mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-11-02 16:37:19 -04:00
Fix path service worker is served from
This commit is contained in:
parent
3bbe859227
commit
5d848715da
@ -222,8 +222,8 @@
|
||||
} else {
|
||||
|
||||
//Register the ServiceWorker
|
||||
navigator.serviceWorker.register('{% static "js/pwabuilder-sw.js" %}', {
|
||||
scope: '{% url 'home' %}'
|
||||
navigator.serviceWorker.register('pwabuilder-sw.js', {
|
||||
scope: '{% url '' %}'
|
||||
}).then(function(reg) {
|
||||
console.log('Service worker has been registered for scope:'+ reg.scope);
|
||||
});
|
||||
|
@ -1,8 +1,9 @@
|
||||
//This is the "Offline page" service worker
|
||||
{% load static %}
|
||||
|
||||
//Install stage sets up the offline page in the cache and opens a new cache
|
||||
self.addEventListener('install', function(event) {
|
||||
var offlinePage = new Request('offline.html');
|
||||
var offlinePage = new Request('{% static "offline.html" %}');
|
||||
event.waitUntil(
|
||||
fetch(offlinePage).then(function(response) {
|
||||
return caches.open('pwabuilder-offline').then(function(cache) {
|
||||
@ -19,7 +20,7 @@ self.addEventListener('fetch', function(event) {
|
||||
fetch(event.request).catch(function(error) {
|
||||
console.error( '[PWA Builder] Network request Failed. Serving offline page ' + error );
|
||||
return caches.open('pwabuilder-offline').then(function(cache) {
|
||||
return cache.match('/static/offline.html');
|
||||
return cache.match('{% static "offline.html" %}');
|
||||
});
|
||||
}
|
||||
));
|
@ -57,5 +57,6 @@ urlpatterns = [
|
||||
path('search', views.search, name='search'),
|
||||
path('search_results', views.search_results, name='search_results'),
|
||||
path('emoji', views.emoji_reference, name='emoji'),
|
||||
path('', views.home),
|
||||
path('pwabuilder-sw.js', views.service_worker, name="sw"),
|
||||
path('', views.home, name=''),
|
||||
]
|
||||
|
@ -782,3 +782,6 @@ def emoji_reference(request):
|
||||
{"preferences": account.preferences,
|
||||
"emojos": sorted(emojos, key=lambda x: x['shortcode']),
|
||||
'own_acct' : request.session['user']})
|
||||
|
||||
def service_worker(request):
|
||||
return render(request, 'pwabuilder-sw.js', content_type="application/javascript")
|
||||
|
Loading…
Reference in New Issue
Block a user