You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2016/07/31 13:36:25 UTC
[whimsy] 02/02: no longer prefetch stylesheets and scripts
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
commit 1b8fff94446c3288377ed61d67e1834dc0946f59
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Jul 31 09:36:05 2016 -0400
no longer prefetch stylesheets and scripts
---
www/board/agenda/views/models/pagecache.js.rb | 28 +--------------------------
www/board/agenda/views/sw.js.rb | 12 ------------
2 files changed, 1 insertion(+), 39 deletions(-)
diff --git a/www/board/agenda/views/models/pagecache.js.rb b/www/board/agenda/views/models/pagecache.js.rb
index 551b326..68f6dc7 100644
--- a/www/board/agenda/views/models/pagecache.js.rb
+++ b/www/board/agenda/views/models/pagecache.js.rb
@@ -39,42 +39,16 @@ class PageCache
end
end
- # fetch and cache page and referenced scripts and stylesheets
+ # add/update bootstrap.html in the cache
def self.preload()
return unless PageCache.enabled?
- base = document.getElementsByTagName('base')[0].href
request = Request.new('bootstrap.html', credentials: 'include')
fetch(request).then do |response|
response.clone().text().then do |text|
- urls = []
-
- # search body text for scripts
- script = Regexp.new(/<script.*?>/, 'g')
- matches = text.match(script)
- matches.each do |match|
- src = match.match(/src="(.*?)"/)
- urls << URL.new(src[1], base) if src
- end
-
- # search body text for links to stylesheets
- links = Regexp.new(/<link.*?>/, 'g')
- matches = text.match(links)
- matches.each do |match|
- href = match.match(/href="(.*?)"/)
- urls << URL.new(href[1], base) if href
- end
-
- # add bootstrap.html and each URL to the cache.
caches.open('board/agenda').then do |cache|
- agenda = Agenda.file[/\d+_\d+_\d+/].gsub('_', '-')
cache.put(request, response)
-
- urls.each do |url|
- request2 = Request.new(url, credentials: 'include')
- fetch(request2).then {|response| cache.put(request2, response)}
- end
end
end
end
diff --git a/www/board/agenda/views/sw.js.rb b/www/board/agenda/views/sw.js.rb
index 12bac7b..d8876c7 100644
--- a/www/board/agenda/views/sw.js.rb
+++ b/www/board/agenda/views/sw.js.rb
@@ -6,8 +6,6 @@
# 2) Return back cached bootstrap page instead of fetching agenda pages
# from the network. Bootstrap will construct page from cached
# agenda.json, as well as update the cache.
-#
-# 3) For all other pages, serve cached content when offline
#
events = nil
@@ -49,15 +47,5 @@ self.addEventListener :fetch do |event|
end
end
)
- elsif false #disable for now
- event.respondWith(
- fetch(event.request, credentials: 'include').catch do |error|
- return caches.open('board/agenda').then do |cache|
- return cache.match(event.request) do |response|
- return response || error
- end
- end
- end
- )
end
end
--
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.