whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: display cache pages
Date Mon, 25 Jul 2016 20:40:20 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  3248bee   display cache pages
3248bee is described below

commit 3248bee9c47bf6024ed33abb536b05a74749ae50
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Mon Jul 25 16:39:58 2016 -0400

    display cache pages
---
 www/board/agenda/views/elements/link.js.rb |  2 +-
 www/board/agenda/views/keyboard.js.rb      |  2 +-
 www/board/agenda/views/pages/cache.js.rb   | 42 +++++++++++++++++++++++++++++-
 www/board/agenda/views/router.js.rb        |  5 +++-
 4 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/www/board/agenda/views/elements/link.js.rb b/www/board/agenda/views/elements/link.js.rb
index e06398b..96a8db9 100644
--- a/www/board/agenda/views/elements/link.js.rb
+++ b/www/board/agenda/views/elements/link.js.rb
@@ -38,7 +38,7 @@ class Link < React
 
     href = event.target.getAttribute('href')
 
-    if href =~ %r{^(\.|(flagged/|(shepherd/)?(queue/)?)[-\w]+)$}
+    if href =~ %r{^(\.|cache/.*|(flagged/|(shepherd/)?(queue/)?)[-\w]+)$}
       event.stopPropagation()
       event.preventDefault()
       Main.navigate href
diff --git a/www/board/agenda/views/keyboard.js.rb b/www/board/agenda/views/keyboard.js.rb
index 4e8e096..fd80093 100644
--- a/www/board/agenda/views/keyboard.js.rb
+++ b/www/board/agenda/views/keyboard.js.rb
@@ -86,7 +86,7 @@ class Keyboard
         end
         return false
       elsif event.keyCode == '='.ord
-        Main.navigate "cache"
+        Main.navigate "cache/"
         return false
       end
     end
diff --git a/www/board/agenda/views/pages/cache.js.rb b/www/board/agenda/views/pages/cache.js.rb
index 4ddf95e..bf540f0 100644
--- a/www/board/agenda/views/pages/cache.js.rb
+++ b/www/board/agenda/views/pages/cache.js.rb
@@ -23,7 +23,10 @@ class CacheStatus < React
       _p 'empty'
     else
       _ul @cache do |item|
-        _li item
+        basename = item.split('/').pop()
+        basename = 'index.html' if basename == ''
+        basename = item.split('/')[-2] + '.html' if basename == 'bootstrap.html'
+        _li {_Link text: item, href: "cache/#{basename}"}
       end
     end
 
@@ -81,3 +84,40 @@ class CacheStatus < React
     end
   end
 end
+
+#
+# Individual Cache page
+#
+
+class CachePage < React
+  def initialize
+    @response = {}
+    @text = ''
+  end
+
+  def render
+    _h2 @response.url
+    _p "#{@response.status} #{@response.statusText}"
+    _pre @text
+  end
+
+  # update on first update
+  def componentDidMount()
+    if defined? caches
+      basename = location.href.split('/').pop()
+      basename = '' if basename == 'index.html'
+      basename = 'bootstrap.html' if basename =~ /^\d+-\d+-\d+\.html$/
+
+      caches.open('board/agenda').then do |cache|
+        cache.matchAll().then do |responses|
+          responses.each do |response| 
+            if response.url.split('/').pop() == basename
+              @response = response
+              response.text().then {|text| @text = text}
+            end
+          end
+        end
+      end
+    end
+  end
+end
diff --git a/www/board/agenda/views/router.js.rb b/www/board/agenda/views/router.js.rb
index 0564b5f..4e1c28f 100644
--- a/www/board/agenda/views/router.js.rb
+++ b/www/board/agenda/views/router.js.rb
@@ -75,9 +75,12 @@ class Router
     elsif path == 'help'
       item = {view: Help}
 
-    elsif path == 'cache'
+    elsif path == 'cache/'
       item = {view: CacheStatus}
 
+    elsif path =~ %r{^cache/}
+      item = {view: CachePage}
+
     else
       item = Agenda.find(path)
     end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message