From b970eb47d74efc4b124433709f2e17acb4e07a74 Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Thu, 7 Jun 2018 13:46:41 +0930 Subject: now generates a simple index, index template added --- generatewebpages.py | 41 +++++++++++++++++++++-------------------- index.txt | 1 + 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/generatewebpages.py b/generatewebpages.py index 4ac2b2d..60d3133 100755 --- a/generatewebpages.py +++ b/generatewebpages.py @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import argparse; import sqlite3; import os; +import re; from os import fdopen, remove; from shutil import copyfile; from tempfile import mkstemp; @@ -42,13 +43,13 @@ class Anime: def __init__(self, animeobj): self.dbpos = animeobj[0]; self.animeid = animeobj[1]; - self.title = animeobj[2]; + self.title = animeobj[2].replace("\"", """); self.episodes = animeobj[3]; self.type = animeobj[4]; self.watched = animeobj[5]; self.score = animeobj[6]; self.status = animeobj[7]; - self.notes = animeobj[8]; + self.notes = str(animeobj[8]).replace("\"", """); self.output = ""; # our final html string def setstatuscolor(self, status): @@ -92,7 +93,7 @@ def replacestringinfile(file_path, string, substr): with fdopen(fh, "w") as new_file: with open(file_path) as old_file: for line in old_file: - new_file.write(str(line.replace(string, substr).encode("utf-8"))); + new_file.write(line.replace(string, substr)); remove(file_path); move(abs_path, file_path); @@ -101,33 +102,33 @@ def replacestring(string, substr, replacement): def insertanimedata(anime): tmp = animetemplate; - tmp = replacestring(tmp, "{ANIME_UNDERLINED_TITLE}", anime.title.replace(" ", "_")); + tmp = replacestring(tmp, "{ANIME_UNDERLINED_TITLE}", re.sub(r'[^\x00-\x7f]',r'', anime.title.replace(" ", "_"))); tmp = replacestring(tmp, "{ANIME_ID}", str(anime.animeid)); - tmp = replacestring(tmp, "{ANIME_TITLE}", anime.title); + tmp = replacestring(tmp, "{ANIME_TITLE}", re.sub(r'[^\x00-\x7f]',r'', anime.title)); tmp = replacestring(tmp, "{TOTAL_EPISODES}", str(anime.episodes)); tmp = replacestring(tmp, "{EPISODES_WATCHED}", str(anime.watched)); tmp = replacestring(tmp, "{WATCH_STATUS_COLOR}", anime.statuscolor); tmp = replacestring(tmp, "{WATCH_STATUS}", anime.status); tmp = replacestring(tmp, "{RATING}", str(anime.score)); - tmp = replacestring(tmp, "{NOTES}", str(anime.notes)); + tmp = replacestring(tmp, "{NOTES}", re.sub(r'[^\x00-\x7f]',r'', str(anime.notes))); anime.output = tmp; # this template is used for every anime we display animetemplate = ( - "
" - "
" - "
" - "\"{ANIME_TITLE}" - "
" - "{ANIME_TITLE}
" - "{TOTAL_EPISODES} episodes ({EPISODES_WATCHED} watched)
" - "status: {WATCH_STATUS}
" - "rating: {RATING}/10
" - "notes: {NOTES}
" - "
" - "
" - "
" - "
"); + "
\n" + "
\n" + "
\n" + "\"{ANIME_TITLE}\n" + "
\n" + "{ANIME_TITLE}
\n" + "{TOTAL_EPISODES} episodes ({EPISODES_WATCHED} watched)
\n" + "status: {WATCH_STATUS}
\n" + "rating: {RATING}/10
\n" + "notes: {NOTES}
\n" + "
\n" + "
\n" + "
\n" + "
\n"); if __name__ == "__main__": """ diff --git a/index.txt b/index.txt index 3fd02d7..07f8f37 100644 --- a/index.txt +++ b/index.txt @@ -36,6 +36,7 @@ body { margin: 5px; float: left; + width: 25%; overflow: hidden; } -- cgit v1.2.3