summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/html38
-rw-r--r--templates/html/news.html4
2 files changed, 22 insertions, 20 deletions
diff --git a/bin/html b/bin/html
index c12b9bc..a317359 100644
--- a/bin/html
+++ b/bin/html
@@ -13,9 +13,11 @@ import subprocess as subp
import sys
+SECTIONS = ['news']
+
# placeholders
PH = {
- 'title': '<!-- NEWS-ITEM-TITLE -->',
+ 'title': '<!-- ITEM-TITLE -->',
'date': '<!-- DATE -->',
'content': '<!-- MAIN-CONTENT -->',
}
@@ -35,8 +37,8 @@ def fok(f):
return True
-def files():
- files = os.scandir('md/news')
+def files(sec):
+ files = os.scandir('md' + '/' + sec)
fs = []
for f in files:
@@ -121,31 +123,31 @@ def markdown(c):
return r.stdout
-def html(t, d, c):
- h = template('news')
- h = h.replace(PH['title'], t, 2)
- h = h.replace(PH['date'], datefmt(d), 1)
- h = h.replace(PH['content'], markdown(c), 1)
-
- return h
-
-
-def process(f):
+def html(sec, f):
c = read(f.path)
-
s = slug(f.path)
+
t = title(c)
d = date(c)
c = content(c)
- h = html(t, d, c)
+ h = template(sec)
+ h = h.replace(PH['title'], t, 2)
+ h = h.replace(PH['date'], datefmt(d), 1)
+ h = h.replace(PH['content'], markdown(c), 1)
+
+ return s, h
+
- write('/'.join(['_build', 'news', s, 'index.html']), h)
+def process(sec):
+ for f in files(sec):
+ s, h = html(sec, f)
+ write('/'.join(['_build', sec, s, 'index.html']), h)
def run():
- for f in files():
- process(f)
+ for sec in SECTIONS:
+ process(sec)
if __name__ == "__main__":
diff --git a/templates/html/news.html b/templates/html/news.html
index ff4c932..7f60c6f 100644
--- a/templates/html/news.html
+++ b/templates/html/news.html
@@ -1,7 +1,7 @@
<!--#include virtual="/includes/html-open.html"-->
<!--#include virtual="/includes/header-open.html"-->
-<title><!-- NEWS-ITEM-TITLE --> &mdash; News &mdash; Free Software Foundation India</title>
+<title><!-- ITEM-TITLE --> &mdash; News &mdash; Free Software Foundation India</title>
<!--#include virtual="/includes/header-close.html"-->
<!--#include virtual="/includes/body-open.html"-->
@@ -15,7 +15,7 @@
<div class="header">
<hgroup>
<h1><span class="tag is-medium">News</span></h1>
- <h2><!-- NEWS-ITEM-TITLE --></h2>
+ <h2><!-- ITEM-TITLE --></h2>
</hgroup>
</div>