public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/ag-web:master commit in: lib/, views/
@ 2015-02-22  0:19 Robin H. Johnson
  0 siblings, 0 replies; 2+ messages in thread
From: Robin H. Johnson @ 2015-02-22  0:19 UTC (permalink / raw
  To: gentoo-commits

commit:     c2f6b4b772f3f52fa04fdc8252afbe73fda61b03
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 22 00:16:32 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 00:18:54 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/ag-web.git;a=commit;h=c2f6b4b7

Also link to MARC.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

---
 lib/helpers.rb    | 17 +++++++++++++++++
 views/message.erb |  5 +++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/helpers.rb b/lib/helpers.rb
index 5c3422e..3620d49 100644
--- a/lib/helpers.rb
+++ b/lib/helpers.rb
@@ -2,6 +2,9 @@ require 'date'
 require 'rinku'
 require 'erb'
 
+GMANE_FIND = 'http://news.gmane.org/find-root.php?message_id='
+MARC_FIND = 'https://marc.info/?i='
+
 helpers do
   def list_check
     unless [$config['active_lists'], $config['frozen_lists']].flatten.include?(params[:list])
@@ -68,5 +71,19 @@ helpers do
     Rinku.auto_link(str, :urls, 'rel="nofollow"')
   end
 
+  def msgid_to_gmane(msgid)
+    GMANE_FIND + ERB::Util::url_encode(msgid)
+  end
 
+  def msgid_to_marc(msgid)
+    # We have to transform the msg-id first
+    # CAK86ViRgefgrb0qUyjQdYa+6C5BTiNvn8UKZwQsMvcJmY-L0mg@mail.gmail.com
+    # CAK86ViRgefgrb0qUyjQdYa+6C5BTiNvn8UKZwQsMvcJmY-L0mg () mail ! gmail ! com
+    # http://marc.info/?i=CAK86ViRgefgrb0qUyjQdYa+6C5BTiNvn8UKZwQsMvcJmY-L0mg%20()%20mail%20!%20gmail%20!%20com
+    # pan.2009.08.28.00.00.38@cox.net
+    # http://marc.info/?i=pan.2009.08.28.00.00.38%20()%20cox%20!%20net
+    local, host = msgid.split('@', 2)
+    new_msgid = local + ' () ' + host.gsub('.',' ! ')
+    MARC_FIND + ERB::Util::url_encode(new_msgid)
+  end
 end

diff --git a/views/message.erb b/views/message.erb
index 181f532..7c5be12 100644
--- a/views/message.erb
+++ b/views/message.erb
@@ -74,5 +74,6 @@
 
 <div class="btn-group btn-group-xs" role="group" aria-label="Message Actions">
   <a href="/<%= h list %>/report/<%= message['_id'] %>" class="btn btn-danger"><span class="fa fa-fw fa-ban"></span> Report Message</a>
-  <a href="http://news.gmane.org/find-root.php?message_id=<%= u(message['_source']['raw_message_id']) %>" class="btn btn-default"><span class="fa fa-fw fa-share-square"></span>Find on GMANE</a>
-</div>
\ No newline at end of file
+  <a href="<%= msgid_to_gmane(message['_source']['raw_message_id']) %>" class="btn btn-default"><span class="fa fa-fw fa-share-square"></span>Find on GMANE</a>
+  <a href="<%= msgid_to_marc(message['_source']['raw_message_id']) %>" class="btn btn-default"><span class="fa fa-fw fa-share-square"></span>Find on MARC</a>
+</div>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/ag-web:master commit in: lib/, views/
@ 2015-02-22 11:29 Alex Legler
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Legler @ 2015-02-22 11:29 UTC (permalink / raw
  To: gentoo-commits

commit:     72b8c84b55e84a0f5287b417d256db4d10aec095
Author:     Alex Legler <alex <AT> a3li <DOT> li>
AuthorDate: Sun Feb 22 11:29:49 2015 +0000
Commit:     Alex Legler <a3li <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 11:29:49 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/ag-web.git;a=commit;h=72b8c84b

Fix mail count

---
 lib/index.rb    |  9 +++++++++
 views/index.erb | 21 +++++++++++----------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/lib/index.rb b/lib/index.rb
index a50ba4c..5690afe 100644
--- a/lib/index.rb
+++ b/lib/index.rb
@@ -73,6 +73,15 @@ def get_month_listing(list)
   )
 end
 
+def get_message_count(list)
+  $es.search(
+    index: 'ml-' + list,
+    size: 1,
+    body: {}
+  )['hits']['total']
+rescue => e
+  '?'
+end
 
 def get_message(list, hash)
   $es.search(

diff --git a/views/index.erb b/views/index.erb
index 77eda4c..d1454ea 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -6,7 +6,11 @@
   <div class="col-xs-12 col-md-6">
     <div class="list-group">
       <% $config['active_lists'].each do |list| %>
-      <a href="<%= h list %>/" class="list-group-item"><span class="fa fa-fw fa-archive"></span> <%= h list %></a>
+        <a href="<%= h list %>/" class="list-group-item">
+          <span class="fa fa-fw fa-archive"></span>
+          <%= h list %>
+          <span class="badge"><%= get_message_count(list) %></span>
+        </a>
       <% end %>
     </div>
   </div>
@@ -24,15 +28,12 @@
 <div class="row">
   <div class="col-xs-12 col-md-6">
     <div class="list-group">
-      <% $config['frozen_lists'].each do |list| 
-          begin
-              months = get_month_listing(list)
-              count = months['hits']['total'] + ' mails'
-          rescue => e
-              count = 'mail count unavailable'
-          end 
-      %>
-  <a href="<%= h list %>/" class="list-group-item"><span class="fa fa-fw fa-archive"></span> <%= h list %> (<%= count %>)</a>
+      <% $config['frozen_lists'].each do |list| %>
+        <a href="<%= h list %>/" class="list-group-item">
+          <span class="fa fa-fw fa-archive"></span>
+          <%= h list %>
+          <span class="badge"><%= get_message_count(list) %></span>
+        </a>
       <% end %>
     </div>
   </div>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-22 11:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-22  0:19 [gentoo-commits] proj/ag-web:master commit in: lib/, views/ Robin H. Johnson
  -- strict thread matches above, loose matches on Subject: below --
2015-02-22 11:29 Alex Legler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox