${esc(shortId(actorOf(t), t.rkey))}
${esc(t.name || 'Untitled tile')}
${t.description ? `${esc(t.description)}
` : ''}// Server-rendered pages. Plain template strings over supram's classes; the // project's own rules live in public/style.css. import { statSync } from 'node:fs'; import { humanBytes, shortId } from './tiles.js'; // The stylesheet is cached for a day; its address changes when it does, so // that new markup never meets an old stylesheet. const STYLE_V = Math.round(statSync(new URL('../public/style.css', import.meta.url)).mtimeMs).toString(36); export const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]); const attr = esc; const SITE = 'appmosphe.re'; // Path segments: encoded, but a DID keeps its colons so URLs stay readable. export const seg = (s) => encodeURIComponent(s).replace(/%3A/gi, ':'); export function fmtDate(iso) { if (!iso) return ''; const d = new Date(iso); if (Number.isNaN(d.getTime())) return ''; return d.toISOString().slice(0, 10); } function timeEl(iso, { derived = false } = {}) { if (!iso) return 'undated'; const title = derived ? `${iso} (from the record key; the record has no createdAt)` : iso; return ``; } export const actorOf = (t) => t.handle || t.did; export const tileHref = (t) => `/@${seg(actorOf(t))}/${seg(t.rkey)}`; export const authorHref = (t) => `/@${seg(actorOf(t))}`; export const imgHref = (did, cid) => `/img/${seg(did)}/${seg(cid)}`; const authorName = (t) => t.displayName || t.handle || t.did; const MARK = ``; const NAV = [ ['/feed', 'Feed'], ['/tiles', 'Tiles'], ['/authors', 'Authors'], ['/publish', 'Publish'], ['/developers', 'Developers'], ['/about', 'About'], ]; export function layout({ title, description, body, path = '/', q = '', stats, config, image, scripts = [] }) { const full = title ? `${title} · ${SITE}` : `${SITE} — Web Tiles on the Atmosphere`; const desc = description || 'Browse the Web Tiles published on the AT Protocol: find tiles by name, description, or author.'; const canonical = `${config.publicUrl}${path}`; const section = `/${path.split('/')[1] || ''}`; return `
${esc(shortId(actorOf(t), t.rkey))}
${esc(t.description)}
` : ''}No tiles here yet.
'; return `Web Tiles on the Atmosphere
Tiles are self-contained web docs and apps that run safely anywhere, from a chat to a feed. ${SITE} finds the ones published on the AT Protocol and runs them.
Search
By name, description, or author.
Browse
${stats.tiles} tiles from ${stats.authors} authors so far.
The feed: every tile, newest first →
Everyone who has published one →
${categories.length ? `${categories.slice(0, 12).map((c) => `${esc(c.category)} ${c.n}`).join(' ')}
` : ''}Publish
Post a tile from a .tile file or a directory, straight from your browser to your repo.
Not seeing a tile that exists? Ask for its repo to be indexed.
${avatar(t, 32)}${esc(authorName(t))} ${t.handle ? `@${esc(t.handle)} · ` : ''}${timeEl(t.createdAt, { derived: t.createdAtDerived })}
${view === 'latest' ? `Every tile, newest first.${paged ? ' Back to the newest' : ''}` : ''}
${empty}
`}${total} ${total === 1 ? 'result' : 'results'} for ${esc(q)}${total ? '' : '. Try fewer words, or an author handle.'}
` : 'Type something to search tile names, descriptions, categories, and authors. Pasting an at:// URI or a short ID like @robin.berjon.com/3meis42djm22d jumps straight to the tile.
${esc(cid)}`;
}
export function tilePage({ tile: t, author, config, prevTile, pds }) {
const actor = actorOf(t);
const id = shortId(actor, t.rkey);
const pics = t.screenshots?.length ? t.screenshots : [];
const kv = [];
if (t.width && t.height) kv.push(['Size', `${t.width} × ${t.height}`]);
if (t.themeColor) kv.push(['Theme colour', ` ${esc(t.themeColor)}`]);
if (t.backgroundColor) kv.push(['Background', ` ${esc(t.backgroundColor)}`]);
kv.push(['Resources', `${t.resourceCount} ${t.resourceCount === 1 ? 'file' : 'files'}${t.totalSize ? `, ${humanBytes(t.totalSize)}` : ''}`]);
kv.push(['Published', timeEl(t.createdAt, { derived: t.createdAtDerived })]);
kv.push(['Indexed', timeEl(t.indexedAt)]);
if (t.shape === 'manifest') kv.push(['Record shape', 'bare MASL manifest']);
const height = Math.max(200, Math.min(1400, t.height || 480));
const runStyle = [t.width ? `--tile-w: ${t.width}px` : '', t.backgroundColor ? `--tile-bg: ${attr(t.backgroundColor)}` : ''].filter(Boolean).join('; ');
return `
@${esc(actor)}/${esc(t.rkey)}
Loading the tile…
${esc(t.description)}
` : ''} ${t.categories.length ? `${t.categories.map((c) => `${esc(c)}`).join(' ')}
` : ''} ${tileActions(t)}Copy at:// link View record ↗ JSON ${t.handle ? `Publish a new version` : ''}
${esc(id)}${esc(t.uri)}| Path | Type | Size | CID |
|---|---|---|---|
${esc(r.path)}${Object.keys(r.headers).length ? `${Object.entries(r.headers).map(([k, v]) => `${esc(k)}: ${esc(v)}`).join(' · ')}` : ''} | ${esc(r.contentType || '—')} | ${humanBytes(r.size)} | ${cidCode(r.cid)} |
${esc(JSON.stringify(t.record, null, 2))}
Indexing requested. Tiles from this account will appear here once its repo has been synced, usually within a minute; reload to check.
` : ''}Index wishes
${SITE} watches the network for ing.dasl.masl records, so new tiles turn up by themselves. If yours hasn't, or you'd like it synced right now, ask here.
${esc(error)}
` : ''} ${result ? `Tracking @${esc(result.handle || result.did)}. ${result.count ? `${result.count} ${result.count === 1 ? 'tile is' : 'tiles are'} indexed: see them.` : `Nothing indexed yet; tiles appear on the author page once the repo has been synced.`}
` : ''}curl -X POST https://${SITE}/api/index \\
-H 'content-type: application/json' \\
-d '{"actor": "robin.berjon.com"}'
Returns { did, handle, tiles, url }; 400 if the account can't be resolved. Please keep it to a few requests a minute.
Publish
From a .tile carball or a tile source directory. Everything happens in your browser: resources go to your PDS as blobs, and the manifest becomes an ing.dasl.masl record signed by your account.
1 · Account
Loading…
2 · Tile
Preview
Running from memory, nothing uploaded yet.
3 · Manifest
4 · Record
Will be published at
Each blob reference is replaced by the one your PDS answers the upload with, whose mimeType is the type it stored the blob under.
Blobs upload first; the record is written last.
Nothing you load here leaves your browser until you press Publish, and then it goes to your own PDS only; ${SITE} just gets told to index the result. To update a tile you published elsewhere, choose it under "Update one of my tiles" and prev is filled in for you. Developing locally? Use http://127.0.0.1 rather than localhost, so the loopback OAuth client's origin matches.
${esc(s)}`;
return `
Developers
What a tile is on AT, the tools that make, run and publish them, and how to put all of that in your own app.
A tile is a bundle of web resources described by a MASL manifest in bundle mode: a name, a resources map from paths to content-addressed blobs with their HTTP headers (at least content-type), and the usual web-app-manifest extras (description, icons, screenshots, categories, theme_color, background_color, sizing). The / entry is what gets rendered. When it runs, a tile can only load what its manifest lists; the embedding app mediates everything else. The Web Tiles spec has the details, including the CSP that a tile execution context must enforce.
On AT, a tile is a record in the ing.dasl.masl collection of its author's repository. Each resource is uploaded as a blob, and the manifest's src entries are blob refs, so the PDS keeps the blobs alive:
@handle/rkey.src is the blob reference the PDS answered the upload with, as it came: size and mimeType included. Upload as application/octet-stream, as the spec recommends; some PDSs (the reference one among them) sniff what they are sent, store the blob under the type they recognise (image/png above), and refuse a record whose reference names another type. mimeType need not match content-type, which is what the tile is served with.cid is the CID of the tile object as DRISL (dag-cbor, codec 0x71, sha-256). It is what prev points at in a later version..tile file the same manifest is the CAR header (with version: 1 and roots: [] added) and the resources are the CAR blocks, linked with plain { "$link": … } CIDs instead of blob refs.A tile source directory is just index.html (it becomes /), a manifest.json with at least a name, and whatever else the page needs. Content types are guessed from file names; anything you put under resources in the manifest is kept.
atile (@dasl/tiles)The command-line tool. It bundles a directory into a .tile, or publishes it to your repo with an app password.
-s remembers the at:// URI per directory in ~/.atile/identifiers.json, so republishing overwrites the same record. atile does not set prev; add "prev": { "$link": "…" } to manifest.json yourself if you want the chain.
Blastile is an app for working with tiles: open a .tile or an at:// URI, watch a source directory with live reload, exchange data with the tile from a console, and publish over AT OAuth. A published tile links to its page here.
It comes two ways. In the browser, with nothing to install: tiles stay in your browser and publishing goes straight to your PDS. And as a desktop app to download, which reads tile directories from disk, shares ~/.atile/identifiers.json with atile so a directory keeps the same record whichever tool publishes it, and runs tiles isolated on random *.localhost origins with the network locked down. The source is in the DASL tiles repository.
tilers follows RSS, Atom and JSON feeds and turns each new entry into a self-contained tile (article, styles, fonts, images), saved as .tile and optionally published to your repo.
The publish page takes a .tile or a directory, lets you check and edit the manifest, pick the record key (a fresh TID, your own, or an existing tile to update with prev set), previews the tile, and writes it to your repo from the browser.
Tiles must run in an origin of their own with the spec's CSP sandbox, which the browser can't fake in-page. @dasl/tile-loader gives you a mothership on your page, which mints an iframe on a random subdomain of a load domain running @dasl/tile-server; the server serves the shuttle runtime with the right headers, and the shuttle asks the mothership for the tile's resources over postMessage. The tile never touches the network itself.
ATTileLoader takes at://<did>/ing.dasl.masl/<rkey>, with a did:plc or a did:web (a host name alone, as AT allows: no path, no port). A handle works in place of the DID too (at://alice.example/…): the loader resolves it and checks that the DID claims it back.tileLinks in @dasl/tile-loader/link, the link protocol): without a handler nothing opens, and linkPrompt shows the user the whole address as a link of yours to follow. Your page frames the loading server only (a frame-src for it is worth having); the tile's own origin is framed there, by a page that keeps it in place.tileSize (@dasl/tile-loader/size) is the size protocol: the frame starts at the size the manifest's sizing asks for and follows what the tile asks for as it runs, or its content when the manifest says "fit": "height", always inside your limits and never under 48 by 48 pixels. The width stays your layout's unless you pass width: 'tile', which makes it the tile's to ask for as well: this site does, with the room its page has as the most a tile gets (sizeTile in web/run-tile.js).@dasl/tile-loader/car loads .tile files over HTTP; @dasl/tile-loader/memory runs a manifest whose src entries are bytes or strings you already hold (that is how the publish page previews before uploading).renderContent() makes is sandboxed already (allow-scripts allow-same-origin allow-forms: no dialogs, no downloads), credentialless on an origin made for the load, and refuses synchronous requests. Its options (sandbox, refuse, credentialless) change that; a sandbox only ever takes away from what the runtime grants. A frame of your own, given to attachIframe(), gets none of it unless you set the attributes.load.webtil.es; ${SITE} uses ${esc(config.tileLoadDomain)}. Your own is one Express app plus wildcard DNS and TLS:Every tile load is a new hostname, so the certificate has to be a wildcard (DNS-01), not per-host on-demand issuance. hardenServer makes what Node answers by itself a dead end too, and the larger header limit leaves room for the cookies a tile can leave. Under /.well-known/web-tiles/ the runtime also serves the modules a tile imports for the tiles protocols: data.js, size.js and link.js. On your page, tileData(tile) from @dasl/tile-loader/data is the other end of data.js.
It is a short sequence of XRPC calls against the author's PDS, which the publish page makes from the browser (web/publish-tile.js in its source). The part about blobs is in @dasl/tile-lexicon, as atile and Blastile use it: blobUploadType, uploadedBlobRef and verifyUploadedBlob.
0x55, sha-256; @atcute/cid's create(CODEC_RAW, bytes)). Resources with the same bytes share a CID.com.atproto.repo.uploadBlob each one with Content-Type: application/octet-stream (blobUploadType), and keep the blob reference it answers with, once you have checked that it names your bytes: verifyUploadedBlob(path, ours, uploadedBlobRef(answer.blob)), where ours is { "$type": "blob", "ref": { "$link": cid }, "mimeType": "application/octet-stream", "size": bytes.length }. It throws if the CID or the size differ.src, mimeType and all (not a type of your own: the PDS refuses a record that names another type than the one it stored), and a content-type per resource; set prev to the previous manifest CID when you are replacing a tile.cid = the DRISL CID of that tile object, with the PDS's references in it (@atcute/cbor's encode, then create(CODEC_DCBOR, bytes)). Encoding { "$link": … } yields CBOR tag 42, as it must.com.atproto.repo.putRecord with collection: "ing.dasl.masl", your record key, and { $type, cid, tile, createdAt }.With OAuth, ask for ${esc(config.oauthScope)}: the repo: scope covers the collection, blob:*/* the uploads. Then POST ${esc(config.publicUrl)}/api/index with {"actor": did} so the tile shows up here within seconds rather than on the next relay sweep.
GET /api/feed?cursor=…&limit=N (every tile, newest first; pass back the cursor you were given until it is null), GET /api/tiles?page=N, GET /api/search?q=…, GET /api/tiles/:actor/:rkey (full record included), GET /api/authors, GET /api/authors/:actor, GET /api/stats. All JSON, no auth, and open to any origin (CORS *), so a page on another site can call them directly.community.lexicon.interaction.like record to your repo, with the tile record as its subject (a strongRef: uri and cid); bookmarking writes a community.lexicon.bookmarks.bookmark whose subject is the tile's at:// URI. Both are the community lexicons, so any app can write them, and both are public. Tiles carry a likeCount: one per account, from likes the index has checked against the liker's PDS. To have a like you just wrote (or deleted) counted at once, POST /api/likes with {"uri": "at://<did>/community.lexicon.interaction.like/<rkey>"}.TAP_SIGNAL_COLLECTION=ing.dasl.masl TAP_COLLECTION_FILTERS=ing.dasl.masl; it tracks every repo with a tile, verifies and backfills, and streams the records. That is what ${SITE} does.com.atproto.sync.listReposByCollection?collection=ing.dasl.masl on a relay lists the repos; com.atproto.repo.listRecords on each PDS lists the tiles.About
A map of the Web Tiles published on the AT Protocol, and a place to run and publish them.
Web Tiles are composable web docs and apps that can be embedded safely anywhere: a tile can only load the resources its manifest lists, and the embedding app mediates everything else. On AT, a tile is an ing.dasl.masl record in its author's repository, with its resources uploaded as blobs; the manifest is a MASL document.
${SITE} follows the network for those records, keeps the manifests, shows them with the metadata they carry, and runs each tile on its page through @dasl/tile-loader. The feed has all of them, newest first; sign in to like and bookmark tiles, which writes public records to your own repo. You can also publish a tile from here, and read how to build with them.
Every tile has an at:// URI. The short form drops the collection and swaps the DID for the author's handle: at://robin.berjon.com/ing.dasl.masl/3meis42djm22d is @robin.berjon.com/3meis42djm22d, and that is also its path here. Handles can change, so the DID form (/@did:plc:…/3meis42djm22d) always works too.
${mode === 'tap' ? 'A dedicated Tap instance subscribes to the relay, tracks every repo with at least one ing.dasl.masl record, verifies signatures, backfills, and streams records here.' : 'The index polls each repo\'s PDS directly (development mode).'} The relay is also asked hourly which repos carry the collection, and anyone can ask for a repo to be indexed right away. Author profiles come from the public Bluesky API and are refreshed daily.
Right now: ${stats.tiles} tiles from ${stats.authors} authors, ${stats.repos} repos tracked.
GET /api/feed?cursor=…GET /api/tiles?page=N, GET /api/tiles?category=…GET /api/search?q=…GET /api/tiles/:actor/:rkeyGET /api/authors, GET /api/authors/:actorPOST /api/index with {"actor": "…"}POST /api/likes with {"uri": "…"}GET /api/statsBuilt by Robin Berjon; source on Tangled.
${status}
${text}