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/13 16:14:54 UTC

[whimsy.git] [21/37] Commit 269dabc: switch index to react

Commit 269dabcdc4dacfdc23d910d32689b5ade3a63f42:
    switch index to react


Branch: refs/heads/secmail
Author: Sam Ruby <ru...@intertwingly.net>
Committer: Sam Ruby <ru...@intertwingly.net>
Pusher: rubys <ru...@apache.org>

------------------------------------------------------------
server.rb                                                    | ++ -
views/app.js.rb                                              | + 
views/index.html.rb                                          | ++ ------------
------------------------------------------------------------
31 changes: 7 additions, 24 deletions.
------------------------------------------------------------


diff --git a/server.rb b/server.rb
index 16a1054..ca9f328 100644
--- a/server.rb
+++ b/server.rb
@@ -18,11 +18,12 @@
   @messages = Mailbox.new(mbox).headers
 
   # for the first week of every month, add previous month
-  if File.mtime(mbox).day < 7
+  if File.mtime(mbox).day <= 7
     mbox = Dir["#{ARCHIVE}/*.yml"].sort[-2]
     @messages.merge! Mailbox.new(@mbox).headers
   end
 
+  @messages = @messages.select {|id, message| message[:attachments]}
   @messages = @messages.sort_by {|id, message| message[:time]}.reverse
   @mbox = File.basename(mbox, '.yml')
 
diff --git a/views/app.js.rb b/views/app.js.rb
index 5d99b56..45d3bc1 100644
--- a/views/app.js.rb
+++ b/views/app.js.rb
@@ -1 +1,2 @@
+require_relative 'index'
 require_relative 'parts'
diff --git a/views/index.html.rb b/views/index.html.rb
index de874a7..fc6f73c 100644
--- a/views/index.html.rb
+++ b/views/index.html.rb
@@ -6,30 +6,11 @@
     }
   }
 
-  _table do
-    _thead do
-      _tr do
-        _th 'Timestamp'
-        _th 'From'
-        _th 'Subject'
-      end
-    end
-
-    _tbody do
-      @messages.each do |id, description|
+  _div.index!
 
-	# skip if there are no attachments at all
-	next unless description[:attachments]
-
-	_tr_ do
-	  _td! do
-	    _a description[:time], href: "#{description[:source]}/#{id}/"
-	  end 
-	  _td description[:name]
-	  _td description['Subject']
-	end
-      end
-    end
+  _script src: 'app.js'
+  _.render '#index' do
+    _Index messages: @messages
   end
 
   _input_.btn.btn_primary type: 'submit', value: 'fetch previous month'