History

Refactoring

Jasper van Merle committed 7 years ago

Commit 35dd78f1 parent 7af10a03 files · +8 −8Browse files

Unified · Split

3 files
  1. README.md +1 −1
  2. lib/app.rb +5 −4
  3. views/service-worker.js.erb +2 −3
README.md+1−1
@@ -59,7 +59,7 @@ The web app is all client-side JavaScript, written in [CoffeeScript](http://coff · 58 unmodified lines
59 59
60Many 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.60Many 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.
61 61
62Another 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.62Another 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.
63 63
64DevDocs being a developer tool, the browser requirements are high:64DevDocs being a developer tool, the browser requirements are high:
65 65
lib/app.rb+5−4
@@ -192,16 +192,17 @@ class App < Sinatra::Application · 191 unmodified lines
192 request.query_string.empty? ? nil : "?#{request.query_string}"192 request.query_string.empty? ? nil : "?#{request.query_string}"
193 end193 end
194 194
195 def manifest_asset_urls195 def service_worker_asset_urls
196 @@manifest_asset_urls ||= [196 @@service_worker_asset_urls ||= [
197 javascript_path('application', asset_host: false),197 javascript_path('application', asset_host: false),
198 stylesheet_path('application'),198 stylesheet_path('application'),
199 image_path('docs-1.png'),199 image_path('docs-1.png'),
200 image_path('docs-1@2x.png'),200 image_path('docs-1@2x.png'),
201 image_path('docs-2.png'),201 image_path('docs-2.png'),
202 image_path('docs-2@2x.png'),202 image_path('docs-2@2x.png'),
203 asset_path('docs.js')203 asset_path('docs.js'),
204 ]204 App.production? ? nil : javascript_path('debug'),
205 ].compact
205 end206 end
206 207
207 def app_size208 def app_size
views/service-worker.js.erb+2−3
@@ -13,9 +13,8 @@ const cachePaths = [ · 12 unmodified lines
13 '/images/webapp-icon-128.png',13 '/images/webapp-icon-128.png',
14 '/images/webapp-icon-256.png',14 '/images/webapp-icon-256.png',
15 '/images/webapp-icon-512.png',15 '/images/webapp-icon-512.png',
16 '<%= manifest_asset_urls.join "',\n '" %>',16 '<%= service_worker_asset_urls.join "',\n '" %>',
17 '<%= doc_index_urls.join "',\n '" %>',<% unless App.production? %>17 '<%= doc_index_urls.join "',\n '" %>',
18 '<%= javascript_path('debug') %>',<% end %>
19];18];
20 19
21<%# Set-up the cache %>20<%# Set-up the cache %>