Fix pdf and txt output, make it obvious for plumbers. - mediawiki-gopher - mediawiki gopher frontend
(HTM) git clone git://bitreich.org/mediawiki-gopher git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/mediawiki-gopher
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit 19f3977c6c45f5e216d71e555cb529554787bb43
(DIR) parent c9fdf6db6a9d9a85498de89ebfb10ede39dc3e66
(HTM) Author: Christoph Lohmann <20h@r-36.net>
Date: Fri, 2 Jan 2026 14:49:27 +0100
Fix pdf and txt output, make it obvious for plumbers.
Diffstat:
M index.dcgi | 13 ++++---------
M pdf/index.cgi | 5 ++++-
M txt/index.cgi | 7 +++++--
3 files changed, 13 insertions(+), 12 deletions(-)
---
(DIR) diff --git a/index.dcgi b/index.dcgi
@@ -35,7 +35,7 @@ def main(args):
def name2gph(name):
return name.replace("|", "\\|")
- def search2gph(search, mount="wiki"):
+ def search2gph(search, mount="txt"):
gph = ""
itgph = "0"
if mount == "pdf":
@@ -48,20 +48,15 @@ def main(args):
title = r["title"]
if r["description"] != None:
title = "%s - %s" % (title, r["description"])
- gph += "[%s|%s|%s/%s/%s|server|port]\n" % \
- (itgph, name2gph(title), g_base, mount, r["key"])
+ gph += "[%s|%s|%s/%s/%s.%s|server|port]\n" % \
+ (itgph, name2gph(title), g_base, mount,\
+ r["key"], mount)
return gph
def index2gph():
gph = "= %s =\n" % (mw_base)
gph += "[7|search|%s/search|server|port]\n" % (g_base)
gph += "[7|pdf search (experimental)|%s/pdfsearch|server|port]\n" % (g_base)
- gph += "[1|random|%s/txt/Special:Random|server|port]\n" \
- % (g_base)
- gph += "[1|randomredirect|%s/txt/Special:RandomRedirect|server|port]\n" \
- % (g_base)
- gph += "[1|randomroot|%s/txt/Special:RandomRootpage|server|port]\n" \
- % (g_base)
return gph
cmds = g_traversal.split("/")
(DIR) diff --git a/pdf/index.cgi b/pdf/index.cgi
@@ -48,9 +48,12 @@ def main(args):
gph = "3Not found.\t\t\n"
else:
page = cmds[1]
+ if page.endswith(".pdf"):
+ page = page[:-4]
pdf = requests.get("%s/%s" % (mw_pdf, \
page), headers=headers)
- g_content = pdf.content.replace(mw_base.encode("utf-8"),\
+ mw_replace = "%s/wiki" % (mw_base)
+ g_content = pdf.content.replace(mw_replace.encode("utf-8"),\
g_uri.encode("utf-8"))
sys.stdout.buffer.write(g_content)
return 0
(DIR) diff --git a/txt/index.cgi b/txt/index.cgi
@@ -50,11 +50,14 @@ def main(args):
gph = "3Not found.\t\t\n"
else:
page = cmds[1]
+ if page.endswith(".txt"):
+ page = page[:-4]
html = requests.get("%s/%s/html" % (mw_page, \
page), headers=headers)
h2t = html2text.HTML2Text()
- txt = h2t.handle(html)
- gph = txt.replace("%s/wiki" % (mw_base), "%s/txt" % (g_uri))
+ h2t.ignore_links = True
+ h2t.ignore_images = True
+ gph = h2t.handle(html.text)
sys.stdout.write(gph)
sys.stdout.flush()