Skip to content

Instantly share code, notes, and snippets.

@davidbgk
Last active July 8, 2019 13:36
Show Gist options
  • Save davidbgk/b666c5b85ab3d3fd94baef04367ff379 to your computer and use it in GitHub Desktop.
Save davidbgk/b666c5b85ab3d3fd94baef04367ff379 to your computer and use it in GitHub Desktop.
Given a folder containing CommonMark files, turn it into HTML.

Folder2HTML

Goal

Given a folder containing CommonMark files, turn it into HTML.

Requirements

File structure

foo/
  detail.html     # Jinja2 template for detail
  list.html       # …for list
  feed.xml        # …for feed
  2017-01-30.md   # An item to be generated
  hello-world.md  # Another one
  why-not.md      # Filename is not significative
  and so one…

Metadata

Each CommonMark file must have the given metadata elements:

title: A title
url: /bar/a-title/
date: 2017-01-30

And then the content.

Parsing with the metadata extension? The thread about that on CommonMark has no conclusion…

Usage

Generate HTML

$ python3 foo

Launch local server

$ python3 -m http.server

Browse it!

$ open http://localhost:8000/bar/a-title/

Discussion

  • which URL for the list?
  • deploy with now? git*-pages? quid of domains?
  • use pex to ease Python execution?
  • add search with lunrjs which works even with i18n?
@karlcow
Copy link

karlcow commented Jan 30, 2017

It seems

  • the structure exceeds your goal
  • OR the goals are not completely defined.

From the structure, I see:

  1. Given a folder containing CommonMark files, turn them into HTML.
  2. Has a template management system for individual page and indexes
  3. Has a (atom?) feed.
  4. Is a flat directory with all files.
  5. Content has a creation date
  6. Content has a title
  7. Content has a predefined URI.

Missing things for me (but then we are drifting from your goals of simplicity I guess):

  • Template pointer management
  • Modification date management for feed (and HTTP etag computation)
  • No css?
  • I would separate template in their own subfolders

@davidbgk
Copy link
Author

davidbgk commented Jul 8, 2019

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