commit af2f405e6bf61d645ff6a886a5183dc1a1305f00 from: Omar Polo date: Tue Nov 10 19:03:01 2020 UTC code fmt improvement, decode query url and print maintainer commit - b1e7f11e6b4f4fa4bd81fe89d098bfc699b9e53f commit + af2f405e6bf61d645ff6a886a5183dc1a1305f00 blob - 4a0370b94cd9c1403ca344259fce18c37aeafb66 blob + a049f2570b0f88b5cc39a188fdc68455d83c89b4 --- resources/cgi/gempkg +++ resources/cgi/gempkg @@ -1,10 +1,11 @@ #!/usr/bin/env python3 import os +import re import sqlite3 import sys import traceback -import re +import urllib.parse query_search = """ select webpkg_fts.pkgstem, @@ -43,7 +44,11 @@ def verbatim(alt, text): def printraw(text): for line in text.splitlines(): - if line.startswith(">") or line.startswith("```") or line.startswith(">") or line.startswith("#"): + if line.startswith(">") \ + or line.startswith("```") \ + or line.startswith(">") \ + or line.startswith("#") \ + or line.startswith("*"): print(" ") print(line) @@ -53,7 +58,6 @@ script_path = os.environ.get("SCRIPT_NAME") path = os.environ.get("REQUEST_RELATIVE") if not path or path == '/': - # home page print("20 text/gemini;charset=utf-8\r") print("Welcome to GemPKG, the gemini interface to the OpenBSD port collection.") print("") @@ -70,6 +74,7 @@ try: print("10 query:\r") exit(0) + query = urllib.parse.unquote(query) cursor = conn.execute(query_search, (query,)) print("20 text/gemini;charset=utf-8\r") @@ -109,6 +114,8 @@ try: if www: print(f"=> {www} WWW") print("") + print("Maintainer:", maintainer) + print("") print("## Description") printraw(re.sub(r"\n", " ", descr)) print("")