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",
|
"MDIGlitchDex", "MetascriptDex", "TMHMDex", "StatDex", "PosterDex", "TypeDex", "UnownDex", "DollDex", "DefaultNameDex",
|
||||||
"BattleTypeDe", "BadgeDescriptionDex", "FacingDex"
|
"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"
|
FORUM_THREAD_INDEX = "thread_index.json.gz"
|
||||||
|
IMAGE_DIRECTORY = "images"
|
||||||
|
|
||||||
class ArchiveLinker(Linker):
|
class ArchiveLinker(Linker):
|
||||||
def __init__ (self, directory_names=[]):
|
def __init__ (self, directory_names=[]):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.directory_names = directory_names
|
self.directory_names = directory_names
|
||||||
|
self.image_directory = IMAGE_DIRECTORY
|
||||||
self.replacements = {
|
self.replacements = {
|
||||||
"/": "+",
|
"/": "+",
|
||||||
#":": ""
|
#":": ""
|
||||||
@@ -39,10 +41,15 @@ class ArchiveLinker(Linker):
|
|||||||
|
|
||||||
def translate_page_title (self, page_title):
|
def translate_page_title (self, page_title):
|
||||||
page_title = super().translate_page_title(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 = ""
|
directory_name = ""
|
||||||
for name in self.directory_names:
|
for name in self.directory_names:
|
||||||
if page_title.startswith(f"{name}/"):
|
if page_title.startswith("{}/".format(name)):
|
||||||
directory_name = name
|
directory_name = name
|
||||||
page_title = page_title[len(directory_name) + 1:]
|
page_title = page_title[len(directory_name) + 1:]
|
||||||
break
|
break
|
||||||
@@ -50,7 +57,14 @@ class ArchiveLinker(Linker):
|
|||||||
for key, value in self.replacements.items():
|
for key, value in self.replacements.items():
|
||||||
page_title = page_title.replace(key, value)
|
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):
|
def prepare_thread (thread):
|
||||||
thread.subject = html.unescape(thread.subject)
|
thread.subject = html.unescape(thread.subject)
|
||||||
@@ -109,7 +123,7 @@ class ArchiveGenerator():
|
|||||||
if page.redirect:
|
if page.redirect:
|
||||||
logger.info("Archiving redirect page (%s -> %s) to %s", page.title, page.redirect, page_out)
|
logger.info("Archiving redirect page (%s -> %s) to %s", page.title, page.redirect, page_out)
|
||||||
renderer.render_template_to_file("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:
|
else:
|
||||||
logger.info("Archiving page %s to %s", page.title, page_out)
|
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, {
|
renderer.render_template_to_file("page", page_out, {
|
||||||
"title": " - {}".format(page.title),
|
"title": " - {}".format(page.title),
|
||||||
|
"pagename": page.title,
|
||||||
"page": page,
|
"page": page,
|
||||||
"base": base,
|
"base": base,
|
||||||
"text": rendered
|
"text": rendered
|
||||||
@@ -137,12 +152,13 @@ class ArchiveGenerator():
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
for category, pages in categories.items():
|
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)
|
logger.info("Archiving category %s to %s", category, category_out)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
renderer.render_template_to_file("category", category_out, {
|
renderer.render_template_to_file("category", category_out, {
|
||||||
"title": f" - {category}",
|
"title": " - {}".format(category),
|
||||||
|
"pagename": "Category:{}".format(category),
|
||||||
"category": category,
|
"category": category,
|
||||||
"pages": pages
|
"pages": pages
|
||||||
})
|
})
|
||||||
@@ -202,7 +218,7 @@ class ArchiveGenerator():
|
|||||||
})
|
})
|
||||||
|
|
||||||
total_pages = math.ceil((thread.num_replies + 1) / DEFAULT_POSTS_PER_PAGE)
|
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
|
page = 0
|
||||||
while True:
|
while True:
|
||||||
posts = [prepare_post(post) for post in forum.get_posts_in_thread(thread, page)]
|
posts = [prepare_post(post) for post in forum.get_posts_in_thread(thread, page)]
|
||||||
@@ -243,4 +259,4 @@ class TemplateRenderer():
|
|||||||
def render_template_to_file (self, template_name, out_file, data={}):
|
def render_template_to_file (self, template_name, out_file, data={}):
|
||||||
with self.open_template(template_name) as template:
|
with self.open_template(template_name) as template:
|
||||||
with open(os.path.join(self.out_dir, out_file), "w") as out:
|
with open(os.path.join(self.out_dir, out_file), "w") as out:
|
||||||
out.write(chevron.render(template, data, self.partials_dir, self.extension))
|
out.write(chevron.render(template, data, self.partials_dir, self.extension))
|
||||||
|
@@ -9,8 +9,8 @@ from flask import Flask, redirect, request
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
DEFAULT_ARCHIVES_DOMAIN = "https://archives.glitchcity.info/"
|
DEFAULT_ARCHIVES_DOMAIN = "https://archives.glitchcity.info/"
|
||||||
DEFAULT_FORUMS_ARCHIVE = f"{DEFAULT_ARCHIVES_DOMAIN}forums"
|
DEFAULT_FORUMS_ARCHIVE = "{}forums".format(DEFAULT_ARCHIVES_DOMAIN)
|
||||||
DEFAULT_WIKI_ARCHIVE = f"{DEFAULT_ARCHIVES_DOMAIN}wiki"
|
DEFAULT_WIKI_ARCHIVE = "{}wiki".format(DEFAULT_ARCHIVES_DOMAIN)
|
||||||
|
|
||||||
## Wiki redirector
|
## Wiki redirector
|
||||||
@app.route("/wiki/")
|
@app.route("/wiki/")
|
||||||
@@ -42,6 +42,8 @@ def make_forum_url (request):
|
|||||||
post_id = None
|
post_id = None
|
||||||
|
|
||||||
if thread_id:
|
if thread_id:
|
||||||
|
thread_id = strip_extension(thread_id)
|
||||||
|
|
||||||
if "." in thread_id:
|
if "." in thread_id:
|
||||||
(thread_id, post_id) = thread_id.split(".")
|
(thread_id, post_id) = thread_id.split(".")
|
||||||
post_id = post_id[len("msg"):]
|
post_id = post_id[len("msg"):]
|
||||||
@@ -57,18 +59,24 @@ def make_forum_url (request):
|
|||||||
url = app.args.forums_archive
|
url = app.args.forums_archive
|
||||||
|
|
||||||
if board_id:
|
if board_id:
|
||||||
url = url + f"board-{board_id}"
|
url = url + "board-{}".format(board_id)
|
||||||
|
|
||||||
if thread_id:
|
if thread_id:
|
||||||
url = url + f"/thread-{thread_id}"
|
url = url + "/thread-{}".format(thread_id)
|
||||||
|
|
||||||
if not url.endswith("/"):
|
if not url.endswith("/"):
|
||||||
url = url + "/"
|
url = url + "/"
|
||||||
|
|
||||||
return 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):
|
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()
|
data = gzipped_in.read()
|
||||||
return json.loads(gzip.decompress(data).decode())
|
return json.loads(gzip.decompress(data).decode())
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ INTERWIKI_NAMESPACES = {
|
|||||||
|
|
||||||
FILE_NAMESPACES = ["File:", "Image:"]
|
FILE_NAMESPACES = ["File:", "Image:"]
|
||||||
CATEGORY_NAMESPACE = "Category:"
|
CATEGORY_NAMESPACE = "Category:"
|
||||||
CATEGORY_LINK_NAMESPACE = f":{CATEGORY_NAMESPACE}"
|
CATEGORY_LINK_NAMESPACE = ":{}".format(CATEGORY_NAMESPACE)
|
||||||
|
|
||||||
class Wiki():
|
class Wiki():
|
||||||
def __init__ (self, xml_path):
|
def __init__ (self, xml_path):
|
||||||
@@ -152,7 +152,7 @@ def render (wikitext, base="", linker=None):
|
|||||||
else:
|
else:
|
||||||
url = linker.translate_interwiki_title(node.title)
|
url = linker.translate_interwiki_title(node.title)
|
||||||
if not url:
|
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(
|
rendered.append('<a href="{}">{}</a>'.format(
|
||||||
url,
|
url,
|
||||||
@@ -170,8 +170,9 @@ def render (wikitext, base="", linker=None):
|
|||||||
render(node.tag)
|
render(node.tag)
|
||||||
))
|
))
|
||||||
elif node_type is Heading:
|
elif node_type is Heading:
|
||||||
rendered.append("<h{}>{}</h{}>".format(
|
rendered.append('<h{} id="{}">{}</h{}>'.format(
|
||||||
node.level,
|
node.level,
|
||||||
|
reformat_page_title(node.title),
|
||||||
render(node.title, base, linker),
|
render(node.title, base, linker),
|
||||||
node.level
|
node.level
|
||||||
))
|
))
|
||||||
@@ -205,7 +206,7 @@ def reformat_page_title (page_title):
|
|||||||
if not page_title:
|
if not page_title:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
return f"{page_title[0].upper()}{page_title[1:].replace(' ', '_')}"
|
return "{}{}".format(page_title[0].upper(), page_title[1:].replace(' ', '_'))
|
||||||
|
|
||||||
class Template():
|
class Template():
|
||||||
def __init__ (self, wikicode):
|
def __init__ (self, wikicode):
|
||||||
@@ -224,4 +225,4 @@ class Template():
|
|||||||
try:
|
try:
|
||||||
parsed_wikicode.replace(argument, value)
|
parsed_wikicode.replace(argument, value)
|
||||||
except ValueError: pass
|
except ValueError: pass
|
||||||
return parsed_wikicode
|
return parsed_wikicode
|
||||||
|
@@ -77,21 +77,21 @@ DO_NOT_ARCHIVE_CATEGORIES = [
|
|||||||
# Boards we are not interested in archiving.
|
# Boards we are not interested in archiving.
|
||||||
# `id_board` in (1, 2)
|
# `id_board` in (1, 2)
|
||||||
DO_NOT_ARCHIVE_BOARDS = [
|
DO_NOT_ARCHIVE_BOARDS = [
|
||||||
24, 94, 118, 121 # Links
|
24, 94, 118, 121, # Links
|
||||||
40, # Exclusive Board
|
40, # Exclusive Board
|
||||||
65, # Requests for Moderatorship
|
65, # Requests for Moderatorship
|
||||||
66, # Requests for Membership+
|
66, # Requests for Membership+
|
||||||
67, # Requests for Distinguished Membership
|
67, # Requests for Distinguished Membership
|
||||||
23, # M.A.S.K. HQ (Staff Board)
|
23, # M.A.S.K. HQ (Staff Board)
|
||||||
22, # Admins Only Board
|
22, # Admins Only Board
|
||||||
89, # Test Board
|
89, # Test Board
|
||||||
86, # Omega Archives
|
86, # Omega Archives
|
||||||
51, 37, 79, 26, 47, 44, 45, 99, 93, 119, 96,
|
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,
|
3, 4, 5, 57, 58, 59, 38, 54, 63, 64,
|
||||||
68, 69, 70, 81, 82, 83,
|
68, 69, 70, 81, 82, 83,
|
||||||
28, # The Dumpster Out Back
|
28, # The Dumpster Out Back
|
||||||
123 # ?????
|
123 # ?????
|
||||||
]
|
]
|
||||||
|
|
||||||
# Regexes for sensitive information
|
# Regexes for sensitive information
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
{{>header}}
|
{{>header}}
|
||||||
|
{{>forums_notice}}
|
||||||
{{#categories}}
|
{{#categories}}
|
||||||
<h2 class="category-name">{{name}}</h2>
|
<h2 class="category-name">{{name}}</h2>
|
||||||
{{>child_boards}}
|
{{>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,8 +1,11 @@
|
|||||||
{{>header}}
|
{{>header}}
|
||||||
Welcome to the <b>Glitch City Laboratories Archives</b>.
|
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>
|
<h2>Archives</h2>
|
||||||
<ul>
|
<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>
|
<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>
|
||||||
<li><a href="wiki">Wiki</a> (<a href="wiki.tar.gz">.tar.gz</a>) (<a href="wiki.xml.gz">.xml.gz</a>)</li>
|
<li><a href="wiki">Wiki</a> (<a href="wiki.tar.gz">.tar.gz</a>) (<a href="wiki.xml.gz">.xml.gz</a>)</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{>footer}}
|
{{>footer}}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
{{>header}}
|
{{>header}}
|
||||||
|
{{>wiki_notice}}
|
||||||
<h2>{{page.title}}</h2>
|
<h2>{{page.title}}</h2>
|
||||||
<article class="page">
|
<article class="page">
|
||||||
{{{text}}}
|
{{{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}}
|
{{>header}}
|
||||||
|
{{>forums_notice}}
|
||||||
<h2><a href="../">{{board.name}}</a></h2>
|
<h2><a href="../">{{board.name}}</a></h2>
|
||||||
<h3>{{thread.subject}} - Page {{next}}</h3>
|
<h3>{{thread.subject}} - Page {{next}}</h3>
|
||||||
{{>pagination}}
|
{{>pagination}}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
{{>header}}
|
{{>header}}
|
||||||
|
{{>forums_notice}}
|
||||||
<h2>{{board.name}}</h2>
|
<h2>{{board.name}}</h2>
|
||||||
<table id="threads">
|
<table id="threads">
|
||||||
<tr>
|
<tr>
|
||||||
|
Reference in New Issue
Block a user