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

Added the ability to use the service without the Internet #44

Open
wants to merge 3 commits into
base: master
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
7 changes: 5 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ const translates = [
// TEMPLATES
const tmplTasks = translates.map(({ dest, url }) => {
return (done) => {
gulp.src(`./src/index-src.html`)
gulp.src([
'./src/index.html',
'./src/manifest.json',
'./src/pwabuilder-sw.js'
])
.pipe(mustache(url))
.pipe(rename(`index.html`))
.pipe(gulp.dest(dest))
.pipe(reload({ stream: true }));
done();
Expand Down
8 changes: 7 additions & 1 deletion src/index-src.html → src/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html>
<head>
<title>{{title}}</title>
<link rel="manifest" href="./manifest.json">
<link rel="stylesheet" href="{{path}}/assets/css/styles.css">
</head>
<body>
Expand Down Expand Up @@ -144,7 +145,12 @@ <h4>{{preview}}:</h4>

</div>
<script src="{{path}}/assets/js/script.js"></script>

<script type="module">
import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';

const el = document.createElement('pwa-update');
document.body.appendChild(el);
</script>
<!-- Yandex.Metrika counter --> <script type="text/javascript" > (function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter49839931 = new Ya.Metrika2({ id:49839931, clickmap:true, trackLinks:true, accurateTrackBounce:true }); } catch(e) { } }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = "https://mc.yandex.ru/metrika/tag.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f, false); } else { f(); } })(document, window, "yandex_metrika_callbacks2"); </script> <noscript><div><img src="https://mc.yandex.ru/watch/49839931" style="position:absolute; left:-9999px;" alt="" /></div></noscript> <!-- /Yandex.Metrika counter -->
</body>
</html>
13 changes: 13 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"dir": "auto",
"display": "browser",
"name": "URL-encoder for SVG",
"short_name": "URL-encoder for SVG",
"scope": "/url-encoder/",
"lang": "ru",
"description": "URL-encoder for SVG",
"theme_color": "none",
"background_color": "none",
"дисплей": "browser",
"цвет_темы": "none"
}
18 changes: 18 additions & 0 deletions src/pwabuilder-sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This is the "Offline copy of assets" service worker

const CACHE = "pwabuilder-offline";

importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');

self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});

workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: CACHE
})
);