From b58bb91ffb721523c5dd5fefc61cd4ef40b4d8ad Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Wed, 15 Feb 2017 15:25:42 -0600 Subject: [PATCH] Moved static hosting to Netlify. --- website/.netlify | 1 + website/Makefile | 5 ++ website/{ => content}/agendas/2017-01-03.md | 0 .../agendas/first-meeting-agenda.md | 0 website/content/agendas/index.html | 1 + .../{ => content}/css/new-life-intro-band.css | 0 website/{ => content}/img/gears.svg | 0 website/{ => content}/index.md | 0 website/content/lead-sheets/index.html | 1 + .../reference-tracks/clicks/index.html | 1 + .../divine-exchange-charity-gayle/index.html | 1 + .../freedome-eddie-james/index.html | 1 + website/content/reference-tracks/index.html | 1 + .../index.html | 1 + .../schedules/2016-11-november.md | 0 .../schedules/2016-12-december.md | 0 .../schedules/2017-01-january.md | 0 .../{ => content}/schedules/2017-03-march.md | 0 website/content/schedules/index.html | 1 + website/make_site.nim | 73 +++++++++++-------- 20 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 website/.netlify create mode 100644 website/Makefile rename website/{ => content}/agendas/2017-01-03.md (100%) rename website/{ => content}/agendas/first-meeting-agenda.md (100%) create mode 120000 website/content/agendas/index.html rename website/{ => content}/css/new-life-intro-band.css (100%) rename website/{ => content}/img/gears.svg (100%) rename website/{ => content}/index.md (100%) create mode 120000 website/content/lead-sheets/index.html create mode 120000 website/content/reference-tracks/clicks/index.html create mode 120000 website/content/reference-tracks/divine-exchange-charity-gayle/index.html create mode 120000 website/content/reference-tracks/freedome-eddie-james/index.html create mode 120000 website/content/reference-tracks/index.html create mode 120000 website/content/reference-tracks/only-king-forever-elevation-worship/index.html rename website/{ => content}/schedules/2016-11-november.md (100%) rename website/{ => content}/schedules/2016-12-december.md (100%) rename website/{ => content}/schedules/2017-01-january.md (100%) rename website/{ => content}/schedules/2017-03-march.md (100%) create mode 120000 website/content/schedules/index.html diff --git a/website/.netlify b/website/.netlify new file mode 100644 index 0000000..98397ca --- /dev/null +++ b/website/.netlify @@ -0,0 +1 @@ +{"site_id":"40aedb36-8379-4429-94ff-e59e9d740396","path":"rendered"} \ No newline at end of file diff --git a/website/Makefile b/website/Makefile new file mode 100644 index 0000000..52513cb --- /dev/null +++ b/website/Makefile @@ -0,0 +1,5 @@ +deploy: render + netlify deploy -s newlifeintroband -p rendered + +render: + nim c -r make_site.nim diff --git a/website/agendas/2017-01-03.md b/website/content/agendas/2017-01-03.md similarity index 100% rename from website/agendas/2017-01-03.md rename to website/content/agendas/2017-01-03.md diff --git a/website/agendas/first-meeting-agenda.md b/website/content/agendas/first-meeting-agenda.md similarity index 100% rename from website/agendas/first-meeting-agenda.md rename to website/content/agendas/first-meeting-agenda.md diff --git a/website/content/agendas/index.html b/website/content/agendas/index.html new file mode 120000 index 0000000..54bb512 --- /dev/null +++ b/website/content/agendas/index.html @@ -0,0 +1 @@ +../../s3-dir-listing.html \ No newline at end of file diff --git a/website/css/new-life-intro-band.css b/website/content/css/new-life-intro-band.css similarity index 100% rename from website/css/new-life-intro-band.css rename to website/content/css/new-life-intro-band.css diff --git a/website/img/gears.svg b/website/content/img/gears.svg similarity index 100% rename from website/img/gears.svg rename to website/content/img/gears.svg diff --git a/website/index.md b/website/content/index.md similarity index 100% rename from website/index.md rename to website/content/index.md diff --git a/website/content/lead-sheets/index.html b/website/content/lead-sheets/index.html new file mode 120000 index 0000000..54bb512 --- /dev/null +++ b/website/content/lead-sheets/index.html @@ -0,0 +1 @@ +../../s3-dir-listing.html \ No newline at end of file diff --git a/website/content/reference-tracks/clicks/index.html b/website/content/reference-tracks/clicks/index.html new file mode 120000 index 0000000..7e6ac2d --- /dev/null +++ b/website/content/reference-tracks/clicks/index.html @@ -0,0 +1 @@ +../../../s3-dir-listing.html \ No newline at end of file diff --git a/website/content/reference-tracks/divine-exchange-charity-gayle/index.html b/website/content/reference-tracks/divine-exchange-charity-gayle/index.html new file mode 120000 index 0000000..7e6ac2d --- /dev/null +++ b/website/content/reference-tracks/divine-exchange-charity-gayle/index.html @@ -0,0 +1 @@ +../../../s3-dir-listing.html \ No newline at end of file diff --git a/website/content/reference-tracks/freedome-eddie-james/index.html b/website/content/reference-tracks/freedome-eddie-james/index.html new file mode 120000 index 0000000..7e6ac2d --- /dev/null +++ b/website/content/reference-tracks/freedome-eddie-james/index.html @@ -0,0 +1 @@ +../../../s3-dir-listing.html \ No newline at end of file diff --git a/website/content/reference-tracks/index.html b/website/content/reference-tracks/index.html new file mode 120000 index 0000000..54bb512 --- /dev/null +++ b/website/content/reference-tracks/index.html @@ -0,0 +1 @@ +../../s3-dir-listing.html \ No newline at end of file diff --git a/website/content/reference-tracks/only-king-forever-elevation-worship/index.html b/website/content/reference-tracks/only-king-forever-elevation-worship/index.html new file mode 120000 index 0000000..7e6ac2d --- /dev/null +++ b/website/content/reference-tracks/only-king-forever-elevation-worship/index.html @@ -0,0 +1 @@ +../../../s3-dir-listing.html \ No newline at end of file diff --git a/website/schedules/2016-11-november.md b/website/content/schedules/2016-11-november.md similarity index 100% rename from website/schedules/2016-11-november.md rename to website/content/schedules/2016-11-november.md diff --git a/website/schedules/2016-12-december.md b/website/content/schedules/2016-12-december.md similarity index 100% rename from website/schedules/2016-12-december.md rename to website/content/schedules/2016-12-december.md diff --git a/website/schedules/2017-01-january.md b/website/content/schedules/2017-01-january.md similarity index 100% rename from website/schedules/2017-01-january.md rename to website/content/schedules/2017-01-january.md diff --git a/website/schedules/2017-03-march.md b/website/content/schedules/2017-03-march.md similarity index 100% rename from website/schedules/2017-03-march.md rename to website/content/schedules/2017-03-march.md diff --git a/website/content/schedules/index.html b/website/content/schedules/index.html new file mode 120000 index 0000000..54bb512 --- /dev/null +++ b/website/content/schedules/index.html @@ -0,0 +1 @@ +../../s3-dir-listing.html \ No newline at end of file diff --git a/website/make_site.nim b/website/make_site.nim index 47f609c..d9bff4d 100644 --- a/website/make_site.nim +++ b/website/make_site.nim @@ -2,12 +2,20 @@ # author: Jonathan Bernard # # 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)