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)