An HTML-only Bluesky frontend

Added old server code

+87
+87
server.ts
··· 1 + import { serve } from "https://deno.land/std@0.105.0/http/server.ts"; 2 + 3 + const server = serve({ port: 8000 }); 4 + 5 + console.log("HTTP webserver running. Access it at: http://localhost:8000/"); 6 + 7 + for await (const request of server) { 8 + const url = request.url; 9 + let profileContent = ""; 10 + 11 + const match = url.match(/^\/profile\/(.+)$/); 12 + if (match) { 13 + const handle = match[1]; 14 + try { 15 + const response = await fetch(`https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=${handle}`); 16 + if (response.ok) { 17 + const data = await response.json(); 18 + const { avatar, displayName, handle, description, followersCount, followsCount, postsCount } = data; 19 + 20 + console.log(data); 21 + 22 + if ("" == displayName) 23 + displayName == "No Display Name"; 24 + 25 + profileContent = ` 26 + <div class="profile"> 27 + <table width="95%" cellspacing="0" cellpadding="0"> 28 + <tr> 29 + <td align="center" valign="middle"> 30 + <table width="40%" border="0" cellspacing="0" cellpadding="0"> 31 + <tr> 32 + <td align="right"> 33 + <nobr> 34 + <h1>${displayName}<br> 35 + <sup><sup><small><small>@${handle}</small></small></sup></sup> 36 + </h1> 37 + </nobr> 38 + <small> 39 + <span> 40 + <nobr> 41 + Followers <strong>${followersCount}</strong>&nbsp; 42 + Following <strong>${followsCount}</strong>&nbsp; 43 + Posts <strong>${postsCount}</strong> 44 + </nobr> 45 + </span> 46 + <small> 47 + </td> 48 + <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> 49 + <td valign="bottom" align="left"> 50 + <img alt="" draggable="false" src="${avatar}" width="115"> 51 + </td> 52 + 53 + </tr> 54 + </table> 55 + </td> 56 + </tr> 57 + </table> 58 + </div> 59 + `; 60 + } else { 61 + profileContent = "<p>Failed to fetch profile data.</p>"; 62 + } 63 + } catch (error) { 64 + profileContent = `<p>Error: ${error.message}</p>`; 65 + } 66 + } else { 67 + profileContent = "<p>No profile handle provided in the URL.</p>"; 68 + } 69 + 70 + const html = ` 71 + <!DOCTYPE html> 72 + <html lang="en"> 73 + <head> 74 + <meta charset="UTF-8"> 75 + <meta name="viewport" content="width=device-width, initial-scale=1.0"> 76 + <meta name="color-scheme" content="light dark"> 77 + <title>HTML Sky</title> 78 + </head> 79 + <body> 80 + ${profileContent} 81 + </body> 82 + </html> 83 + `; 84 + 85 + request.respond({ status: 200, body: html }); 86 + } 87 +