Compare commits

..

6 Commits

5 changed files with 28 additions and 9 deletions

View File

@@ -27,11 +27,13 @@ DEX_TYPES = [
DEXES = list(chain.from_iterable([["{}{}".format(dex_type, language) for dex_type in DEX_TYPES] for language in DEX_LANGUAGES]))
FORUM_THREAD_INDEX = "thread_index.json.gz"
IMAGE_DIRECTORY = "images"
class ArchiveLinker(Linker):
def __init__ (self, directory_names=[]):
super().__init__()
self.directory_names = directory_names
self.image_directory = IMAGE_DIRECTORY
self.replacements = {
"/": "+",
#":": ""
@@ -39,6 +41,11 @@ class ArchiveLinker(Linker):
def translate_page_title (self, page_title):
page_title = super().translate_page_title(page_title)
fragment = ""
if "#" in page_title:
fragment = page_title[page_title.find("#"):]
page_title = page_title[:-len(fragment)]
directory_name = ""
for name in self.directory_names:
@@ -50,7 +57,14 @@ class ArchiveLinker(Linker):
for key, value in self.replacements.items():
page_title = page_title.replace(key, value)
return "{}{}{}.html".format(directory_name, '/' if directory_name else '', page_title)
return "{}{}{}.html{}".format(directory_name, '/' if directory_name else '', page_title, fragment)
def translate_image_title (self, page_title):
image_title = super().translate_image_title(page_title)
if not image_title:
return
return "{}/{}".format(self.image_directory, image_title)
def prepare_thread (thread):
thread.subject = html.unescape(thread.subject)
@@ -126,6 +140,7 @@ class ArchiveGenerator():
renderer.render_template_to_file("page", page_out, {
"title": " - {}".format(page.title),
"pagename": page.title,
"page": page,
"base": base,
"text": rendered
@@ -143,6 +158,7 @@ class ArchiveGenerator():
try:
renderer.render_template_to_file("category", category_out, {
"title": " - {}".format(category),
"pagename": "Category:{}".format(category),
"category": category,
"pages": pages
})

View File

@@ -170,8 +170,9 @@ def render (wikitext, base="", linker=None):
render(node.tag)
))
elif node_type is Heading:
rendered.append("<h{}>{}</h{}>".format(
rendered.append('<h{} id="{}">{}</h{}>'.format(
node.level,
reformat_page_title(node.title),
render(node.title, base, linker),
node.level
))

View File

@@ -1,6 +1,6 @@
{{>header}}
{{>wiki_notice}}
<h2>{{title}}</h2>
<h2>{{pagename}}</h2>
<ul>
{{#pages}}
<li><a href="{{url}}">{{title}}</a></li>

View File

@@ -1,7 +1,8 @@
{{>header}}
Welcome to the <b>Glitch City Laboratories Archives</b>.
<p>Glitch City Laboratories was a Pok&eacute;mon glitch website that existed from March 2006 to September 2020 (<a href="forums/board-2/thread-9114/page-0.html">announcement of closure</a>). This is an <b>archive</b> of content from the website prior to its closure.</p>
<p>Further development and discussion is happening at <a href="https://discord.com/invite/EA7jxJ6">Glitch City Research Institute</a>, the successor community.</p>
<p>Further development and discussion is happening at <b><a href="https://discord.com/invite/EA7jxJ6">Glitch City Research Institute</a></b>, the successor community.</p>
<p>The <b><a href="https://glitchcity.wiki/">Glitch City Wiki</a></b> is the continuation of the Glitch City Laboratories wiki.</p>
<h2>Archives</h2>
<ul>
<li><a href="forums">Forums</a> (<a href="forums.tar.gz">.tar.gz</a>) (<a href="forums.sql.gz">.sql.gz</a>) (<a href="forums.sqlite.gz">.sqlite.gz</a>)</li>

View File

@@ -1,5 +1,6 @@
<div class="notice">
<p>Glitch City Laboratories closed on 1 September 2020 (<a href="{{base}}../forums/board-2/thread-9114/page-0.html">announcement</a>). This is an <b>archived</b> copy of an article from Glitch City Laboratories wiki.</p>
<p><b>A live version of this article is available at the <a href="https://glitchcity.wiki/">Glitch City Wiki</a> <a href="https://glitchcity.wiki/{{pagename}}">here</a>.</b></p>
<p>You can join <a href="https://discord.com/invite/EA7jxJ6">Glitch City Research Institute</a> to ask questions or discuss current developments.</p>
<p>You may also download the archive of the wiki in <a href="{{base}}../wiki.tar.gz">.tar.gz</a> or <a href="{{base}}../wiki.xml.gz">.xml.gz</a> formats.</p>
</div>