Commit Diff


commit - 759ed8a24fe33d3cc5511e03d25822ba812571ef
commit + 11eb9ffae8b7af8e9474e4d3e3149de0246e5017
blob - bbfbca3cddc3fdde7f527368a8f47b03b30b92c7
blob + b743d4785bf84fdf3bb5e5889150401f1081b1e9
--- lonk.py
+++ lonk.py
@@ -143,6 +143,14 @@ class HtmlToGmi(HTMLParser):
         # https://humungus.tedunangst.com/r/webs/v/tip/f/htfilter/html.go
         if tag in _TAGS_IN_TEXT:
             return
+
+        if tag == "img":
+            img = {attr_name: attr_value for attr_name, attr_value in attrs}
+            title = img.get("title")
+            if img.get("class") == "emu" and title and self.stack:
+                self.stack[-1].on_data(title)
+                return
+                
 
         if self.stack:
             self.gmi_text.append(self.stack[-1].flush())
@@ -176,6 +184,9 @@ class HtmlToGmi(HTMLParser):
 
     def handle_endtag(self, tag):
         # print(f" < {tag=}")
+        if tag in _TAGS_IN_TEXT:
+            return
+
         if self.stack:
             self.gmi_text.append(self.stack[-1].flush())
             if tag == self.stack[-1].tag:
@@ -230,16 +241,19 @@ def demo():
 
 def server():
     from argparse import ArgumentParser
+    parser.add_argument("--address", default="127.0.0.1", help="bind to this address (default: %(default)s)")
+    parser.add_argument("--port", default=1965, type=int, help="bind to this port (default: %(default)s)")
     parser.add_argument("--settings", required=True, help="path to server settings (JSON file)")
     parser.add_argument("--certfile", required=True, help="path server certificate file")
     parser.add_argument("--keyfile", required=True, help="path certificate private key file")
+    parser.add_argument("--dbfile", required=True, help="path to databale file")
     args = parser.parse_args()
 
     ssl_ctx = SSLContext(PROTOCOL_TLS_SERVER)
     ssl_ctx.load_cert_chain(args.certfile, args.keyfile)
 
     with socket() as sock:
-        sock.bind(("127.0.0.1", 1998))
+        sock.bind((args.address, args.port))
         sock.listen()
         with ssl_ctx.wrap_socket(sock, server_side=True) as ssl_sock:
             conn, addr = ssl_sock.accept()