This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new a3a86ea3 Display all messages with links
a3a86ea3 is described below

commit a3a86ea30c6c0418c01659f045e57d0e617eca21
Author: Sebb <[email protected]>
AuthorDate: Fri Aug 2 22:40:46 2024 +0100

    Display all messages with links
---
 www/secretary/workbench/server.rb         |  7 +++++++
 www/secretary/workbench/views/all.html.rb | 27 +++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/www/secretary/workbench/server.rb 
b/www/secretary/workbench/server.rb
index b2635ac3..fac856ba 100644
--- a/www/secretary/workbench/server.rb
+++ b/www/secretary/workbench/server.rb
@@ -112,6 +112,13 @@ get %r{/(\d{6})/deleted} do |mbox|
   _html :deleted
 end
 
+# display all messages
+get %r{/(\d{6})/all} do |mbox|
+  @mbox = mbox
+  @messages = Mailbox.new(@mbox).client_headers
+  _html :all
+end
+
 # retrieve a single message
 get %r{/(\d{6})/(\w+)/} do |month, hash|
   @message = Mailbox.new(month).headers[hash]
diff --git a/www/secretary/workbench/views/all.html.rb 
b/www/secretary/workbench/views/all.html.rb
new file mode 100644
index 00000000..056da464
--- /dev/null
+++ b/www/secretary/workbench/views/all.html.rb
@@ -0,0 +1,27 @@
+_html do
+  _h1 'All messages'
+  _table.table do
+    _thead do
+      _tr do
+        _th 'Status'
+        _th 'Timestamp'
+        _th 'From'
+        _th 'Subject'
+      end
+    end
+    _tbody do
+      @messages.each do |msg|
+        time = Time.parse(msg[:time]).to_s
+        _tr do
+          _td msg[:status].to_s
+          _td do
+            _a time, href: "../%s" % msg[:href], title: time
+          end
+          _td msg[:from]
+          _td msg[:subject]
+        end
+      end
+    end
+  end
+  _hr
+end

Reply via email to