aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2020-07-16 15:32:30 -0400
committerGitHub <noreply@github.com>2020-07-16 15:32:30 -0400
commit385d25c9f96c0acd5d932488e3bd0ed36ceb4dd7 (patch)
treeaf789f7250519b23038a7e5ea0ae7f4f4c1ffdfc /static
parent449e934246c82d90dd0aac2644d67f928befeeb4 (diff)
downloadxesite-385d25c9f96c0acd5d932488e3bd0ed36ceb4dd7.tar.xz
xesite-385d25c9f96c0acd5d932488e3bd0ed36ceb4dd7.zip
Rewrite site backend in Rust (#178)
* add shell.nix changes for Rust #176 * set up base crate layout * add first set of dependencies * start adding basic app modules * start html templates * serve index page * add contact and feeds pages * add resume rendering support * resume cleanups * get signalboost page working * rewrite config to be in dhall * more work * basic generic post loading * more tests * initial blog index support * fix routing? * render blogposts * X-Clacks-Overhead * split blog handlers into blog.rs * gallery index * gallery posts * fix hashtags * remove instantpage (it messes up the metrics) * talk support + prometheus * Create rust.yml * Update rust.yml * Update codeql-analysis.yml * add jsonfeed library * jsonfeed support * rss/atom * go mod tidy * atom: add posted date * rss: add publishing date * nix: build rust program * rip out go code * rip out go templates * prepare for serving in docker * create kubernetes deployment * create automagic deployment * build docker images on non-master * more fixes * fix timestamps * fix RSS/Atom/JSONFeed validation errors * add go vanity import redirecting * templates/header: remove this * atom feed: fixes * fix? * fix?? * fix rust tests * Update rust.yml * automatically show snow during the winter * fix dates * show commit link in footer * sitemap support * fix compiler warning * start basic patreon client * integrate kankyo * fix patreon client * add patrons page * remove this * handle patron errors better * fix build * clean up deploy * sort envvars for deploy * remove deps.nix * shell.nix: remove go * update README * fix envvars for tests * nice * blog: add rewrite in rust post * blog/site-update: more words
Diffstat (limited to 'static')
-rw-r--r--static/js/installsw.js7
-rw-r--r--static/js/instantpage-3.0.0.js2
-rwxr-xr-xstatic/js/sw.js46
3 files changed, 30 insertions, 25 deletions
diff --git a/static/js/installsw.js b/static/js/installsw.js
new file mode 100644
index 0000000..76c43f9
--- /dev/null
+++ b/static/js/installsw.js
@@ -0,0 +1,7 @@
+if (navigator.serviceWorker.controller) {
+ console.log("Active service worker found, no need to register");
+} else {
+ navigator.serviceWorker.register("/sw.js").then(function(reg) {
+ console.log("Service worker has been registered for scope:" + reg.scope);
+ });
+}
diff --git a/static/js/instantpage-3.0.0.js b/static/js/instantpage-3.0.0.js
deleted file mode 100644
index 0a67c12..0000000
--- a/static/js/instantpage-3.0.0.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! instant.page v3.0.0 - (C) 2019 Alexandre Dieulot - https://instant.page/license */
-let t,e;const n=new Set,o=document.createElement("link"),s=o.relList&&o.relList.supports&&o.relList.supports("prefetch")&&window.IntersectionObserver&&"isIntersecting"in IntersectionObserverEntry.prototype,i="instantAllowQueryString"in document.body.dataset,r="instantAllowExternalLinks"in document.body.dataset,a="instantWhitelist"in document.body.dataset;let c=65,d=!1,l=!1,u=!1;if("instantIntensity"in document.body.dataset){const t=document.body.dataset.instantIntensity;if("mousedown"==t.substr(0,"mousedown".length))d=!0,"mousedown-only"==t&&(l=!0);else if("viewport"==t.substr(0,"viewport".length))navigator.connection&&(navigator.connection.saveData||navigator.connection.effectiveType.includes("2g"))||("viewport"==t?document.documentElement.clientWidth*document.documentElement.clientHeight<45e4&&(u=!0):"viewport-all"==t&&(u=!0));else{const e=parseInt(t);isNaN(e)||(c=e)}}if(s){const n={capture:!0,passive:!0};if(l||document.addEventListener("touchstart",function(t){e=performance.now();const n=t.target.closest("a");if(!f(n))return;h(n.href)},n),d?document.addEventListener("mousedown",function(t){const e=t.target.closest("a");if(!f(e))return;h(e.href)},n):document.addEventListener("mouseover",function(n){if(performance.now()-e<1100)return;const o=n.target.closest("a");if(!f(o))return;o.addEventListener("mouseout",m,{passive:!0}),t=setTimeout(()=>{h(o.href),t=void 0},c)},n),u){let t;(t=window.requestIdleCallback?t=>{requestIdleCallback(t,{timeout:1500})}:t=>{t()})(()=>{const t=new IntersectionObserver(e=>{e.forEach(e=>{if(e.isIntersecting){const n=e.target;t.unobserve(n),h(n.href)}})});document.querySelectorAll("a").forEach(e=>{f(e)&&t.observe(e)})})}}function m(e){e.relatedTarget&&e.target.closest("a")==e.relatedTarget.closest("a")||t&&(clearTimeout(t),t=void 0)}function f(t){if(t&&t.href&&(!a||"instant"in t.dataset)&&(r||t.origin==location.origin||"instant"in t.dataset)&&["http:","https:"].includes(t.protocol)&&("http:"!=t.protocol||"https:"!=location.protocol)&&(i||!t.search||"instant"in t.dataset)&&!(t.hash&&t.pathname+t.search==location.pathname+location.search||"noInstant"in t.dataset))return!0}function h(t){if(n.has(t))return;const e=document.createElement("link");e.rel="prefetch",e.href=t,document.head.appendChild(e),n.add(t)}
diff --git a/static/js/sw.js b/static/js/sw.js
index 0fa1e3e..5e2c921 100755
--- a/static/js/sw.js
+++ b/static/js/sw.js
@@ -5,37 +5,37 @@ self.addEventListener('install', function(event) {
event.waitUntil(preLoad());
});
-const cacheName = "cache-2019-11-01";
+const cacheName = "cache-xesite-2.0.0";
var preLoad = function(){
- console.log('[PWA Builder] Install Event processing');
- return caches.open(cacheName).then(function(cache) {
- console.log('[PWA Builder] Cached index and offline page during Install');
- return cache.addAll(['/blog/', '/blog', '/', '/contact', '/resume', '/talks', '/gallery']);
- });
+ console.log('[PWA Builder] Install Event processing');
+ return caches.open(cacheName).then(function(cache) {
+ console.log('[PWA Builder] Cached index and offline page during Install');
+ return cache.addAll(['/blog/', '/blog', '/', '/contact', '/resume', '/talks', '/gallery', '/signalboost']);
+ });
};
self.addEventListener('fetch', function(event) {
- if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') {
- return;
- }
- console.log('[PWA Builder] The service worker is serving the asset.');
- event.respondWith(checkResponse(event.request).catch(function() {
- return returnFromCache(event.request);
- }));
- event.waitUntil(addToCache(event.request));
+ if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin') {
+ return;
+ }
+ console.log('[PWA Builder] The service worker is serving the asset.');
+ event.respondWith(checkResponse(event.request).catch(function() {
+ return returnFromCache(event.request);
+ }));
+ event.waitUntil(addToCache(event.request));
});
var checkResponse = function(request){
- return new Promise(function(fulfill, reject) {
- fetch(request).then(function(response){
- if(response.status !== 404) {
- fulfill(response);
- } else {
- reject();
- }
- }, reject);
- });
+ return new Promise(function(fulfill, reject) {
+ fetch(request).then(function(response){
+ if(response.status !== 404) {
+ fulfill(response);
+ } else {
+ reject();
+ }
+ }, reject);
+ });
};
var addToCache = function(request){