Compare commits
11 Commits
f65361e06b
...
master
Author | SHA1 | Date | |
---|---|---|---|
eff22ff325 | |||
6ab90d5fff | |||
d98354046b | |||
f1ae73b737 | |||
d062ca6787 | |||
a9adf51453 | |||
7157757d43 | |||
5859ee0408 | |||
b33ea016d5 | |||
ab29250b74 | |||
167a03be3c |
@@ -24,14 +24,16 @@ DEX_TYPES = [
|
||||
"MDIGlitchDex", "MetascriptDex", "TMHMDex", "StatDex", "PosterDex", "TypeDex", "UnownDex", "DollDex", "DefaultNameDex",
|
||||
"BattleTypeDe", "BadgeDescriptionDex", "FacingDex"
|
||||
]
|
||||
DEXES = list(chain.from_iterable([[f"{dex_type}{language}" for dex_type in DEX_TYPES] for language in DEX_LANGUAGES]))
|
||||
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,10 +41,15 @@ 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:
|
||||
if page_title.startswith(f"{name}/"):
|
||||
if page_title.startswith("{}/".format(name)):
|
||||
directory_name = name
|
||||
page_title = page_title[len(directory_name) + 1:]
|
||||
break
|
||||
@@ -50,7 +57,14 @@ class ArchiveLinker(Linker):
|
||||
for key, value in self.replacements.items():
|
||||
page_title = page_title.replace(key, value)
|
||||
|
||||
return f"{directory_name}{'/' if directory_name else ''}{page_title}.html"
|
||||
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)
|
||||
@@ -109,7 +123,7 @@ class ArchiveGenerator():
|
||||
if page.redirect:
|
||||
logger.info("Archiving redirect page (%s -> %s) to %s", page.title, page.redirect, page_out)
|
||||
renderer.render_template_to_file("redirect", page_out, {
|
||||
"target": f"{base}{linker.translate_page_title(page.redirect)}"
|
||||
"target": "{}{}".format(base, linker.translate_page_title(page.redirect))
|
||||
})
|
||||
else:
|
||||
logger.info("Archiving page %s to %s", page.title, page_out)
|
||||
@@ -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
|
||||
@@ -137,12 +152,13 @@ class ArchiveGenerator():
|
||||
raise e
|
||||
|
||||
for category, pages in categories.items():
|
||||
category_out = f"Category:{linker.translate_page_title(category)}"
|
||||
category_out = "Category:{}".format(linker.translate_page_title(category))
|
||||
logger.info("Archiving category %s to %s", category, category_out)
|
||||
|
||||
try:
|
||||
renderer.render_template_to_file("category", category_out, {
|
||||
"title": f" - {category}",
|
||||
"title": " - {}".format(category),
|
||||
"pagename": "Category:{}".format(category),
|
||||
"category": category,
|
||||
"pages": pages
|
||||
})
|
||||
@@ -202,7 +218,7 @@ class ArchiveGenerator():
|
||||
})
|
||||
|
||||
total_pages = math.ceil((thread.num_replies + 1) / DEFAULT_POSTS_PER_PAGE)
|
||||
page_links = [{"label": page + 1, "link": f"page-{page}.html"} for page in range(total_pages)]
|
||||
page_links = [{"label": page + 1, "link": "page-{}.html".format(page)} for page in range(total_pages)]
|
||||
page = 0
|
||||
while True:
|
||||
posts = [prepare_post(post) for post in forum.get_posts_in_thread(thread, page)]
|
||||
|
@@ -9,8 +9,8 @@ from flask import Flask, redirect, request
|
||||
app = Flask(__name__)
|
||||
|
||||
DEFAULT_ARCHIVES_DOMAIN = "https://archives.glitchcity.info/"
|
||||
DEFAULT_FORUMS_ARCHIVE = f"{DEFAULT_ARCHIVES_DOMAIN}forums"
|
||||
DEFAULT_WIKI_ARCHIVE = f"{DEFAULT_ARCHIVES_DOMAIN}wiki"
|
||||
DEFAULT_FORUMS_ARCHIVE = "{}forums".format(DEFAULT_ARCHIVES_DOMAIN)
|
||||
DEFAULT_WIKI_ARCHIVE = "{}wiki".format(DEFAULT_ARCHIVES_DOMAIN)
|
||||
|
||||
## Wiki redirector
|
||||
@app.route("/wiki/")
|
||||
@@ -42,6 +42,8 @@ def make_forum_url (request):
|
||||
post_id = None
|
||||
|
||||
if thread_id:
|
||||
thread_id = strip_extension(thread_id)
|
||||
|
||||
if "." in thread_id:
|
||||
(thread_id, post_id) = thread_id.split(".")
|
||||
post_id = post_id[len("msg"):]
|
||||
@@ -57,18 +59,24 @@ def make_forum_url (request):
|
||||
url = app.args.forums_archive
|
||||
|
||||
if board_id:
|
||||
url = url + f"board-{board_id}"
|
||||
url = url + "board-{}".format(board_id)
|
||||
|
||||
if thread_id:
|
||||
url = url + f"/thread-{thread_id}"
|
||||
url = url + "/thread-{}".format(thread_id)
|
||||
|
||||
if not url.endswith("/"):
|
||||
url = url + "/"
|
||||
|
||||
return url
|
||||
|
||||
def strip_extension (item):
|
||||
for extension in [".html"]:
|
||||
if item.endswith(extension):
|
||||
item = item[:-len(extension)]
|
||||
return item
|
||||
|
||||
def read_thread_index (forums_archive):
|
||||
with urllib.request.urlopen(f"{forums_archive}{FORUM_THREAD_INDEX}") as gzipped_in:
|
||||
with urllib.request.urlopen("{}{}".format(forums_archive, FORUM_THREAD_INDEX)) as gzipped_in:
|
||||
data = gzipped_in.read()
|
||||
return json.loads(gzip.decompress(data).decode())
|
||||
|
||||
|
@@ -32,7 +32,7 @@ INTERWIKI_NAMESPACES = {
|
||||
|
||||
FILE_NAMESPACES = ["File:", "Image:"]
|
||||
CATEGORY_NAMESPACE = "Category:"
|
||||
CATEGORY_LINK_NAMESPACE = f":{CATEGORY_NAMESPACE}"
|
||||
CATEGORY_LINK_NAMESPACE = ":{}".format(CATEGORY_NAMESPACE)
|
||||
|
||||
class Wiki():
|
||||
def __init__ (self, xml_path):
|
||||
@@ -152,7 +152,7 @@ def render (wikitext, base="", linker=None):
|
||||
else:
|
||||
url = linker.translate_interwiki_title(node.title)
|
||||
if not url:
|
||||
url = f"{base}{linker.translate_page_title(node.title)}"
|
||||
url = "{}{}".format(base, linker.translate_page_title(node.title))
|
||||
|
||||
rendered.append('<a href="{}">{}</a>'.format(
|
||||
url,
|
||||
@@ -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
|
||||
))
|
||||
@@ -205,7 +206,7 @@ def reformat_page_title (page_title):
|
||||
if not page_title:
|
||||
return ""
|
||||
|
||||
return f"{page_title[0].upper()}{page_title[1:].replace(' ', '_')}"
|
||||
return "{}{}".format(page_title[0].upper(), page_title[1:].replace(' ', '_'))
|
||||
|
||||
class Template():
|
||||
def __init__ (self, wikicode):
|
||||
|
@@ -77,7 +77,7 @@ DO_NOT_ARCHIVE_CATEGORIES = [
|
||||
# Boards we are not interested in archiving.
|
||||
# `id_board` in (1, 2)
|
||||
DO_NOT_ARCHIVE_BOARDS = [
|
||||
24, 94, 118, 121 # Links
|
||||
24, 94, 118, 121, # Links
|
||||
40, # Exclusive Board
|
||||
65, # Requests for Moderatorship
|
||||
66, # Requests for Membership+
|
||||
@@ -87,7 +87,7 @@ DO_NOT_ARCHIVE_BOARDS = [
|
||||
89, # Test Board
|
||||
86, # Omega Archives
|
||||
51, 37, 79, 26, 47, 44, 45, 99, 93, 119, 96,
|
||||
62, # Submit-A-Glitch Archives
|
||||
62, 60, 80, 84, # Submit-A-Glitch Archives
|
||||
3, 4, 5, 57, 58, 59, 38, 54, 63, 64,
|
||||
68, 69, 70, 81, 82, 83,
|
||||
28, # The Dumpster Out Back
|
||||
|
@@ -1,4 +1,5 @@
|
||||
{{>header}}
|
||||
{{>forums_notice}}
|
||||
{{#categories}}
|
||||
<h2 class="category-name">{{name}}</h2>
|
||||
{{>child_boards}}
|
||||
|
9
templates/category.mustache
Normal file
9
templates/category.mustache
Normal file
@@ -0,0 +1,9 @@
|
||||
{{>header}}
|
||||
{{>wiki_notice}}
|
||||
<h2>{{pagename}}</h2>
|
||||
<ul>
|
||||
{{#pages}}
|
||||
<li><a href="{{url}}">{{title}}</a></li>
|
||||
{{/pages}}
|
||||
</ul>
|
||||
{{>footer}}
|
@@ -1,5 +1,8 @@
|
||||
{{>header}}
|
||||
Welcome to the <b>Glitch City Laboratories Archives</b>.
|
||||
<p>Glitch City Laboratories was a Poké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 <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>
|
||||
|
@@ -1,4 +1,5 @@
|
||||
{{>header}}
|
||||
{{>wiki_notice}}
|
||||
<h2>{{page.title}}</h2>
|
||||
<article class="page">
|
||||
{{{text}}}
|
||||
|
5
templates/partials/forums_notice.mustache
Normal file
5
templates/partials/forums_notice.mustache
Normal file
@@ -0,0 +1,5 @@
|
||||
<div class="notice">
|
||||
<p>Glitch City Laboratories closed on 1 September 2020 (<a href="{{base}}board-2/thread-9114/page-0.html">announcement</a>). This is an <b>archived</b> copy of a thread from Glitch City Laboratories Forums.</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 this forum in <a href="{{base}}../forums.tar.gz">.tar.gz</a>, <a href="{{base}}../forums.sql.gz">.sql.gz</a>, or <a href="{{base}}../forums.sqlite.gz">.sqlite.gz</a> formats.</p>
|
||||
</div>
|
6
templates/partials/wiki_notice.mustache
Normal file
6
templates/partials/wiki_notice.mustache
Normal file
@@ -0,0 +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>
|
@@ -1,4 +1,5 @@
|
||||
{{>header}}
|
||||
{{>forums_notice}}
|
||||
<h2><a href="../">{{board.name}}</a></h2>
|
||||
<h3>{{thread.subject}} - Page {{next}}</h3>
|
||||
{{>pagination}}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
{{>header}}
|
||||
{{>forums_notice}}
|
||||
<h2>{{board.name}}</h2>
|
||||
<table id="threads">
|
||||
<tr>
|
||||
|
Reference in New Issue
Block a user