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-l...@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...@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>

Reply via email to