Skip to content

Instantly share code, notes, and snippets.

@pfrazee
Created November 3, 2016 18:55
Show Gist options
  • Save pfrazee/2e762a4a793a142d80901c8d0ca1554e to your computer and use it in GitHub Desktop.
Save pfrazee/2e762a4a793a142d80901c8d0ca1554e to your computer and use it in GitHub Desktop.

Dat file-path duck-typing

In the /log reader, I'm using pathnames to infer the content-types, and schemas, of data-files stored in dats. It will assume that files which match against /log/*.txt are text/plain files which should be listed in this application's feed.

My thinking is, this is a 1) convenient 2) simple and 3) descriptive-enough way to handle data meta-information. It's more convenient than writing out explicit metadata in the dat.json file, and it's also easy to write path-matching rules for (using unix path-globs).

Some example duck-typing rules:

  • /dat.json - the dat metadata file

  • /favicon.{ico,png,jpg,jpeg} - favicon for the dat

  • /log/*.txt - blog posts about the archive

  • /photos/*/*.{png,jpg,jpeg} - photo album pics

  • /photos/*/album.json - metadata file about a photo album

Might work, might not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment