feat: Share URLs

Introduces a new share dialog that contains buttons to copy a new share URL

Fixes #33 (closed)

Related to #44

Screenshots

image

New Dependencies

  • canvas to create and render elements server-side (⚠️ This introduces new binary requirements, see project)
  • isbot to identify crawlers

Implementation

A new endpoint is served (/share/X,Y/z=ZOOM?[...]) that will redirect normal browsers to the standard UI (/#x=X&y=Y&...) and bots that were detected by isbot will be served a dummy page with opengraph metadata to render information to the user (eg, when sent in an app like Discord)

Preview images of the canvas are available now at /api/share/preview?x=X&y=Y&zoom=ZOOM and will be cached for 5 minutes server-side and clients are encouraged to cache the image for 15 minutes

URL Schema (/share/...)

  • /share/{x},{y}/z={zoom}?template={template}&x={templatex}&y={templatey}&w={templatewidth}&style={templatestyle}
  • /share/{x},{y}?template={template}&x={templatex}&y={templatey}&w={templatewidth}&style={templatestyle}
Template Type What?
{x} number pixel to center on
{y} number pixel to center on
{zoom} number zoom level
{template} url template image URL, the UI will generate a data: uri for images (easier for static linking)
{templatex} number top left corner of the template placement
{templatey} number top left corner of the template placement
{templatewidth} number width of the template in pixels
{templatestyle} enum what template style to use

Preview Endpoint (/api/share/preview)

  • Server cached by 5 minutes
  • Clients encouraged to cache for 15 minutes (Cache-Control)
Query Type What?
x number pixel to be centered on
y number pixel to be centered on
zoom number? zoom scale (pixels included in each direction = 5 * (zoom + 1))
Edited by Grant

Merge request reports

Loading