Skip to content

Instantly share code, notes, and snippets.

@dypsilon
Last active September 26, 2015 01:15
Show Gist options
  • Select an option

  • Save dypsilon/406e3c15aa2cb91fce82 to your computer and use it in GitHub Desktop.

Select an option

Save dypsilon/406e3c15aa2cb91fce82 to your computer and use it in GitHub Desktop.
Dynamic Routing for fluo

Dynamic Routing

Item Block

Contexts: browser, server

  1. Takes the image id provided by the storage and creates an URL like /carousel/06a55f5c-fb24-4a81-8ab8-abb0f630ce81.jpeg
  2. Passes it as a source to the lazy image.

Lazy Image

Contexts: browser

  1. Finds the nearest breakpoint and adds the width of the breakpoint to the file name: /carousel/06a55f5c-fb24-4a81-8ab8-abb0f630ce81_800.jpeg
  2. Tells the browser to load the image which sends a request to the route handler.

Route Handler

Contexts: dynserver, publisher

  1. Takes an URL of the form "/carousel/{image_name}" (Example: /carousel/06a55f5c-fb24-4a81-8ab8-abb0f630ce81_800.jpeg)
  2. Transforms the URL into /carousel/files/06a55f5c-fb24-4a81-8ab8-abb0f630ce81.jpeg?width=800
  3. Sents a request to the store.
  4. Forwards the reply as a stream.

URL Generator

Contexts: publisher

  1. Makes a request to the store.
  2. Generates URLs for each carousel, each image and each breakpoint.
  3. Returns all URLs as a flat array. Example:

/carousel/06a55f5c-fb24-4a81-8ab8-abb0f630ce81_320.jpeg /carousel/06a55f5c-fb24-4a81-8ab8-abb0f630ce81_800.jpeg /carousel/06a55f5c-fb24-4a81-8ab8-abb0f630ce81_1200.jpeg /carousel/06a55f5c-fb24-4a81-8ab8-abb0f630ce81_1590.jpeg

Publisher

  1. Collects the URLs from all generators.
  2. Crawls all urls (route handlers are called).
  3. Saves the responses into corresponding files.

Dynamic Servers (devserver, preview)

  1. Find the corresponding route handler for the incomming URL (Example: /carousel/06a55f5c-fb24-4a81-8ab8-abb0f630ce81_800.jpeg)
  2. Forward the reply as a stream to the browser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment