summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel-Jones <daniel@danieljon.es>2017-11-09 11:51:50 +1100
committerdaniel-Jones <daniel@danieljon.es>2017-11-09 11:51:50 +1100
commit3bb5c367adfeefa056735c61ae2bccfc99d5172d (patch)
tree5f46f52fb0dab73f75c3a88ba5a1ca2ec84b4a48
parent81a41ed68c6be179ff60a953be360ec82ddd9a86 (diff)
downloadwebsite-3bb5c367adfeefa056735c61ae2bccfc99d5172d.tar.gz
website-3bb5c367adfeefa056735c61ae2bccfc99d5172d.zip
added anime recommendations to generator
-rw-r--r--generatesite.py69
-rw-r--r--settings.cfg13
-rw-r--r--template.txt11
3 files changed, 25 insertions, 68 deletions
diff --git a/generatesite.py b/generatesite.py
index e923851..980b428 100644
--- a/generatesite.py
+++ b/generatesite.py
@@ -132,63 +132,20 @@ def generateblog():
print(t.read());
'''
-def generateshows():
- cpage = 0;
+def generateanime():
template = cfg.get("output", "template");
outdir = cfg.get("output", "dir");
- blogdir = cfg.get("shows", "dir");
- blogsrc = cfg.get("shows", "srcdir");
- perpage = cfg.get("shows", "perpage");
- print("generating {}/{}/ from directory /{}/final".format(outdir, blogdir, blogsrc));
- os.makedirs(outdir + "/" + blogdir, exist_ok=True);
- os.makedirs(blogsrc + "/final", exist_ok=True);
- # number of blog posts
- postcount = len(glob.glob1(blogsrc, "*.txt"));
- pagecount = postcount/int(perpage)+1;
- print("{} posts, {} per page = {} pages".format(postcount, perpage, int(pagecount)));
- folder = outdir + "/" + blogdir;
- # delete generated blog files
- deletefiles(outdir + "/" + blogdir);
- # delete renamed blog files
- deletefiles(blogsrc + "/final");
- '''
- copy our blog posts to blogsrc/final, rename them, 60 becomes 1, 59 becomes 2 etc
- this is done because I am extremely lazy and had troubles doing it any other way.
- sorry if you're reading this.
- '''
- #integrate this with the loop below it?
- count = 1;
- for x in range(int(postcount), 0, -1):
- copyfile(blogsrc + "/" + str(x) + ".txt", blogsrc + "/final/" + str(count) + ".txt");
- count += 1;
- # generate pages
- for x in range(1, int(pagecount) + 1):
- copyfile(template, outdir + "/" + blogdir + "/" + str(x) + ".html");
- with open(outdir + "/" + blogdir + "/" + str(x) + ".html", "r") as contentfile:
- content = contentfile.read().replace('\n', '');
- replace(outdir + "/" + blogdir + "/" + str(x) + ".html", "{TITLE}", cfg.get("blog", "title"));
- replace(outdir + "/" + blogdir + "/" + str(x) + ".html", "{INFO}", "Blog");
- replace(outdir + "/" + blogdir + "/" + str(x) + ".html", "{TIME}", strftime("%Y-%m-%d %H:%M:%S", gmtime()));
- # place blog posts into their pages
- count = 1;
- cpage = 1;
- page = "";
- total_count = postcount;
- # count from 1 - perpage, add perpage to count, count from count - count + perpage
- while count < postcount + 1:
- for x in range(count, count + int(perpage)):
- if count < postcount + 1:
- with open(blogsrc + "/final/" + str(x) + ".txt") as contentfile:
- content = contentfile.read();
- page += "#" + str(total_count) + content + "<hr>";
- count += 1;
- total_count -= 1;
- if cpage <= pagecount:
- page += generatepagebar(str(cpage), str(int(pagecount)));
- page = generatepagebar(str(cpage), str(int(pagecount))) + page;
- replace(outdir + "/" + blogdir + "/" + str(cpage) + ".html", "{CONTENT}", page);
- page = "";
- cpage += 1;
+ animesrc = cfg.get("anime", "src");
+ animedir = cfg.get("anime", "dir");
+ print("generating {}/index.html from {}".format(outdir, animesrc));
+ copyfile(template, outdir + "/" + animedir + "/index.html");
+ with open(animesrc, "r") as contentfile:
+ content = contentfile.read();
+ replace(outdir + "/" + animedir + "/index.html", "{TITLE}", cfg.get("anime", "title"));
+ replace(outdir + "/" + animedir + "/index.html", "{INFO}", cfg.get("anime", "header"));
+ replace(outdir + "/" + animedir + "/index.html", "{CONTENT}", content);
+ replace(outdir + "/" + animedir + "/index.html", "{TIME}", strftime("%Y-%m-%d %H:%M:%S", gmtime()));
+
if __name__ == "__main__":
cfg = configparser.ConfigParser();
@@ -197,4 +154,4 @@ if __name__ == "__main__":
generateindex();
generateblog();
generateportfolio();
- #generateshows();
+ generateanime();
diff --git a/settings.cfg b/settings.cfg
index e2e7ece..b433d7d 100644
--- a/settings.cfg
+++ b/settings.cfg
@@ -17,11 +17,8 @@ dir = blog
srcdir = content/blog
# number of posts per page
perpage = 7
-[shows]
-title = viewings
-header = <h1>Shows I have watched</h1>
-# shows directory
-dir = shows
-srcdir = content/shows
-# number of posts per page
-perpage = 5
+[anime]
+title = anime
+header = <h1>Anime I recommend</h1>
+dir = viewings
+src = content/viewings/index.txt
diff --git a/template.txt b/template.txt
index b9fdfd0..0d4cdce 100644
--- a/template.txt
+++ b/template.txt
@@ -10,14 +10,17 @@
<link rel="icon" type="image/png" href="https://danieljon.es/favicon.png">
<title>{TITLE}</title>
<style type="text/css">
-body{/*background-color:#222; color: #eee;*/ margin-right: 20px; margin-left: 20px;}
-/*div{background-color: #202020 !important;}*/
+body{/*background-color:#222; color: #eee;*/ margin-right: 20px; margin-left: 20px; font-family: Verdana}
+/*div{background-color: #1a1a1a;}*/
/*a:link{color: #3F51B5;}*/
/*a:visited{#3F51B5;}*/
-img{max-width: 100%; max-height: 100%; overflow: hidden;}
+img{max-width: 100%; max-height: 100%; overflow: hidden;}
.middle{text-align: center;}
+.middiv{margin: auto; width: 80%;}
#gentag{text-align: center; font-size: 75%;}
-/*h1,h2,h3,h4 {background-color: black !important; color: #e02020 !important;}*/
+h1,h2,h3,h4{padding-left: 5px; /*background-color: black !important; color: #e02020*/ !important;}
+div.viewing{max-width: 70%; width: 100%; display: inline-block; margin: 10px;}
+div.cover{display:inline-block; vertical-align: top; padding-top: 28px; padding-left: 15px; padding-bottom: 20px;}
</style>
</head>