From 0b1320a9da843c39890dfcfeefdbcae7470357b6 Mon Sep 17 00:00:00 2001 From: Adrian Malacoda Date: Sun, 16 Aug 2020 21:11:59 -0500 Subject: [PATCH] Add archives index page, and deploy wiki archives. --- deploy_archives | 16 +++++++++++++--- epilogue/__init__.py | 15 ++++++--------- epilogue/archive_generator.py | 17 ++++++++++++++++- templates/index.mustache | 8 ++++++++ templates/page-0-redirect.mustache | 4 ---- templates/redirect.mustache | 4 ++++ 6 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 templates/index.mustache delete mode 100644 templates/page-0-redirect.mustache create mode 100644 templates/redirect.mustache diff --git a/deploy_archives b/deploy_archives index 53b2e68..3e21965 100755 --- a/deploy_archives +++ b/deploy_archives @@ -3,6 +3,16 @@ HOSTNAME=glitchcity.info ARCHIVE_PATH=/var/www/html/gclarchives cd archives -tar -cf forums.tar forums && gzip -f forums.tar -scp forums.tar.gz $HOSTNAME:$ARCHIVE_PATH -ssh $HOSTNAME "cd $ARCHIVE_PATH; tar -xf forums.tar.gz" \ No newline at end of file +scp index.html style.css $HOSTNAME:$ARCHIVE_PATH + +if [ -d "forums" ]; then + tar -cf forums.tar forums && gzip -f forums.tar + scp forums.tar.gz $HOSTNAME:$ARCHIVE_PATH + ssh $HOSTNAME "cd $ARCHIVE_PATH; tar -xf forums.tar.gz" +fi; + +if [ -d "wiki" ]; then + tar -cf wiki.tar wiki && gzip -f wiki.tar + scp wiki.tar.gz $HOSTNAME:$ARCHIVE_PATH + ssh $HOSTNAME "cd $ARCHIVE_PATH; tar -xf wiki.tar.gz" +fi; \ No newline at end of file diff --git a/epilogue/__init__.py b/epilogue/__init__.py index c53bae6..7092cff 100644 --- a/epilogue/__init__.py +++ b/epilogue/__init__.py @@ -11,6 +11,8 @@ WIKI_DIRECTORY = os.path.join(BASEDIR, "wiki") TEMPLATES_DIR = os.path.join(BASEDIR, "templates") STATIC_DIR = os.path.join(BASEDIR, "static") +ARCHIVE_GENERATOR = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR) + ARCHIVES_BASEDIR = "archives" FORUM_ARCHIVES = os.path.join(ARCHIVES_BASEDIR, "forums") WIKI_ARCHIVES = os.path.join(ARCHIVES_BASEDIR, "wiki") @@ -22,18 +24,14 @@ def main(): if not args: args = DEFAULT_ARGUMENTS + ARCHIVE_GENERATOR.generate_index(ARCHIVES_BASEDIR) + if "forum" in args or "forums" in args: - archive_forum() + ARCHIVE_GENERATOR.generate_forum(Forum(FORUM_DATABASE), FORUM_ARCHIVES) if "wiki" in args: archive_wiki() -def archive_forum(): - forum = Forum(FORUM_DATABASE) - - generator = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR) - generator.generate_forum(forum, FORUM_ARCHIVES) - def archive_wiki(): wiki = None for entry in os.listdir(WIKI_DIRECTORY): @@ -41,5 +39,4 @@ def archive_wiki(): wiki = Wiki(os.path.join(WIKI_DIRECTORY, entry)) if wiki: - generator = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR) - generator.generate_wiki(wiki, WIKI_ARCHIVES) \ No newline at end of file + ARCHIVE_GENERATOR.generate_wiki(wiki, WIKI_ARCHIVES) \ No newline at end of file diff --git a/epilogue/archive_generator.py b/epilogue/archive_generator.py index 9f6a70f..5392ac4 100644 --- a/epilogue/archive_generator.py +++ b/epilogue/archive_generator.py @@ -27,6 +27,16 @@ class ArchiveGenerator(): self.template_dir = template_dir self.static_dir = static_dir + def generate_index (self, out_dir): + logger.info("Generating index page at %s", out_dir) + try: + os.makedirs(out_dir) + except FileExistsError: pass + + shutil.copyfile(os.path.join(self.static_dir, "style.css"), os.path.join(out_dir, "style.css")) + renderer = TemplateRenderer(self.template_dir, out_dir) + renderer.render_template_to_file("index", "index.html", {}) + def generate_wiki (self, wiki, out_dir): logger.info("Archiving wiki to %s", out_dir) try: @@ -35,6 +45,9 @@ class ArchiveGenerator(): shutil.copyfile(os.path.join(self.static_dir, "style.css"), os.path.join(out_dir, "style.css")) renderer = TemplateRenderer(self.template_dir, out_dir) + renderer.render_template_to_file("redirect", "index.html", { + "target": "Main_Page.html" + }) for page in wiki.get_pages(): if page.redirect: @@ -101,7 +114,9 @@ class ArchiveGenerator(): except FileExistsError: pass renderer = TemplateRenderer(self.template_dir, thread_out_dir) - renderer.render_template_to_file("page-0-redirect", "index.html") + renderer.render_template_to_file("redirect", "index.html", { + "target": "page-0.html" + }) page = 0 while True: diff --git a/templates/index.mustache b/templates/index.mustache new file mode 100644 index 0000000..8c8b922 --- /dev/null +++ b/templates/index.mustache @@ -0,0 +1,8 @@ +{{>header}} +Welcome to the Glitch City Laboratories Archives. +

Archives

+ +{{>footer}} \ No newline at end of file diff --git a/templates/page-0-redirect.mustache b/templates/page-0-redirect.mustache deleted file mode 100644 index 7b69450..0000000 --- a/templates/page-0-redirect.mustache +++ /dev/null @@ -1,4 +0,0 @@ - - -

Redirect

- \ No newline at end of file diff --git a/templates/redirect.mustache b/templates/redirect.mustache new file mode 100644 index 0000000..b7334e4 --- /dev/null +++ b/templates/redirect.mustache @@ -0,0 +1,4 @@ + + +

Redirect

+ \ No newline at end of file