Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] first pass at a simple interface to extract URIs from a message
@ 2008-01-30  3:23 brabuhr
  2008-02-03  2:56 ` William Morgan
  2008-02-16 20:04 ` William Morgan
  0 siblings, 2 replies; 8+ messages in thread
From: brabuhr @ 2008-01-30  3:23 UTC (permalink / raw)


On Jan 29, 2008 2:47 PM, Daniel Wagner <daniel at wagner-home.com> wrote:
> One thing I find myself doing all the time is highlighting a web address
> and pasting it into Firefox.

This adds a new key binding to the thread-view mode (L) to assist with
loading URIs from the body of the message.  This first pass will pull
the URIs from the message text and loop through them while asking if
that URI should be loaded.  Currently, there is no code to actually
perform the load.
---
 lib/sup/modes/thread-view-mode.rb |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/lib/sup/modes/thread-view-mode.rb
b/lib/sup/modes/thread-view-mode.rb
index 961fc5d..5fae8fa 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -1,4 +1,5 @@
 require 'open3'
+require 'uri'
 module Redwood

 class ThreadViewMode < LineCursorMode
@@ -48,6 +49,7 @@ EOS
     k.add :subscribe_to_list, "Subscribe to/unsubscribe from mailing list", "("
     k.add :unsubscribe_from_list, "Subscribe to/unsubscribe from
mailing list", ")"
     k.add :pipe_message, "Pipe message or attachment to a shell command", '|'
+    k.add :follow_link, "Follow a web link", "L"

     k.add_multi "(a)rchive/(d)elete/mark as (s)pam/mark as
u(N)read:", '.' do |kk|
       kk.add :archive_and_kill, "Archive this thread and kill buffer", 'a'
@@ -456,6 +458,34 @@ EOS
     end
   end

+  def follow_link
+    chunk = @chunk_lines[curpos]
+
+    return unless chunk.is_a?(Chunk::Text)
+
+    uris = URI.extract(chunk.lines.join("\n")).uniq.sort
+
+    if uris.size > 0
+      Redwood::log uris.join("\n")
+      Redwood::BufferManager.flash "#{uris.size} URIs found."
+      sleep 1
+
+      uris.each do |uri|
+        case Redwood::BufferManager.ask_yes_or_no "Load URI: #{uri} (y/n)"
+        when true
+          Redwood::BufferManager.flash "<add launch the url code here
please :-)>"
+          break
+        when false
+          next
+        else
+          break
+        end
+      end
+    else
+      Redwood::BufferManager.flash "No URIs found."
+    end
+  end
+
 private

   def initial_state_for m
-- 
1.5.2.5


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

end of thread, other threads:[~2008-02-19 10:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-30  3:23 [sup-talk] [PATCH] first pass at a simple interface to extract URIs from a message brabuhr
2008-02-03  2:56 ` William Morgan
2008-02-09  2:01   ` brabuhr at gmail.com
2008-02-16 20:04 ` William Morgan
2008-02-16 20:06   ` [sup-talk] [PATCH] add URL extraction, listing, and viewing capabilities to ThreadViewMode William Morgan
2008-02-18 23:24   ` [sup-talk] [PATCH] first pass at a simple interface to extract URIs from a message Nicolas Pouillard
2008-02-19  3:12     ` Daniel Wagner
2008-02-19 10:17       ` Nicolas Pouillard

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