Moved static hosting to Netlify.

This commit is contained in:
Jonathan Bernard 2017-02-15 15:25:42 -06:00
parent 4f93b3132a
commit b58bb91ffb
20 changed files with 58 additions and 29 deletions

1
website/.netlify Normal file
View File

@ -0,0 +1 @@
{"site_id":"40aedb36-8379-4429-94ff-e59e9d740396","path":"rendered"}

5
website/Makefile Normal file
View File

@ -0,0 +1,5 @@
deploy: render
netlify deploy -s newlifeintroband -p rendered
render:
nim c -r make_site.nim

View File

@ -0,0 +1 @@
../../s3-dir-listing.html

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1 @@
../../s3-dir-listing.html

View File

@ -0,0 +1 @@
../../../s3-dir-listing.html

View File

@ -0,0 +1 @@
../../../s3-dir-listing.html

View File

@ -0,0 +1 @@
../../../s3-dir-listing.html

View File

@ -0,0 +1 @@
../../s3-dir-listing.html

View File

@ -0,0 +1 @@
../../../s3-dir-listing.html

View File

@ -0,0 +1 @@
../../s3-dir-listing.html

View File

@ -2,12 +2,20 @@
# author: Jonathan Bernard <jonathan@jdbernard.com>
#
# Stupid-simple static site generator. Operates on the current working
# directory. Outputs rendered HTML to a directory named 'rendered'. Reads in an
# HTML template from a file 'template.html'. Walks the current working directory
# looking for files with the '.rst' extension, splits out optional front-matter
# (JSON), compiles the rest into HTML fragments, stuffs the fragments into the
# template and write an HTML file at the same relative path in the 'rendered'
# directory with the same filename (extension changed to .html).
# directory. Outputs rendered HTML to a directory named 'rendered'.
#
# 1. Reads in an HTML template from a file 'template.html'.
# 3. Walks the 'content' directory looking for files.
#
# a. For all files with the '.md' extension:
# i. splits out optional front-matter (JSON),
# ii. compiles the rest into HTML fragments,
# iii. stuffs the fragments into the template, and
# iv. writes an HTML file at the same relative path in the 'rendered'
# directory with the same filename (extension changed to .html).
#
# b. For all other files, copies them verbatim into the same relative path
# in the 'rendered' directory.
import json, nre, os, osproc
from strutils import endsWith, rfind
@ -22,34 +30,41 @@ let tempFile = "temp.make_site.md"
if not dirExists("rendered"): createDir("rendered")
# Walk the directory looking for .md files.
for file in walkDirRec("."):
if not file.endsWith(".md"): continue
for file in walkDirRec("content", {pcFile, pcDir, pcLinkToFile}):
#echo "Considering " & file
let dir = file[8..file.rfind('/')]
let filename = file[(file.rfind('/') + 1)..^1]
echo "> Rendering " & file
var renderedTemplate = htmlTemplate
var mdDoc: string
let outputFile = "rendered/" & file.replace(mdExtRe, "html")
let outputDir = "rendered/" & file[0..file.rfind('/')]
# Create output subdir if necessary
if not existsDir("rendered/" & dir): createDir("rendered/" & dir)
if not existsDir(outputDir): createDir(outputDir)
if filename.endsWith(".md"):
echo "> Rendering " & dir & filename
var renderedTemplate = htmlTemplate
var mdDoc: string
let outputFile = "rendered/" & dir & filename.replace(mdExtRe, "html")
# Split out front-matter
let docSplit = file.readFile.split(re"\+\+\+", 2)
# Split out front-matter
let docSplit = file.readFile.split(re"\+\+\+", 2)
# Parse the front-matter (if there is any)
if docSplit.len > 1:
let metadata = json.parseJson(docSplit[0])
mdDoc = docSplit[1]
for key, value in metadata:
let replKey = re("<%" & key & "%>")
renderedTemplate = htmlTemplate.replace(replKey, value.getStr)
else: mdDoc = docSplit[0]
# Parse the front-matter (if there is any)
if docSplit.len > 1:
let metadata = json.parseJson(docSplit[0])
mdDoc = docSplit[1]
for key, value in metadata:
let replKey = re("<%" & key & "%>")
renderedTemplate = htmlTemplate.replace(replKey, value.getStr)
else: mdDoc = docSplit[0]
# Compile the file into an HTML fragment
writeFile(tempFile, mdDoc)
let htmlDoc = execProcess("markdown " & tempFile)
renderedTemplate = renderedTemplate.replace(contentKey, htmlDoc)
# Compile the file into an HTML fragment
writeFile(tempFile, mdDoc)
let htmlDoc = execProcess("markdown " & tempFile)
renderedTemplate = renderedTemplate.replace(contentKey, htmlDoc)
writeFile(outputFile, renderedTemplate)
writeFile(outputFile, renderedTemplate)
else:
echo "> Copying " & dir & filename
copyFile(file, "rendered/" & dir & filename);
removeFile(tempFile)