atmo.rsvp
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #30 from flo-bit/feat/spaces

fix mentions, link to bsky/blacksky instead of atmo.rsvp profile for …

authored by

Florian and committed by
GitHub
a37f840c 4ee99f77

+41 -15
+1
src/lib/atproto/index.ts
··· 1 1 export { user, login, signup, logout } from './auth.svelte'; 2 + export { getProfileUrl } from './profile-url'; 2 3 3 4 export { 4 5 parseUri,
+7
src/lib/atproto/profile-url.ts
··· 1 + export function getProfileUrl(handleOrDid: string): string { 2 + const lower = handleOrDid.toLowerCase(); 3 + if (lower.endsWith('.blacksky.team') || lower.endsWith('.blacksky.app')) { 4 + return `https://blacksky.community/profile/${handleOrDid}`; 5 + } 6 + return `https://bsky.app/profile/${handleOrDid}`; 7 + }
+20 -10
src/lib/components/event-view/format.ts
··· 1 1 import { marked } from 'marked'; 2 2 import { sanitize } from '$lib/cal/sanitize'; 3 + import { getProfileUrl } from '$lib/atproto/profile-url'; 3 4 import type { FlatEventRecord } from '$lib/contrail'; 4 5 5 6 export function formatMonth(date: Date): string { ··· 135 136 let result = text; 136 137 137 138 if (facets && facets.length > 0) { 138 - const encoder = new TextEncoder(); 139 - const encoded = encoder.encode(text); 139 + const encoded = new TextEncoder().encode(text); 140 140 const decoder = new TextDecoder(); 141 141 142 - const sorted = [...facets].sort((a, b) => b.index.byteStart - a.index.byteStart); 142 + const sorted = [...facets].sort((a, b) => a.index.byteStart - b.index.byteStart); 143 + 144 + const parts: string[] = []; 145 + let cursor = 0; 143 146 144 147 for (const facet of sorted) { 145 148 const feature = facet.features?.[0]; 146 149 if (!feature) continue; 150 + if (facet.index.byteStart < cursor) continue; 147 151 148 - const segmentBytes = encoded.slice(facet.index.byteStart, facet.index.byteEnd); 149 - const segmentText = decoder.decode(segmentBytes); 152 + const segmentText = decoder.decode( 153 + encoded.slice(facet.index.byteStart, facet.index.byteEnd) 154 + ); 150 155 151 156 let mdLink: string | null = null; 152 157 switch (feature.$type) { 153 - case 'app.bsky.richtext.facet#mention': 154 - mdLink = `[${segmentText}](/${feature.did})`; 158 + case 'app.bsky.richtext.facet#mention': { 159 + const handle = segmentText.startsWith('@') ? segmentText.slice(1) : segmentText; 160 + mdLink = `[${segmentText}](${getProfileUrl(handle || feature.did || '')})`; 155 161 break; 162 + } 156 163 case 'app.bsky.richtext.facet#link': 157 164 mdLink = `[${segmentText}](${feature.uri})`; 158 165 break; ··· 162 169 } 163 170 164 171 if (mdLink) { 165 - const before = decoder.decode(encoded.slice(0, facet.index.byteStart)); 166 - const after = decoder.decode(encoded.slice(facet.index.byteEnd)); 167 - result = before + mdLink + after; 172 + parts.push(decoder.decode(encoded.slice(cursor, facet.index.byteStart))); 173 + parts.push(mdLink); 174 + cursor = facet.index.byteEnd; 168 175 } 169 176 } 177 + 178 + parts.push(decoder.decode(encoded.slice(cursor))); 179 + result = parts.join(''); 170 180 } 171 181 172 182 return marked.parse(result, { renderer }) as string;
+2 -5
src/lib/contrail.ts
··· 1 1 import '../lexicon-types/index.js'; 2 + import { getProfileUrl } from '$lib/atproto/profile-url'; 2 3 import type { EventData } from '$lib/event-types'; 3 4 import type { 4 5 RsvpAtmoGetProfile, ··· 159 160 }; 160 161 } 161 162 162 - function getProfileUrl(did: string, handle?: string) { 163 - return `/p/${handle || did}`; 164 - } 165 - 166 163 function buildAttendee( 167 164 did: string, 168 165 status: 'going' | 'interested', ··· 177 174 avatar: getProfileBlobUrl(did, profile?.record?.avatar), 178 175 name: profile?.record?.displayName || handle || did, 179 176 handle, 180 - url: getProfileUrl(did, handle) 177 + url: getProfileUrl(handle || did) 181 178 }; 182 179 } 183 180
+11
src/routes/(app)/+page.svelte
··· 42 42 {/each} 43 43 </div> 44 44 {/if} 45 + 46 + <footer class="text-base-500 dark:text-base-400 mt-24 text-center text-sm"> 47 + <a 48 + href="https://github.com/flo-bit/atmo-events" 49 + target="_blank" 50 + rel="noopener" 51 + class="hover:text-accent-600 dark:hover:text-accent-400 transition-colors" 52 + > 53 + View source on GitHub 54 + </a> 55 + </footer> 45 56 </div>