Jasper van Merle 6 rokov pred
rodič
commit
35dd78f191
3 zmenil súbory, kde vykonal 8 pridanie a 8 odobranie
  1. 1 1
      README.md
  2. 5 4
      lib/app.rb
  3. 2 3
      views/service-worker.js.erb

+ 1 - 1
README.md

@@ -59,7 +59,7 @@ The web app is all client-side JavaScript, written in [CoffeeScript](http://coff
 
 Many of the code's design decisions were driven by the fact that the app uses XHR to load content directly into the main frame. This includes stripping the original documents of most of their HTML markup (e.g. scripts and stylesheets) to avoid polluting the main frame, and prefixing all CSS class names with an underscore to prevent conflicts.
 
-Another driving factor is performance and the fact that everything happens in the browser. `applicationCache` (which comes with its own set of constraints) and `localStorage` are used to speed up the boot time, while memory consumption is kept in check by allowing the user to pick his/her own set of documentations. The search algorithm is kept simple because it needs to be fast even searching through 100,000 strings.
+Another driving factor is performance and the fact that everything happens in the browser. A service worker (which comes with its own set of constraints) and `localStorage` are used to speed up the boot time, while memory consumption is kept in check by allowing the user to pick his/her own set of documentations. The search algorithm is kept simple because it needs to be fast even searching through 100,000 strings.
 
 DevDocs being a developer tool, the browser requirements are high:
 

+ 5 - 4
lib/app.rb

@@ -192,16 +192,17 @@ class App < Sinatra::Application
       request.query_string.empty? ? nil : "?#{request.query_string}"
     end
 
-    def manifest_asset_urls
-      @@manifest_asset_urls ||= [
+    def service_worker_asset_urls
+      @@service_worker_asset_urls ||= [
         javascript_path('application', asset_host: false),
         stylesheet_path('application'),
         image_path('docs-1.png'),
         image_path('docs-1@2x.png'),
         image_path('docs-2.png'),
         image_path('docs-2@2x.png'),
-        asset_path('docs.js')
-      ]
+        asset_path('docs.js'),
+        App.production? ? nil : javascript_path('debug'),
+      ].compact
     end
 
     def app_size

+ 2 - 3
views/service-worker.js.erb

@@ -13,9 +13,8 @@ const cachePaths = [
   '/images/webapp-icon-128.png',
   '/images/webapp-icon-256.png',
   '/images/webapp-icon-512.png',
-  '<%= manifest_asset_urls.join "',\n  '" %>',
-  '<%= doc_index_urls.join "',\n  '" %>',<% unless App.production? %>
-  '<%= javascript_path('debug') %>',<% end %>
+  '<%= service_worker_asset_urls.join "',\n  '" %>',
+  '<%= doc_index_urls.join "',\n  '" %>',
 ];
 
 <%# Set-up the cache %>