Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] Additional attachment goodness...
@ 2008-02-27 22:40 Marcus Williams
  2008-02-28 17:02 ` William Morgan
  0 siblings, 1 reply; 3+ messages in thread
From: Marcus Williams @ 2008-02-27 22:40 UTC (permalink / raw)


Adds hidden/reserved attachment label to track attachments. Also adds
new flag on thread index mode to denote an attachment '#'. This
extends the attachments patch sent earlier and is also against latest
'next'.  It will require another sup-sync -all to work against all
sources, but attempts to be backwards compatable with non-synced
sources. Adds a "has:attachment" search query.
---
 lib/sup/index.rb                   |    2 +-
 lib/sup/label.rb                   |    6 +++---
 lib/sup/message.rb                 |    1 +
 lib/sup/modes/thread-index-mode.rb |    3 ++-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index 4205f2a..bb70328 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -438,7 +438,7 @@ protected
     extraopts[:load_deleted] = true if subs =~ /\blabel:deleted\b/
 
     ## gmail style "is" operator
-    subs = subs.gsub(/\b(is):(\S+)\b/) do
+    subs = subs.gsub(/\b(is|has):(\S+)\b/) do
       field, label = $1, $2
       case label
       when "read"
diff --git a/lib/sup/label.rb b/lib/sup/label.rb
index 4afc0f9..716ef98 100644
--- a/lib/sup/label.rb
+++ b/lib/sup/label.rb
@@ -5,13 +5,13 @@ class LabelManager
 
   ## labels that have special semantics. user will be unable to
   ## add/remove these via normal label mechanisms.
-  RESERVED_LABELS = [ :starred, :spam, :draft, :unread, :killed, :sent, :deleted, :inbox ]
+  RESERVED_LABELS = [ :starred, :spam, :draft, :unread, :killed, :sent, :deleted, :inbox, :attachment ]
 
   ## labels which it nonetheless makes sense to search for by
-  LISTABLE_RESERVED_LABELS = [ :starred, :spam, :draft, :sent, :killed, :deleted, :inbox ]
+  LISTABLE_RESERVED_LABELS = [ :starred, :spam, :draft, :sent, :killed, :deleted, :inbox, :attachment ]
 
   ## labels that will typically be hidden from the user
-  HIDDEN_RESERVED_LABELS = [ :starred, :unread ]
+  HIDDEN_RESERVED_LABELS = [ :starred, :unread, :attachment ]
 
   def initialize fn
     @fn = fn
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 480f52c..2be779c 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -410,6 +410,7 @@ private
         # attachment (should we allow images with generated names?).
         # Lowercase the filename because searches are easier that way 
         @attachments.push filename.downcase unless filename =~ /^sup-attachment-/
+        add_label :attachment unless filename =~ /^sup-attachment-/
         [Chunk::Attachment.new(m.header.content_type, filename, m, sibling_types)]
 
       ## otherwise, it's body text
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
index 7a0b815..1b2c0d7 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -713,7 +713,8 @@ protected
       from +
       [
       [subj_color, size_widget_text],
-      [:to_me_color, dp ? " >" : (p ? ' +' : "  ")],
+      [:to_me_color, t.labels.member?(:attachment) ? "#" : " "],
+      [:to_me_color, dp ? ">" : (p ? '+' : " ")],
       [subj_color, t.subj + (t.subj.empty? ? "" : " ")],
     ] +
       (t.labels - @hidden_labels).map { |label| [:label_color, "+#{label} "] } +
-- 
1.5.4.1



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

end of thread, other threads:[~2008-02-28 20:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-27 22:40 [sup-talk] [PATCH] Additional attachment goodness Marcus Williams
2008-02-28 17:02 ` William Morgan
2008-02-28 20:57   ` Marcus Williams

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