From f0cd957c7a8a53dea2eb08a45578084b4d8bb5b4 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Sat, 17 Mar 2018 20:35:13 +0900 Subject: Cache HTML page with Service Worker (#6802) This is the first step to make Mastodon work offline. It is also required by Chromium to trigger Web Manifest automated install prompt. --- app/javascript/mastodon/service_worker/entry.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/mastodon/service_worker/entry.js b/app/javascript/mastodon/service_worker/entry.js index eea4cfc3c..ad933b95e 100644 --- a/app/javascript/mastodon/service_worker/entry.js +++ b/app/javascript/mastodon/service_worker/entry.js @@ -1,10 +1,30 @@ import './web_push_notifications'; +function fetchRoot() { + return fetch('/', { credentials: 'include' }); +} + // Cause a new version of a registered Service Worker to replace an existing one // that is already installed, and replace the currently active worker on open pages. self.addEventListener('install', function(event) { - event.waitUntil(self.skipWaiting()); + const promises = Promise.all([caches.open('mastodon-web'), fetchRoot()]); + const asyncAdd = promises.then(([cache, root]) => cache.put('/', root)); + + event.waitUntil(asyncAdd); }); self.addEventListener('activate', function(event) { event.waitUntil(self.clients.claim()); }); +self.addEventListener('fetch', function(event) { + const url = new URL(event.request.url); + + if (url.pathname.startsWith('/web/')) { + event.respondWith(fetchRoot().then(response => { + if (response.ok) { + return response; + } + + throw null; + }).catch(() => caches.match('/'))); + } +}); -- cgit From ca7e6a6d2ec2310fd026f2694580f839b4124dd2 Mon Sep 17 00:00:00 2001 From: trwnh Date: Sat, 17 Mar 2018 06:35:35 -0500 Subject: Properly center .nothing-here (#6787) (#6788) Apply "margin: 0 auto;" at line 443 to fix issue #6787 --- app/javascript/styles/mastodon/accounts.scss | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/javascript/styles/mastodon/accounts.scss b/app/javascript/styles/mastodon/accounts.scss index 873963c90..dd82ab375 100644 --- a/app/javascript/styles/mastodon/accounts.scss +++ b/app/javascript/styles/mastodon/accounts.scss @@ -440,6 +440,7 @@ text-align: center; padding: 60px 0; padding-top: 55px; + margin: 0 auto; cursor: default; } -- cgit From 4a0a19fe54f1d2d433ad3d72c35f2bbb915279f6 Mon Sep 17 00:00:00 2001 From: Daniel Hunsaker Date: Sat, 17 Mar 2018 06:27:50 -0600 Subject: Handle Mastodon::HostValidationError when pulling remoteable assets (#6782) This will prevent, for example, `rake mastodon:redownload_avatars` from crashing when an instance is no longer responding to connection attempts, instead silently continuing as expected. --- app/models/concerns/remotable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/concerns/remotable.rb b/app/models/concerns/remotable.rb index 020303a2f..69685ec83 100644 --- a/app/models/concerns/remotable.rb +++ b/app/models/concerns/remotable.rb @@ -38,7 +38,7 @@ module Remotable send("#{attachment_name}_file_name=", basename + extname) self[attribute_name] = url if has_attribute?(attribute_name) - rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError => e + rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError => e Rails.logger.debug "Error fetching remote #{attachment_name}: #{e}" nil end -- cgit From 566ace2d6479c05e51dd8ce24283b8606be631de Mon Sep 17 00:00:00 2001 From: nightpool Date: Sat, 17 Mar 2018 12:39:28 -0400 Subject: Add entropy to download filenames (#6811) pretty quick fix, and with the 1 week expiration i don't think we need to be too worried about the existing files closes #6798 --- app/services/backup_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/backup_service.rb b/app/services/backup_service.rb index fadc24a82..8492c1117 100644 --- a/app/services/backup_service.rb +++ b/app/services/backup_service.rb @@ -49,7 +49,7 @@ class BackupService < BaseService end end - archive_filename = ['archive', Time.now.utc.strftime('%Y%m%d%H%M%S'), SecureRandom.hex(2)].join('-') + '.tar.gz' + archive_filename = ['archive', Time.now.utc.strftime('%Y%m%d%H%M%S'), SecureRandom.hex(16)].join('-') + '.tar.gz' @backup.dump = ActionDispatch::Http::UploadedFile.new(tempfile: tmp_file, filename: archive_filename) @backup.processed = true -- cgit