@@ -31,6 +31,7 @@ import { decode } from "html-entities";
31
31
import type { BotImpl } from "./bot-impl.ts" ;
32
32
import { Layout } from "./components/Layout.tsx" ;
33
33
import { Message } from "./components/Message.tsx" ;
34
+ import { Follower } from "./components/Follower.tsx" ;
34
35
import { getMessageClass , isMessageObject , textXss } from "./message-impl.ts" ;
35
36
import type { MessageClass } from "./message.ts" ;
36
37
import type { Uuid } from "./repository.ts" ;
@@ -142,9 +143,11 @@ app.get("/", async (c) => {
142
143
</ a > { " " }
143
144
·{ " " }
144
145
< span >
145
- { followersCount === 1
146
- ? `1 follower`
147
- : `${ followersCount . toLocaleString ( "en" ) } followers` }
146
+ < a href = "/followers" >
147
+ { followersCount === 1
148
+ ? `1 follower`
149
+ : `${ followersCount . toLocaleString ( "en" ) } followers` }
150
+ </ a >
148
151
</ span > { " " }
149
152
·{ " " }
150
153
< span >
@@ -206,6 +209,41 @@ app.get("/", async (c) => {
206
209
) ;
207
210
} ) ;
208
211
212
+ app . get ( "/followers" , async ( c ) => {
213
+ const { bot } = c . env ;
214
+ const ctx = bot . federation . createContext ( c . req . raw , c . env . contextData ) ;
215
+ const session = bot . getSession ( ctx ) ;
216
+ const followersCount = await bot . repository . countFollowers ( ) ;
217
+ const followers = await Array . fromAsync ( bot . repository . getFollowers ( ) ) ;
218
+
219
+ const url = new URL ( c . req . url ) ;
220
+ const activityLink = ctx . getActorUri ( bot . identifier ) ;
221
+ const feedLink = new URL ( "/feed.xml" , url ) ;
222
+
223
+ return c . html (
224
+ < Layout
225
+ bot = { bot }
226
+ host = { url . host }
227
+ activityLink = { activityLink }
228
+ feedLink = { feedLink }
229
+ >
230
+ < header class = "container" >
231
+ < h1 >
232
+ < a href = "/" > ←</ a > { " " }
233
+ { followersCount === 1
234
+ ? `1 follower`
235
+ : `${ followersCount . toLocaleString ( "en" ) } followers` }
236
+ </ h1 >
237
+ </ header >
238
+ < main class = "container" >
239
+ { followers . map ( ( follower , index ) => (
240
+ < Follower key = { follower . id ?. href ?? index } actor = { follower } session = { session } />
241
+ ) ) }
242
+ </ main >
243
+ </ Layout > ,
244
+ ) ;
245
+ } ) ;
246
+
209
247
app . get ( "/tags/:hashtag" , async ( c ) => {
210
248
const hashtag = c . req . param ( "hashtag" ) ;
211
249
const { bot } = c . env ;
0 commit comments