diff options
author | Daniel Jones <daniel@danieljon.es> | 2017-12-10 00:48:33 -0500 |
---|---|---|
committer | Daniel Jones <daniel@danieljon.es> | 2017-12-10 00:48:33 -0500 |
commit | b10ec6100457950a54e60798e0f6ca8f56add7d0 (patch) | |
tree | ada1d2c57f5f8340225ac009a8d5605fcebd51d3 | |
parent | b6c7a333d9e98dc6974ad794a78437bb85753207 (diff) | |
parent | 746b166704068d2be7762a9c2885f08dae18a891 (diff) | |
download | website-b10ec6100457950a54e60798e0f6ca8f56add7d0.tar.gz website-b10ec6100457950a54e60798e0f6ca8f56add7d0.zip |
Merge branch 'master' of /home/daniel/git/website
-rw-r--r-- | generatesite.py | 22 | ||||
-rw-r--r-- | settings.cfg | 2 | ||||
-rwxr-xr-x | setup.sh | 1 |
3 files changed, 19 insertions, 6 deletions
diff --git a/generatesite.py b/generatesite.py index 38e2cbc..6e827e5 100644 --- a/generatesite.py +++ b/generatesite.py @@ -71,10 +71,12 @@ def generateblog(): template = cfg.get("output", "template"); outdir = cfg.get("output", "dir"); blogdir = cfg.get("blog", "dir"); + directdir = cfg.get("blog", "direct"); blogsrc = cfg.get("blog", "srcdir"); perpage = cfg.get("blog", "perpage"); print("generating {}/{}/ from directory /{}/final".format(outdir, blogdir, blogsrc)); os.makedirs(outdir + "/" + blogdir, exist_ok=True); + os.makedirs(outdir + "/" + blogdir + "/" + directdir, exist_ok=True); os.makedirs(blogsrc + "/final", exist_ok=True); # number of blog posts postcount = len(glob.glob1(blogsrc, "*.txt")); @@ -114,7 +116,7 @@ def generateblog(): if count < postcount + 1: with open(blogsrc + "/final/" + str(x) + ".txt") as contentfile: content = contentfile.read(); - page += "<div id='" + str(total_count) + "'> <a href='" + str(cpage) + ".html#" + str(total_count) + "'>#" + str(total_count) + "</a>" + content + "</div><hr>"; + page += "<div id='" + str(total_count) + "'> <a href='" + directdir + "/" + str(total_count) + ".html'>direct link</a>" + content + "</div><hr>"; count += 1; total_count -= 1; if cpage <= pagecount: @@ -123,11 +125,19 @@ def generateblog(): replace(outdir + "/" + blogdir + "/" + str(cpage) + ".html", "{CONTENT}", page); page = ""; cpage += 1; - ''' - for x in range(1, postcount + 1): - with open(blogsrc + "/" + str(x) + ".txt", "r") as t: - print(t.read()); - ''' + # generate /direct/ pages + for x in range(1, int(postcount) + 1): + copyfile(template, outdir + "/" + blogdir + "/" + directdir + "/" + str(x) + ".html"); + replace(outdir + "/" + blogdir + "/" + directdir + "/" + str(x) + ".html", "{TITLE}", cfg.get("blog", "title")); + replace(outdir + "/" + blogdir + "/" + directdir + "/" + str(x) + ".html", "{INFO}", cfg.get("blog", "header")); + replace(outdir + "/" + blogdir + "/" + directdir + "/" + str(x) + ".html", "{TIME}", strftime("%Y-%m-%d %H:%M:%S", gmtime())); + with open(blogsrc + "/" + str(x) + ".txt") as contentfile: + content = contentfile.read(); + replace(outdir + "/" + blogdir + "/" + directdir + "/" + str(x) + ".html", "{CONTENT}", content); + replace(outdir + "/" + blogdir + "/" + directdir + "/" + str(x) + ".html", "media/", "../media/"); + + + def generateanime(): template = cfg.get("output", "template"); diff --git a/settings.cfg b/settings.cfg index 79a0388..78e207c 100644 --- a/settings.cfg +++ b/settings.cfg @@ -14,6 +14,8 @@ title = daniel's blog header = <h1>Blog</h1> Rambles about myself and programming <br><br> Comments welcome - comments@danieljon.es<br><br> # blog directory dir = blog +# direct link directory +direct = direct srcdir = content/blog # number of posts per page perpage = 7 @@ -1,6 +1,7 @@ # directories mkdir output/ mkdir output/blog/ +mkdir output/blog/direct mkdir output/viewings/ mkdir output/waifus/ mkdir content/ |