[devdocsgjs/main: 682/1867] Fix merge conflicts




commit 8a71af9c2f206756304e740e8484ce135f871916
Merge: e2063f32 0f9ff40c
Author: Jasper van Merle <jaspervmerle gmail com>
Date:   Sat Jul 20 03:15:20 2019 +0200

    Fix merge conflicts

 .gitignore                                         |   1 +
 .travis.yml                                        |   8 ++
 Dockerfile                                         |   1 +
 Dockerfile-alpine                                  |   1 +
 README.md                                          |  10 +--
 assets/javascripts/app/app.coffee                  |  21 ++++--
 assets/javascripts/app/appcache.coffee             |  42 -----------
 assets/javascripts/app/config.coffee.erb           |   2 +
 assets/javascripts/app/serviceworker.coffee        |  49 +++++++++++++
 assets/javascripts/app/settings.coffee             |  33 +++++++++
 assets/javascripts/app/update_checker.coffee       |   6 +-
 assets/javascripts/lib/page.coffee                 |  18 ++++-
 assets/javascripts/lib/util.coffee                 |   4 +
 assets/javascripts/models/doc.coffee               |   4 +-
 assets/javascripts/news.json                       |   4 +
 assets/javascripts/templates/error_tmpl.coffee     |  10 +--
 assets/javascripts/templates/notif_tmpl.coffee     |   6 ++
 .../javascripts/templates/pages/about_tmpl.coffee  |   3 +-
 .../templates/pages/offline_tmpl.coffee            |  13 +++-
 .../templates/pages/root_tmpl.coffee.erb           |   4 +-
 .../templates/pages/settings_tmpl.coffee           |   8 ++
 assets/javascripts/tracking.js                     |  50 +++++++------
 assets/javascripts/views/content/entry_page.coffee |   2 +-
 .../javascripts/views/content/settings_page.coffee |  21 +++---
 assets/javascripts/views/layout/document.coffee    |  12 +--
 assets/javascripts/views/layout/resizer.coffee     |  11 +--
 assets/javascripts/views/layout/settings.coffee    |  10 +--
 assets/javascripts/views/search/search.coffee      |   8 ++
 .../javascripts/views/search/search_scope.coffee   |  28 +++++--
 assets/javascripts/views/sidebar/sidebar.coffee    |   2 +-
 assets/stylesheets/components/_header.scss         |   1 +
 assets/stylesheets/components/_notif.scss          |   4 +
 docs/maintainers.md                                |   9 +--
 lib/app.rb                                         |  55 +++++++++-----
 lib/docs/core/scrapers/file_scraper.rb             |   4 +-
 public/docs/docs.json                              |   1 -
 public/images/webapp-icon-192.png                  | Bin 0 -> 32187 bytes
 public/manifest.json                               |   6 ++
 test/app_test.rb                                   |  81 ---------------------
 test/lib/docs/core/scrapers/file_scraper_test.rb   |   4 +-
 views/app.erb                                      |  14 +---
 views/index.erb                                    |   5 +-
 views/manifest.erb                                 |  14 ----
 views/other.erb                                    |   5 +-
 views/service-worker.js.erb                        |  49 +++++++++++++
 views/unsupported.erb                              |   6 +-
 46 files changed, 369 insertions(+), 281 deletions(-)
---
diff --cc lib/app.rb
index cc2ba434,f86ab109..a1ace892
--- a/lib/app.rb
+++ b/lib/app.rb
@@@ -197,33 -195,47 +200,45 @@@ class App < Sinatra::Applicatio
        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'),
 +        image_path('sprites/docs.png'),
 +        image_path('sprites/docs 2x png'),
-         asset_path('docs.js')
-       ]
+         asset_path('docs.js'),
+         App.production? ? nil : javascript_path('debug'),
+       ].compact
      end
  
-     def app_size
-       @app_size ||= memoized_cookies['size'].nil? ? '20rem' : "#{memoized_cookies['size']}px"
-     end
+     # Returns a cache name for the service worker to use which changes if any of the assets changes
+     # When a manifest exist, this name is only created once based on the asset manifest because it never 
changes without a server restart
+     # If a manifest does not exist, it is created every time this method is called because the assets can 
change while the server is running
+     def service_worker_cache_name
+       if File.exist?(App.assets_manifest_path)
+         if defined?(@@service_worker_cache_name)
+           return @@service_worker_cache_name
+         end
  
-     def app_layout
-       memoized_cookies['layout']
-     end
+         digest = Sprockets::Manifest
+                    .new(nil, App.assets_manifest_path)
+                    .files
+                    .values
+                    .map {|file| file["digest"]}
+                    .join
  
-     def app_theme
-       @app_theme ||= memoized_cookies['dark'].nil? ? 'default' : 'dark'
-     end
+         return @@service_worker_cache_name ||= Digest::MD5.hexdigest(digest)
+       else
+         paths = App.sprockets
+                   .each_file
+                   .to_a
+                   .reject {|file| file.start_with?(App.docs_path)}
  
-     def dark_theme?
-       app_theme == 'dark'
+         return App.sprockets.pack_hexdigest(App.sprockets.files_digest(paths))
+       end
      end
  
-     def redirect_via_js(path) # courtesy of HTML5 App Cache
+     def redirect_via_js(path)
        response.set_cookie :initial_path, value: path, expires: Time.now + 15, path: '/'
        redirect '/', 302
      end


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]