Browse Source

Fixed JSON thingy.

squarespace
Trey Del Bonis 2 years ago
parent
commit
a03755de7b

+ 1
- 1
markdown/module-1-conflict.md View File

@@ -1,5 +1,5 @@
---
title: 'Conflict Among Comrades :: ProvDSA PoliEd'
title: 'Conflict Among Comrades'
...

# Conflict Among Comrades

+ 1
- 1
markdown/module-2-socialism-101.md View File

@@ -1,5 +1,5 @@
---
title: 'Socialism 101 :: ProvDSA PoliEd'
title: 'Socialism 101'
...

# Socialism 101

+ 1
- 1
markdown/module-3-working-class.md View File

@@ -1,5 +1,5 @@
---
title: 'Why the Working Class? :: ProvDSA PoliEd'
title: 'Why the Working Class?'
...

# Why the Working Class?

+ 1
- 1
markdown/module-4-exploitation.md View File

@@ -1,5 +1,5 @@
---
title: 'Exploitation and Oppression :: ProvDSA PoliEd'
title: 'Exploitation and Oppression'
...

# Exploitation and Oppression

+ 1
- 1
markdown/module-5-imperialism.md View File

@@ -1,5 +1,5 @@
---
title: 'Imperialism and Colonialism :: ProvDSA PoliEd'
title: 'Imperialism and Colonialism'
...

# Imperialism and Colonialism

+ 1
- 1
markdown/module-6-praxis.md View File

@@ -1,5 +1,5 @@
---
title: 'Praxis :: ProvDSA PoliEd'
title: 'Praxis'
...

# Praxis

+ 30
- 4
render.py View File

@@ -5,6 +5,7 @@ import subprocess
import sys
import shutil
import pathlib
import json

output = sys.argv[1]

@@ -24,19 +25,44 @@ for dp, dns, fns in os.walk('static'):
continue
shutil.copy2(os.path.join(dp, fn), os.path.join(output, fn))

TITLE_PREFIX = 'title: '

# Convert and export the markdown files.
def export_markdown(f):
outfile = os.path.splitext(os.path.join(output, f))[0] + '.html'
def export_markdown(path):
title = None

with open('markdown/' + path, 'r') as f:
for l in f.readlines():
# Shittily parse out the thing.
if l.startswith(TITLE_PREFIX):
tstr = l[len(TITLE_PREFIX):]
if tstr.startswith('\''):
tstr = tstr[1:]
if tstr.endswith('\''):
tstr = tstr[:-1]
title = tstr.strip()

title = str(title)

outfile = os.path.splitext(os.path.join(output, path))[0] + '.page'
try:
os.makedirs(os.path.dirname(outfile))
except:
pass
cmd = 'pandoc --from markdown+yaml_metadata_block --to html --standalone --template=pandoc.template --include-in-header=mdheader.htm -o ' + outfile + ' markdown/' + f
cmd = 'pandoc --from markdown+yaml_metadata_block --to html --standalone --template=squarespace.template --include-in-header=mdheader.htm -o ' + outfile + ' markdown/' + path
subprocess.run(cmd.split(), shell=False)

# Generate info file
with open(outfile + '.conf', 'w') as f:
conf = {
'title': '%s :: ProvDSA PoliEd' % title,
'description': '%s - ProvDSA PoliEd Foundational Series' % title
}

json.dump(conf, f, indent=' ')

for dp, dns, fns in os.walk('markdown'):
for fn in fns:
if fn.endswith('~'):
continue
export_markdown(os.path.relpath(os.path.join(dp, fn), 'markdown'))


+ 7
- 0
squarespace.template View File

@@ -0,0 +1,7 @@
$for(include-before)$
$include-before$
$endfor$
$body$
$for(include-after)$
$include-after$
$endfor$

Loading…
Cancel
Save