add ui for entering message id
authorJann Horn <jann@thejh.net>
Sun, 1 Sep 2024 23:54:36 +0000 (01:54 +0200)
committerJann Horn <jann@thejh.net>
Sun, 1 Sep 2024 23:54:36 +0000 (01:54 +0200)
.gcloudignore [new file with mode: 0644]
main.py

diff --git a/.gcloudignore b/.gcloudignore
new file mode 100644 (file)
index 0000000..df94e0f
--- /dev/null
@@ -0,0 +1,22 @@
+# This file specifies files that are *not* uploaded to Google Cloud
+# using gcloud. It follows the same syntax as .gitignore, with the addition of
+# "#!include" directives (which insert the entries of the given .gitignore-style
+# file at that point).
+#
+# For more information, run:
+#   $ gcloud topic gcloudignore
+#
+.gcloudignore
+# If you would like to upload your .git directory, .gitignore file or files
+# from your .gitignore file, remove the corresponding line
+# below:
+.git
+.gitignore
+
+# Python pycache:
+__pycache__/
+# Ignored by the build system
+/setup.cfg
+
+# sample files
+*.mbox
\ No newline at end of file
diff --git a/main.py b/main.py
index 38c0bfd..cb35da4 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -345,7 +345,8 @@ def parse_mbox():
 def app(environ, start_response):
     out = []
     query = parse_qs(environ.get('QUERY_STRING', ''))
-    msgid = query.get('msgid', None)
+    msgid = query.get('msgid', [''])[0]
+    print(repr(msgid))
 
     all_topic_roots = parse_mbox()
 
@@ -355,7 +356,9 @@ def app(environ, start_response):
     out.append('    <title>Mehlbrei</title>')
     out.append('    <style>')
     out.append('      html {height: 100%;width:100%;margin:0px;}')
-    out.append('      body {display: flex;height: 100%;width:100%;margin:0px;}')
+    out.append('      body {display: flex;flex-direction: column; height: 100%;width:100%;margin:0px;}')
+    out.append('      #header {width: 100%; flex-shrink:0;}')
+    out.append('      #below-header {display: flex;width:100%;margin:0px;flex-grow:2;flex-shrink:1;min-height:0;}')
     out.append('      #topic_panel {height: 100%; overflow:scroll;flex-shrink:0;}')
     out.append('      #main_panel {height: 100%; overflow:scroll;flex-grow:2;}')
     out.append('      .topic_link {display:block;}')
@@ -368,28 +371,37 @@ def app(environ, start_response):
     out.append('    </style>')
     out.append('  </head>')
     out.append('  <body>')
-    out.append('    <div id="topic_panel">')
-    out.append('      <h1>Topics</h1>')
-    for topic_root in all_topic_roots:
-        out.append('      <span class="topic_link'+(' empty-topic' if topic_root.non_diff_root_descendants == 0 else '')+'"><a href="#topic-'+str(topic_root.index)+'">'+html.escape(topic_root.msg.get('subject', '<no subject>'), quote=False)+'</a> ('+str(topic_root.non_diff_root_descendants)+' replies)</span>')
+    out.append('    <div id="header">')
+    out.append('      <form action="/thread" method="get">')
+    out.append('        Message ID (must exist on <a href="https://lore.kernel.org/">lore.kernel.org</a>):')
+    out.append('        <input type="text" name="msgid" size="50" value="'+html.escape(msgid)+'">')
+    out.append('        <button>lookup</button>')
+    out.append('      </form>')
     out.append('    </div>')
-    out.append('    <div id="main_panel">')
+    out.append('    <div id="below-header">')
+    out.append('      <div id="topic_panel">')
+    out.append('        <h1>Topics</h1>')
+    for topic_root in all_topic_roots:
+        out.append('        <span class="topic_link'+(' empty-topic' if topic_root.non_diff_root_descendants == 0 else '')+'"><a href="#topic-'+str(topic_root.index)+'">'+html.escape(topic_root.msg.get('subject', '<no subject>'), quote=False)+'</a> ('+str(topic_root.non_diff_root_descendants)+' replies)</span>')
+    out.append('      </div>')
+    out.append('      <div id="main_panel">')
     for topic_root in all_topic_roots:
-        out.append('      <div class="alt-content" id="topic-'+str(topic_root.index)+'">')
+        out.append('        <div class="alt-content" id="topic-'+str(topic_root.index)+'">')
         printed_top_header = False
         printed_threads_header = False
         for block in topic_root.blocks.ranges:
             if block.start_pos_child < 0 and not printed_top_header:
-                out.append('        <h1>Top-posted messages (sorry this section looks like a mess)</h1>')
+                out.append('          <h1>Top-posted messages (sorry this section looks like a mess)</h1>')
                 printed_top_header = True
             if block.start_pos_child >= 0 and not printed_threads_header:
-                out.append('        <h1>Actual thread</h1>')
+                out.append('          <h1>Actual thread</h1>')
                 printed_threads_header = True
-            out.append('        <div class="message-block-container" style="margin-left:'+str(block.message.depth*4)+'em">')
-            out.append('          <div class="message-block-meta">'+html.escape(block.message.from_hdr, quote=False)+'</div>')
-            out.append('          <div class="message-block-content">'+html.escape(block.get_text(), quote=False)+'</div>')
-            out.append('        </div>')
-        out.append('      </div>')
+            out.append('          <div class="message-block-container" style="margin-left:'+str(block.message.depth*4)+'em">')
+            out.append('            <div class="message-block-meta">'+html.escape(block.message.from_hdr, quote=False)+'</div>')
+            out.append('            <div class="message-block-content">'+html.escape(block.get_text(), quote=False)+'</div>')
+            out.append('          </div>')
+        out.append('        </div>')
+    out.append('      </div>')
     out.append('    </div>')
     out.append('  </body>')
     out.append('</html>')