Refactoring

pull/1022/head
Jasper van Merle 6 years ago
parent 7af10a020d
commit 35dd78f191

@ -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. 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: DevDocs being a developer tool, the browser requirements are high:

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

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

Loading…
Cancel
Save