whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: first pass at client side of historical comments
Date Thu, 07 Apr 2016 14:46:01 GMT
This is an automated email from the ASF dual-hosted git repository.

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

The following commit(s) were added to refs/heads/master by this push:
       new  d08ff2c   first pass at client side of historical comments
d08ff2c is described below

commit d08ff2cb56ab4198a1a20e5061975a74f62cb041
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Thu Apr 7 10:45:27 2016 -0400

    first pass at client side of historical comments
---
 www/board/agenda/public/stylesheets/app.css        |  5 ++++
 www/board/agenda/routes.rb                         | 10 ++++----
 www/board/agenda/views/app.js.rb                   |  1 +
 .../agenda/views/elements/additional-info.js.rb    | 19 ++++++++++++++-
 www/board/agenda/views/models/agenda.js.rb         | 16 +------------
 www/board/agenda/views/models/comments.js.rb       | 28 ++++++++++++++++++++++
 www/board/agenda/views/utils.js.rb                 | 23 ++++++++++++++++++
 7 files changed, 81 insertions(+), 21 deletions(-)

diff --git a/www/board/agenda/public/stylesheets/app.css b/www/board/agenda/public/stylesheets/app.css
index faaae1c..2e918e4 100644
--- a/www/board/agenda/public/stylesheets/app.css
+++ b/www/board/agenda/public/stylesheets/app.css
@@ -462,3 +462,8 @@ button.checklist {
   margin-left: 1.5em;
   margin-bottom: 1em;
 }
+
+h5.history {
+  margin-left: 1em;
+}
+
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index d046bcb..241ce9e 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -206,6 +206,11 @@ get %r{/json/chat/(\d\d\d\d_\d\d_\d\d)} do |date|
   end
 end
 
+# historical comments
+get '/json/historical-comments' do
+  _json HistoricalComments.comments
+end
+
 # event stream for server sent events (a.k.a EventSource)
 get '/events', provides: 'text/event-stream' do
   stream :keep_open do |out|
@@ -246,8 +251,3 @@ get '/text/draft/:file' do |file|
     end
   end
 end
-
-# historical comments
-get '/historical-comments' do
-  _json HistoricalComments.comments
-end
diff --git a/www/board/agenda/views/app.js.rb b/www/board/agenda/views/app.js.rb
index ce24e8d..3dcf14a 100644
--- a/www/board/agenda/views/app.js.rb
+++ b/www/board/agenda/views/app.js.rb
@@ -58,3 +58,4 @@ require_relative 'models/chat'
 require_relative 'models/jira'
 require_relative 'models/pending'
 require_relative 'models/posted'
+require_relative 'models/comments'
diff --git a/www/board/agenda/views/elements/additional-info.js.rb b/www/board/agenda/views/elements/additional-info.js.rb
index 3369d14..e0ac7e6 100644
--- a/www/board/agenda/views/elements/additional-info.js.rb
+++ b/www/board/agenda/views/elements/additional-info.js.rb
@@ -31,13 +31,30 @@ class AdditionalInfo < React
     end
 
     # posted comments
-    unless @@item.comments.empty?
+    history = HistoricalComments.find(@@item.title)
+    if not @@item.comments.empty? or (history and not @prefix)
       _h4 'Comments', id: "#{@prefix}comments"
       @@item.comments.each do |comment|
         _pre.comment do
           _Text raw: comment, filters: [hotlink]
         end
       end
+
+      # historical comments
+      if history and not @prefix
+        for date in history
+          _h5.history do
+            _span "\u2022 "
+            _a date.gsub('_', '-'),
+              href: HistoricalComments.link(date, @@item.title)
+            _span ':'
+          end
+
+          _pre.comment do
+            _Text raw: history[date], filters: [hotlink]
+          end
+        end
+      end
     end
 
     # pending comments
diff --git a/www/board/agenda/views/models/agenda.js.rb b/www/board/agenda/views/models/agenda.js.rb
index 160f0ee..a4fd3d3 100644
--- a/www/board/agenda/views/models/agenda.js.rb
+++ b/www/board/agenda/views/models/agenda.js.rb
@@ -134,21 +134,7 @@ class Agenda
 
   # return comments as an array of individual comments
   def comments
-    results = []
-    return results unless @comments
-
-    comment = ''
-    @comments.split("\n").each do |line|
-      if line =~ /^\S/
-        results << comment unless comment.empty?
-        comment = line
-      else
-        comment += "\n" + line
-      end
-    end
-
-    results << comment unless comment.empty?
-    return results
+    splitComments(@comments)
   end
 
   # item's comments excluding comments that have been seen before
diff --git a/www/board/agenda/views/models/comments.js.rb b/www/board/agenda/views/models/comments.js.rb
new file mode 100644
index 0000000..0b18c8a
--- /dev/null
+++ b/www/board/agenda/views/models/comments.js.rb
@@ -0,0 +1,28 @@
+#
+# Fetch, retain, and query the list of historical comments
+#
+
+class HistoricalComments
+  @@comments = nil
+
+  # find historical comments based on report title
+  def self.find(title)
+    if @@comments
+      return @@comments[title]
+    elsif defined? XMLHttpRequest
+      @@comments = {}
+      fetch('historical-comments', :json) do |comments|
+        @@comments = comments
+      end
+    end
+  end
+
+  # find link for historical comments based on date and report title
+  def self.link(date, title)
+    if Server.agendas.include? "board_agenda_#{date}.txt"
+      return "../#{date.gsub('_', '-')}/#{title}"
+    else
+      return "../../minutes/#{title}.html#minutes_#{date}"
+    end
+  end
+end
diff --git a/www/board/agenda/views/utils.js.rb b/www/board/agenda/views/utils.js.rb
index f1daa1c..cce6dd3 100644
--- a/www/board/agenda/views/utils.js.rb
+++ b/www/board/agenda/views/utils.js.rb
@@ -173,3 +173,26 @@ class Flow
     return lines.join("\n")
   end
 end
+
+#
+# Split comments string into individual comments
+#
+
+def splitComments(string)
+  results = []
+  return results unless string
+
+  comment = ''
+  string.split("\n").each do |line|
+    if line =~ /^\S/
+      results << comment unless comment.empty?
+      comment = line
+    else
+      comment += "\n" + line
+    end
+  end
+
+  results << comment unless comment.empty?
+  return results
+end
+

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message