summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel-Jones <daniel@danieljon.es>2017-12-10 16:13:09 +1030
committerdaniel-Jones <daniel@danieljon.es>2017-12-10 16:13:09 +1030
commit746b166704068d2be7762a9c2885f08dae18a891 (patch)
treeb0702f5ce488953c3ff922fec9e0b0affcfaad20
parent68eb05f5c0df68e754e5eeeb154c445bf687368c (diff)
downloadwebsite-746b166704068d2be7762a9c2885f08dae18a891.tar.gz
website-746b166704068d2be7762a9c2885f08dae18a891.zip
added direct blog link to posts
-rw-r--r--generatesite.py22
-rw-r--r--settings.cfg2
-rwxr-xr-xsetup.sh1
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
diff --git a/setup.sh b/setup.sh
index 06d464f..f74555b 100755
--- a/setup.sh
+++ b/setup.sh
@@ -1,6 +1,7 @@
# directories
mkdir output/
mkdir output/blog/
+mkdir output/blog/direct
mkdir output/viewings/
mkdir output/waifus/
mkdir content/