You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sam Ruby <ru...@apache.org> on 2015/12/17 02:55:50 UTC
[whimsy.git] [1/1] Commit 48f6ddf: start to rough in a "check for new mail" button
Commit 48f6ddf66b51c491d340fedacec55b6d91f66b03:
start to rough in a "check for new mail" button
Branch: refs/heads/secmail
Author: Sam Ruby <ru...@intertwingly.net>
Committer: Sam Ruby <ru...@intertwingly.net>
Pusher: rubys <ru...@apache.org>
------------------------------------------------------------
www/secmail/mailbox.rb | +++++++++++
www/secmail/parsemail.rb | +++++++ --------
www/secmail/public/secmail.css | ++++++++
www/secmail/views/index.js.rb | +++++ ---
------------------------------------------------------------
52 changes: 41 additions, 11 deletions.
------------------------------------------------------------
diff --git a/www/secmail/mailbox.rb b/www/secmail/mailbox.rb
index d914f12..f890189 100644
--- a/www/secmail/mailbox.rb
+++ b/www/secmail/mailbox.rb
@@ -12,6 +12,27 @@
class Mailbox
#
+ # fetch a/some/all mailboxes
+ #
+ def self.fetch(mailboxes=nil)
+ options = %w(-av --no-motd)
+
+ if mailboxes == nil
+ options += %w(--delete --exclude='*.yml')
+ source = "#{SOURCE}/"
+ elsif Array === mailboxes
+ host, path = SOURCE.split(':', 2)
+ files = mailboxes.map {|name| "#{path}/#{name}*"}
+ source = "#{host}:#{files.join(' ')}"
+ else
+ source = "#{SOURCE}/#{mailboxes}*"
+ end
+
+ Dir.mkdir ARCHIVE unless Dir.exist? ARCHIVE
+ system 'rsync', *options, source, "#{ARCHIVE}/"
+ end
+
+ #
# Initialize a mailbox
#
def initialize(name)
diff --git a/www/secmail/parsemail.rb b/www/secmail/parsemail.rb
index fd529ce..372f25d 100644
--- a/www/secmail/parsemail.rb
+++ b/www/secmail/parsemail.rb
@@ -23,15 +23,14 @@
ARGV.unshift Time.now.strftime('%Y%m')
end
-if ARGV.any? {|arg| arg =~ /^\d{6}$/}
- Dir.mkdir ARCHIVE unless Dir.exist? ARCHIVE
- ARGV.each do |arg|
- if arg =~ /^\d{6}$/
- system "rsync -av --no-motd #{SOURCE}/#{arg}* #{ARCHIVE}/"
- end
- end
+# fetch (selected|all) mailboxes
+months = ARGV.select {|arg| arg =~ /^\d{6}$/}
+if not months.empty?
+ Mailbox.fetch months
+elsif ARGV.include? '--fetch1'
+ Mailbox.fetch Time.now.strftime('%Y%m')
elsif ARGV.include? '--fetch' or not Dir.exist? database
- system "rsync -av --no-motd --delete --exclude='*.yml' #{SOURCE}/ #{ARCHIVE}/"
+ Mailbox.fetch
end
# scan each mailbox for updates
diff --git a/www/secmail/public/secmail.css b/www/secmail/public/secmail.css
index 2f09da1..3b2a160 100644
--- a/www/secmail/public/secmail.css
+++ b/www/secmail/public/secmail.css
@@ -1,8 +1,16 @@
+#index table {
+ margin-left: 8px;
+}
+
#index td:nth-child(2), #index th:nth-child(2) {
padding-right: 7px;
padding-left: 7px;
}
+#index button {
+ margin: 5px;
+}
+
.selected {
background-color: yellow;
}
diff --git a/www/secmail/views/index.js.rb b/www/secmail/views/index.js.rb
index 31abb09..c9bd1da 100644
--- a/www/secmail/views/index.js.rb
+++ b/www/secmail/views/index.js.rb
@@ -40,13 +40,15 @@ def render
end
if @nextmbox
- _input.btn.btn_primary type: 'submit', value: 'fetch previous month',
+ _button.btn.btn_primary 'download previous month',
onClick: self.fetch_month
end
+ _button.btn.btn_success 'check for new mail', onClick: self.refresh,
+ disabled: true
+
unless @undoStack.empty?
- _input.btn.btn_info type: 'submit', value: 'undo delete',
- onClick: self.undo
+ _button.btn.btn_info 'undo delete', onClick: self.undo
end
end