commit:     496ba5a82637b8f023846f53d6c219d3e18259ad
Author:     Alex Legler <alex <AT> a3li <DOT> li>
AuthorDate: Mon Feb 23 20:58:52 2015 +0000
Commit:     Alex Legler <a3li <AT> gentoo <DOT> org>
CommitDate: Mon Feb 23 20:58:52 2015 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/ag-web.git;a=commit;h=496ba5a8

Various UI bit fixes for new storage format

---
 lib/helpers.rb      | 26 +++++++++++++-------------
 public/css/main.css |  7 +++++--
 views/layout.erb    |  3 ++-
 views/listmonth.erb |  2 +-
 views/message.erb   | 10 +++++-----
 views/report.erb    |  6 +++---
 6 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/lib/helpers.rb b/lib/helpers.rb
index 525dd93..5b4d2e3 100644
--- a/lib/helpers.rb
+++ b/lib/helpers.rb
@@ -42,8 +42,9 @@ helpers do
     ERB::Util::url_encode(text)
   end
 
-  def strip_email_domain(str)
-    str.split(/,\s*/).map do |email|
+  # This method strips domains from header fields.
+  def strip_email_headers(ary)
+    [ary].flatten.map do |email|
       email.gsub(/@(.*?)(>|$)/) do |s|
         if $1 == 'gentoo.org'
           "@g.o#{$2}"
@@ -53,21 +54,20 @@ helpers do
           "@#{'×' * $1.length}#{$2}"
         end
       end
-    end.join(', ')
+    end
   end
 
+  # This method is meant to strip emails from free text, not header fields
   def strip_email(str)
-    str.split(/,\s*/).map do |email|
-      email.gsub(/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,10})/) do 
|s|
-        if $2 == 'gentoo' and $3 == 'org'
-          "#{$1}@g.o"
-        elsif $2 == 'lists.gentoo' and $3 == 'org'
-          "#{$1}@l.g.o"
-        else
-          "#{$1}@#{'×' * $2.length}.#{$3}"
-        end
+    str.gsub(/([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,10})/) do |s|
+      if $2 == 'gentoo' and $3 == 'org'
+        "#{$1}@g.o"
+      elsif $2 == 'lists.gentoo' and $3 == 'org'
+        "#{$1}@l.g.o"
+      else
+        "#{$1}@#{'×' * $2.length}.#{$3}"
       end
-    end.join(', ')
+    end
   end
 
   def linkize(str)

diff --git a/public/css/main.css b/public/css/main.css
index c6ffc94..449d356 100644
--- a/public/css/main.css
+++ b/public/css/main.css
@@ -21,11 +21,11 @@
   }
 
   .ag-message-table-date {
-    width: 22%;
+    width: 18%;
   }
 
   .ag-message-table-from {
-    width: 18%;
+    width: 22%;
   }
 
   .ag-mostrecent-table-author {
@@ -91,4 +91,7 @@
 
 .ag-view-selection {
   margin-bottom: .5em;
+}
+
+.ag-date {
 }
\ No newline at end of file

diff --git a/views/layout.erb b/views/layout.erb
index 67a7e8b..e3bb34c 100644
--- a/views/layout.erb
+++ b/views/layout.erb
@@ -93,7 +93,8 @@
         <div class="row">
           <div class="col-xs-12 col-md-offset-2 col-md-7">
             <p class="spacer">
-              All contents reflect the opinion of the author, not the Gentoo 
project or the Gentoo Foundation.
+              All times displayed are UTC (GMT+0).<br>
+              Contents reflect the opinion of the author, not the Gentoo 
project or the Gentoo Foundation.
             </p>
           </div>
           <div class="col-xs-12 col-md-3">

diff --git a/views/listmonth.erb b/views/listmonth.erb
index 485df49..76a2244 100644
--- a/views/listmonth.erb
+++ b/views/listmonth.erb
@@ -23,7 +23,7 @@
       <tr>
         <td><a href="../../message/<%= message['_id'] %>"><%= h 
message['_source']['subject'] %></a></td>
         <td><%= h message['_source']['from_realname'] %></td>
-        <td><%= date_format message['_source']['date'] %></td>
+        <td><span class="ag-date"><%= date_format message['_source']['date'] 
%></span></td>
       </tr>
     <% end %>
   </table>

diff --git a/views/message.erb b/views/message.erb
index 78823c2..ee700fd 100644
--- a/views/message.erb
+++ b/views/message.erb
@@ -4,16 +4,16 @@
   <table class="table table-condensed ag-header-table">
     <tr>
       <th class="ag-header-name-col">From:</th>
-      <td><%= h strip_email_domain(message['_source']['from']) %></td>
+      <td><%= h strip_email_headers(message['_source']['from']).first %></td>
     </tr>
     <tr>
       <th>To:</th>
-      <td><%= h strip_email_domain(message['_source']['to']) %></td>
+      <td><%= h strip_email_headers(message['_source']['to']).join ', ' %></td>
     </tr>
-    <% unless message['_source']['cc'] == nil or message['_source']['cc'] == 
'' %>
+    <% unless message['_source']['cc'] == nil or message['_source']['cc'] == 
[] %>
     <tr>
       <th>Cc:</th>
-      <td><%= h strip_email_domain(message['_source']['cc']) %></td>
+      <td><%= h strip_email_headers(message['_source']['cc']).join ', ' %></td>
     </tr>
     <% end %>
     <tr>
@@ -72,7 +72,7 @@
     <% children.each do |child| %>
       <tr>
         <td><a href="<%= child['_id'] %>"><%= h child['_source']['subject'] 
%></a></td>
-        <td><%= h strip_email_domain(child['_source']['from']) %></td>
+        <td><%= h strip_email_headers(child['_source']['from']).first %></td>
       </tr>
     <% end %>
   </table>

diff --git a/views/report.erb b/views/report.erb
index 559dc23..13a8cf4 100644
--- a/views/report.erb
+++ b/views/report.erb
@@ -11,15 +11,15 @@
   </tr>
   <tr>
     <th class="ag-header-name-col">From:</th>
-    <td><%= h strip_email_domain(message['_source']['from']) %></td>
+    <td><%= h strip_email_headers(message['_source']['from']).first %></td>
   </tr>
   <tr>
     <th>To:</th>
-    <td><%= h strip_email_domain(message['_source']['to']) %></td>
+    <td><%= h strip_email_headers(message['_source']['to']).join ', ' %></td>
   </tr>
   <tr>
     <th>Cc:</th>
-    <td><%= h strip_email_domain(message['_source']['cc']) %></td>
+    <td><%= h strip_email_headers(message['_source']['cc']).join ', ' %></td>
   </tr>
   <tr>
     <th>Subject:</th>

Reply via email to