Add archives index page, and deploy wiki archives.
This commit is contained in:
parent
6f05f05410
commit
0b1320a9da
@ -3,6 +3,16 @@ HOSTNAME=glitchcity.info
|
|||||||
ARCHIVE_PATH=/var/www/html/gclarchives
|
ARCHIVE_PATH=/var/www/html/gclarchives
|
||||||
|
|
||||||
cd archives
|
cd archives
|
||||||
tar -cf forums.tar forums && gzip -f forums.tar
|
scp index.html style.css $HOSTNAME:$ARCHIVE_PATH
|
||||||
scp forums.tar.gz $HOSTNAME:$ARCHIVE_PATH
|
|
||||||
ssh $HOSTNAME "cd $ARCHIVE_PATH; tar -xf forums.tar.gz"
|
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;
|
@ -11,6 +11,8 @@ WIKI_DIRECTORY = os.path.join(BASEDIR, "wiki")
|
|||||||
TEMPLATES_DIR = os.path.join(BASEDIR, "templates")
|
TEMPLATES_DIR = os.path.join(BASEDIR, "templates")
|
||||||
STATIC_DIR = os.path.join(BASEDIR, "static")
|
STATIC_DIR = os.path.join(BASEDIR, "static")
|
||||||
|
|
||||||
|
ARCHIVE_GENERATOR = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR)
|
||||||
|
|
||||||
ARCHIVES_BASEDIR = "archives"
|
ARCHIVES_BASEDIR = "archives"
|
||||||
FORUM_ARCHIVES = os.path.join(ARCHIVES_BASEDIR, "forums")
|
FORUM_ARCHIVES = os.path.join(ARCHIVES_BASEDIR, "forums")
|
||||||
WIKI_ARCHIVES = os.path.join(ARCHIVES_BASEDIR, "wiki")
|
WIKI_ARCHIVES = os.path.join(ARCHIVES_BASEDIR, "wiki")
|
||||||
@ -22,18 +24,14 @@ def main():
|
|||||||
if not args:
|
if not args:
|
||||||
args = DEFAULT_ARGUMENTS
|
args = DEFAULT_ARGUMENTS
|
||||||
|
|
||||||
|
ARCHIVE_GENERATOR.generate_index(ARCHIVES_BASEDIR)
|
||||||
|
|
||||||
if "forum" in args or "forums" in args:
|
if "forum" in args or "forums" in args:
|
||||||
archive_forum()
|
ARCHIVE_GENERATOR.generate_forum(Forum(FORUM_DATABASE), FORUM_ARCHIVES)
|
||||||
|
|
||||||
if "wiki" in args:
|
if "wiki" in args:
|
||||||
archive_wiki()
|
archive_wiki()
|
||||||
|
|
||||||
def archive_forum():
|
|
||||||
forum = Forum(FORUM_DATABASE)
|
|
||||||
|
|
||||||
generator = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR)
|
|
||||||
generator.generate_forum(forum, FORUM_ARCHIVES)
|
|
||||||
|
|
||||||
def archive_wiki():
|
def archive_wiki():
|
||||||
wiki = None
|
wiki = None
|
||||||
for entry in os.listdir(WIKI_DIRECTORY):
|
for entry in os.listdir(WIKI_DIRECTORY):
|
||||||
@ -41,5 +39,4 @@ def archive_wiki():
|
|||||||
wiki = Wiki(os.path.join(WIKI_DIRECTORY, entry))
|
wiki = Wiki(os.path.join(WIKI_DIRECTORY, entry))
|
||||||
|
|
||||||
if wiki:
|
if wiki:
|
||||||
generator = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR)
|
ARCHIVE_GENERATOR.generate_wiki(wiki, WIKI_ARCHIVES)
|
||||||
generator.generate_wiki(wiki, WIKI_ARCHIVES)
|
|
@ -27,6 +27,16 @@ class ArchiveGenerator():
|
|||||||
self.template_dir = template_dir
|
self.template_dir = template_dir
|
||||||
self.static_dir = static_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):
|
def generate_wiki (self, wiki, out_dir):
|
||||||
logger.info("Archiving wiki to %s", out_dir)
|
logger.info("Archiving wiki to %s", out_dir)
|
||||||
try:
|
try:
|
||||||
@ -35,6 +45,9 @@ class ArchiveGenerator():
|
|||||||
|
|
||||||
shutil.copyfile(os.path.join(self.static_dir, "style.css"), os.path.join(out_dir, "style.css"))
|
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 = TemplateRenderer(self.template_dir, out_dir)
|
||||||
|
renderer.render_template_to_file("redirect", "index.html", {
|
||||||
|
"target": "Main_Page.html"
|
||||||
|
})
|
||||||
|
|
||||||
for page in wiki.get_pages():
|
for page in wiki.get_pages():
|
||||||
if page.redirect:
|
if page.redirect:
|
||||||
@ -101,7 +114,9 @@ class ArchiveGenerator():
|
|||||||
except FileExistsError: pass
|
except FileExistsError: pass
|
||||||
|
|
||||||
renderer = TemplateRenderer(self.template_dir, thread_out_dir)
|
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
|
page = 0
|
||||||
while True:
|
while True:
|
||||||
|
8
templates/index.mustache
Normal file
8
templates/index.mustache
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{{>header}}
|
||||||
|
Welcome to the <b>Glitch City Laboratories Archives</b>.
|
||||||
|
<h2>Archives</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="forums">Forums</a> (<a href="forums.tar.gz">.tar.gz</a>)</li>
|
||||||
|
<li><a href="wiki">Wiki</a> (<a href="wiki.tar.gz">.tar.gz</a>)</li>
|
||||||
|
</ul>
|
||||||
|
{{>footer}}
|
@ -1,4 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head><meta http-equiv="refresh" content="0; url=page-0.html" /></head>
|
|
||||||
<body><p><a href="page-0.html">Redirect</a></p></body>
|
|
||||||
</html>
|
|
4
templates/redirect.mustache
Normal file
4
templates/redirect.mustache
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<html>
|
||||||
|
<head><meta http-equiv="refresh" content="0; url={{target}}" /></head>
|
||||||
|
<body><p><a href="{{target}}">Redirect</a></p></body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user