Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: brabuhr@gmail.com (brabuhr)
Subject: [sup-talk] [PATCH] first pass at a simple interface to extract URIs from a message
Date: Tue, 29 Jan 2008 22:23:31 -0500	[thread overview]
Message-ID: <21aa9f0801291923w2df946dbga7832a7345c09a95@mail.gmail.com> (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


             reply	other threads:[~2008-01-30  3:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-30  3:23 brabuhr [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21aa9f0801291923w2df946dbga7832a7345c09a95@mail.gmail.com \
    --to=brabuhr@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox