Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabled pwa feature #288

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<link
href="https://fonts.googleapis.com/css2?family=Montserrat+Alternates:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
rel="stylesheet">
<link rel="manifest" href="/manifest.json">
</head>

<body id="body">
Expand Down Expand Up @@ -300,6 +301,7 @@
<div class="end_line"></div>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="website/scripts/script.js"></script>
<script src="script.js"></script>


</body>
Expand Down
21 changes: 21 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Dataverse",
"short_name": "App",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#000000",
"icons": [
{
"src": "/software/images/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/software/images/icon-192x192.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

11 changes: 11 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(registration => {
console.log('ServiceWorker registration successful:', registration);
})
.catch(error => {
console.error('ServiceWorker registration failed:', error);
});
});
}
Binary file added software/images/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added software/images/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

const CACHE_NAME = 'my-app-cache-v1';
const urlsToCache = [
'/index.html',
'/website/pages/license.html',
'/website/pages/license.html',
'/website/pages/contributor.html',
'/website/styles/style.css',
'/website/styles/contributor.css',
'/script.js',
'/software/images/icon-192x192.png',
'/software/images/icon-512x512.png'
];

self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
return cache.addAll(urlsToCache);
})
);
});

self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => {
return response || fetch(event.request);
})
);
});