This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new ebf4994 start to rough in a 'latest' path where the client
optimistically shows the latest agenda.
ebf4994 is described below
commit ebf49942f820c572a5c1d66ca3bac6c3c339b54a
Author: Sam Ruby <[email protected]>
AuthorDate: Mon Jun 4 20:40:55 2018 -0400
start to rough in a 'latest' path where the client optimistically
shows the latest agenda.
---
www/board/agenda/routes.rb | 9 +++++++++
www/board/agenda/views/layout/main.js.rb | 6 +++++-
www/board/agenda/views/sw.js.rb | 33 ++++++++++++++++++++++++++++++--
3 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index c5828e9..9e663dd 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -9,6 +9,15 @@ get '/' do
redirect "#{request.path}#{agenda[/\d+_\d+_\d+/].gsub('_', '-')}/"
end
+# alias for latest agenda
+get '/latest/' do
+ agenda = dir('board_agenda_*.txt').sort.last
+ pass unless agenda
+ call env.merge(
+ 'PATH_INFO' => "/#{agenda[/\d+_\d+_\d+/].gsub('_', '-')}/"
+ )
+end
+
# redirect shepherd to latest agenda
get '/shepherd' do
user=ASF::Person.find(env.user).public_name.split(' ').first
diff --git a/www/board/agenda/views/layout/main.js.rb
b/www/board/agenda/views/layout/main.js.rb
index f3585ea..d63c636 100644
--- a/www/board/agenda/views/layout/main.js.rb
+++ b/www/board/agenda/views/layout/main.js.rb
@@ -108,7 +108,11 @@ class Main < Vue
if path == 'bootstrap.html'
path = document.location.href
base = document.getElementsByTagName('base')[0].href
- path = path.slice(base.length) if path.start_with? base
+ if path.start_with? base
+ path = path.slice(base.length)
+ elsif path.end_with? '/latest/'
+ path = '.'
+ end
end
history.replaceState({path: path}, nil, path)
diff --git a/www/board/agenda/views/sw.js.rb b/www/board/agenda/views/sw.js.rb
index 896d34f..edd1582 100644
--- a/www/board/agenda/views/sw.js.rb
+++ b/www/board/agenda/views/sw.js.rb
@@ -99,6 +99,31 @@ def fetch_from_cache(event)
end
end
+# Return latest bootstrap page from the cache
+def latest(event)
+ return Promise.new do |fulfill, reject|
+ caches.open('board/agenda').then do |cache|
+ cache.matchAll().then do |responses|
+ match = nil
+ responses.each do |response|
+ if response.url.end_with? '/bootstrap.html'
+ match = response if not match or match.url < response.url
+ end
+ end
+
+ if match
+ fulfill(match)
+
+ request = Request.new(match.url, cache: "no-store")
+ fetch(request).then {|response| cache.put request, response}
+ else
+ fetch(event.request).then(fulfill, reject)
+ end
+ end
+ end
+ end
+end
+
# Return a bootstrap.html page within 0.5 seconds. If the network responds
# in time, go with that response, otherwise respond with a cached version.
def bootstrap(event, request)
@@ -164,8 +189,6 @@ self.addEventListener :fetch do |event|
url = url.slice(scope.length) if url.start_with? scope
if event.request.method == 'GET'
- return if url.end_with? '/bootstrap.html'
-
# determine what url to fetch (if any)
if url.end_with? '/bootstrap.html'
return
@@ -182,6 +205,12 @@ self.addEventListener :fetch do |event|
elsif url =~ %r{\.(js|css)\?\d+$}
# cache and respond to js and css requests
event.respondWith(fetch_from_cache(event))
+
+ elsif url == ''
+ # event.respondWith(Response.redirect('latest/'))
+
+ elsif url == 'latest/'
+ event.respondWith(latest(event))
end
end
end
--
To stop receiving notification emails like this one, please contact
[email protected].