diff --git a/Dockerfile b/Dockerfile
index 32c4993..2c6ee52 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,8 @@
-FROM xena/go:1.11 AS build
-COPY . /root/go/src/github.com/Xe/site
-WORKDIR /root/go/src/github.com/Xe/site
-RUN GO111MODULE=on CGO_ENABLED=0 GOBIN=/root go install -v -mod=vendor ./cmd/site
+FROM xena/go:1.11.1 AS build
+ENV GOPROXY https://cache.greedo.xeserv.us
+COPY . /site
+WORKDIR /site
+RUN CGO_ENABLED=0 GOBIN=/root go install -v ./cmd/site
FROM xena/alpine
EXPOSE 5000
diff --git a/cmd/site/main.go b/cmd/site/main.go
index 4295e8a..e9b4d21 100644
--- a/cmd/site/main.go
+++ b/cmd/site/main.go
@@ -17,7 +17,7 @@ import (
"github.com/gorilla/feeds"
blackfriday "github.com/russross/blackfriday"
"github.com/tj/front"
- "gopkg.in/segmentio/analytics-go.v3"
+ analytics "gopkg.in/segmentio/analytics-go.v3"
)
var port = os.Getenv("PORT")
@@ -191,6 +191,9 @@ func Build() (*Site, error) {
s.mux.HandleFunc("/blog/", s.showPost)
s.mux.Handle("/css/", http.FileServer(http.Dir(".")))
s.mux.Handle("/static/", http.FileServer(http.Dir(".")))
+ s.mux.HandleFunc("/sw.js", func(w http.ResponseWriter, r *http.Request) {
+ http.ServeFile(w, r, "./static/js/sw.js")
+ })
return s, nil
}
diff --git a/static/js/sw.js b/static/js/sw.js
new file mode 100755
index 0000000..4b3b1e2
--- /dev/null
+++ b/static/js/sw.js
@@ -0,0 +1,55 @@
+//This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
+
+//Install stage sets up the offline page in the cache and opens a new cache
+self.addEventListener('install', function(event) {
+ event.waitUntil(preLoad());
+});
+
+var preLoad = function(){
+ console.log('[PWA Builder] Install Event processing');
+ return caches.open('pwabuilder-offline').then(function(cache) {
+ console.log('[PWA Builder] Cached index and offline page during Install');
+ return cache.addAll(['/offline.html', '/index.html']);
+ });
+}
+
+self.addEventListener('fetch', function(event) {
+ 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)
+ });
+};
+
+var addToCache = function(request){
+ return caches.open('pwabuilder-offline').then(function (cache) {
+ return fetch(request).then(function (response) {
+ console.log('[PWA Builder] add page to offline'+response.url)
+ return cache.put(request, response);
+ });
+ });
+};
+
+var returnFromCache = function(request){
+ return caches.open('pwabuilder-offline').then(function (cache) {
+ return cache.match(request).then(function (matching) {
+ if(!matching || matching.status == 404) {
+ return cache.match('offline.html')
+ } else {
+ return matching
+ }
+ });
+ });
+};
diff --git a/static/manifest.json b/static/manifest.json
new file mode 100644
index 0000000..8136ce9
--- /dev/null
+++ b/static/manifest.json
@@ -0,0 +1,17 @@
+{
+ "name": "Christine Dodrill",
+ "short_name": "Christine",
+ "theme_color": "#ffcbe4",
+ "background_color": "#fa99ca",
+ "display": "standalone",
+ "scope": "/",
+ "start_url": "https://christine.website/",
+ "description": "Blog and Resume for Christine Dodrill",
+ "orientation": "any",
+ "icons": [
+ {
+ "src": "https://christine.website/static/img/avatar.png",
+ "sizes": "1024x1024"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/templates/base.html b/templates/base.html
index 13722a0..c00bc1e 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -5,6 +5,7 @@
+
@@ -61,6 +62,15 @@
+