whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] 01/02: when possible, prefill in the 'post report' form with text from the board@ mailing list
Date Wed, 20 Jun 2018 02:42:58 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit f96a2e1af1303f4270cb605cc94cf1b4f2136a65
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Tue Jun 19 19:27:50 2018 -0700

    when possible, prefill in the 'post report' form with text from the
    board@ mailing list
---
 www/board/agenda/routes.rb                         |  4 +++
 .../agenda/views/actions/posted-reports.json.rb    | 32 ++++++++++++++++------
 www/board/agenda/views/buttons/post.js.rb          |  9 ++++++
 3 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 9cacf40..2621756 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -280,6 +280,10 @@ get '/json/posted-reports' do
   _json :"actions/posted-reports"
 end
 
+post '/json/posted-reports' do
+  _json :"actions/posted-reports"
+end
+
 # podling name searches
 get '/json/podlingnamesearch' do
   _json ASF::Podling.namesearch
diff --git a/www/board/agenda/views/actions/posted-reports.json.rb b/www/board/agenda/views/actions/posted-reports.json.rb
index 849deca..b00efa7 100755
--- a/www/board/agenda/views/actions/posted-reports.json.rb
+++ b/www/board/agenda/views/actions/posted-reports.json.rb
@@ -1,5 +1,6 @@
 #
-# List of reports posted to board@
+# If @path is passed, return that message body, otherwise return the
+# list of reports posted to board@
 #
 
 require 'date'
@@ -8,6 +9,16 @@ require 'whimsy/asf/agenda'
 
 # link to board private-arch
 THREAD = "https://lists.apache.org/thread.html/"
+ARCHIVE = '/srv/mail/board'
+
+if @path and @path =~ /^\d+\/\w+$/
+  mail = Mail.new(File.read(File.join(ARCHIVE, @path)))
+  if mail.text_part
+    return {text: mail.text_part.body.to_s.force_encoding(Encoding::UTF_8)}
+  else
+    return {text: ''}
+  end
+end
 
 # only look at this month's and last month's mailboxes, and within those
 # only look at emails that were received since the previous board meeting.
@@ -21,19 +32,21 @@ else
 end
 
 # get a list of current board messages
-archive = Dir["/srv/mail/board/#{previous}/*", "/srv/mail/board/#{current}/*"]
+archive = Dir["#{ARCHIVE}/#{previous}/*", "/srv/mail/board/#{current}/*"]
 
 # select messages that have a subject line starting with [REPORT]
 reports = []
-archive.each do |email|
-  email.untaint
-  next if File.mtime(email) < cutoff
-  next if email.end_with? '/index'
-  message = IO.read(email, mode: 'rb')
+archive.each do |email_path|
+  email_path.untaint
+  next if File.mtime(email_path) < cutoff
+  next if email_path.end_with? '/index'
+  message = IO.read(email_path, mode: 'rb')
   subject = message[/^Subject: .*/]
   next unless subject and subject =~ /\bREPORT\b/i
   mail = Mail.new(message.encode(message.encoding, crlf_newline: true))
-  reports << mail if subject and mail.subject =~ /\A[\[({]REPORT[\])}]/i
+  if subject and mail.subject =~ /\A[\[({]REPORT[\])}]/i
+    reports << [email_path.split('/')[-2..-1].join('/'), mail] 
+  end
 end
 
 # Get a list of missing board reports
@@ -43,9 +56,10 @@ missing = parsed.select {|item| item['missing']}.
   map {|item| item['title'].downcase}
 
 # produce output
-_ reports do |mail|
+_ reports do |path, mail|
   _subject mail.subject
   _link THREAD + URI.escape('<' + mail.message_id + '>')
+  _path path
 
   subject = mail.subject.downcase
   _missing missing.any? {|title| subject =~ /\b#{title}\b/}
diff --git a/www/board/agenda/views/buttons/post.js.rb b/www/board/agenda/views/buttons/post.js.rb
index 33f467a..b0ccfce 100644
--- a/www/board/agenda/views/buttons/post.js.rb
+++ b/www/board/agenda/views/buttons/post.js.rb
@@ -337,6 +337,15 @@ class Post < Vue
       @label = 'report'
       @message = "Post #{@@item.title} Report"
 
+      # if by chance the report was posted to board@, attempt to fetch
+      # the text/plain version of the body
+      posted = Posted.get(@@item.title)
+      unless posted.empty?
+        post 'posted-reports', path: posted.last.path do |response|
+          @report ||= response.text
+        end
+      end
+
     when 'edit item'
       @header = 'Edit Discussion Item'
       @label = 'text'


Mime
View raw message