On Jan 29, 2008 2:47 PM, Daniel Wagner <[EMAIL PROTECTED]> 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
_______________________________________________
sup-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/sup-talk