From 0cb96b12bb61652aea003c1dfbb24b3a9a7be9d5 Mon Sep 17 00:00:00 2001 From: Korbs Date: Thu, 23 Nov 2023 20:59:13 -0500 Subject: [PATCH 1/8] Use Alpine Linux instead of Debian --- Dockerfile | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index c934dca0..73794cf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,28 +4,18 @@ ## To run the image, run: ## docker run -d -p 6003:6003 poketube -# Base (Debian) -FROM debian +# Base (Alpine Linux) +FROM alpine # Set Work Directory WORKDIR /poketube COPY . /poketube -# Expose Ports +# Expose Default Ports EXPOSE 6003 # Install Requirements -RUN apt-get update && apt-get -y install \ - libcurl4-openssl-dev make g++ ca-certificates curl gnupg - -# Install NodeJS v18 -RUN mkdir -p /etc/apt/keyrings -RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg - -RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list - -RUN apt-get update -RUN apt-get -y install nodejs +RUN apk add nodejs npm make g++ ca-certificates curl gnupg python3 # Install Packages RUN npm install From 18d7a757958e281cde8e401729dfa34ca358aada Mon Sep 17 00:00:00 2001 From: Korbs Date: Sat, 25 Nov 2023 06:11:16 -0500 Subject: [PATCH 2/8] Use GNU --- Dockerfile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 73794cf3..c934dca0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,18 +4,28 @@ ## To run the image, run: ## docker run -d -p 6003:6003 poketube -# Base (Alpine Linux) -FROM alpine +# Base (Debian) +FROM debian # Set Work Directory WORKDIR /poketube COPY . /poketube -# Expose Default Ports +# Expose Ports EXPOSE 6003 # Install Requirements -RUN apk add nodejs npm make g++ ca-certificates curl gnupg python3 +RUN apt-get update && apt-get -y install \ + libcurl4-openssl-dev make g++ ca-certificates curl gnupg + +# Install NodeJS v18 +RUN mkdir -p /etc/apt/keyrings +RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg + +RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list + +RUN apt-get update +RUN apt-get -y install nodejs # Install Packages RUN npm install From a825847cb259a953b5a4b18194aff614ce13e3c8 Mon Sep 17 00:00:00 2001 From: Korbs Date: Thu, 7 Dec 2023 16:35:15 +0000 Subject: [PATCH 3/8] Remove SudoVanilla's instance --- instances.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/instances.json b/instances.json index a3e23283..e4f3b050 100644 --- a/instances.json +++ b/instances.json @@ -16,20 +16,6 @@ } } ], - [ - "poketube.sudovanilla.com", - { - "uri": "https://poketube.sudovanilla.com", - "CLOUDFLARE": true, - "piwik": false, - "region": "🇺🇸", - "software": { - "name": "poketube", - "version": "lastest", - "branch": "dev" - } - } - ], [ "poke.vern.cc", { From ba99f09304c0ec9b738d6e8941d781f66bbd0ba9 Mon Sep 17 00:00:00 2001 From: Korbs Date: Fri, 15 Dec 2023 00:08:34 -0500 Subject: [PATCH 4/8] Add service worker and offline page --- src/libpoketube/init/pages-static.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libpoketube/init/pages-static.js b/src/libpoketube/init/pages-static.js index 3ca2d6db..31467383 100644 --- a/src/libpoketube/init/pages-static.js +++ b/src/libpoketube/init/pages-static.js @@ -87,8 +87,16 @@ module.exports = function (app, config, renderTemplate) { renderTemplate(res, req, "content-settings.ejs"); }); - app.get("/manifest.json", function (req, res) { - res.sendFile("manifest.json", { root: location_pwa }); + app.get("/offline", function (req, res) { + res.sendFile("offline.html", { root: location_pwa }); + }); + + app.get("/manifest.json", function (req, res) { + res.sendFile("manifest.json", { root: location_pwa }); + }); + + app.get("/service-worker.js", function (req, res) { + res.sendFile("service-worker.js", { root: location_pwa }); }); From 004d6efea12b363b7d1d83ec396061d3b106ccbf Mon Sep 17 00:00:00 2001 From: Korbs Date: Fri, 15 Dec 2023 00:08:43 -0500 Subject: [PATCH 5/8] Add service worker --- pwa/service-worker.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pwa/service-worker.js diff --git a/pwa/service-worker.js b/pwa/service-worker.js new file mode 100644 index 00000000..2ce1c1d8 --- /dev/null +++ b/pwa/service-worker.js @@ -0,0 +1,34 @@ +'use strict'; + +var cacheVersion = 1; +var currentCache = { + offline: 'offline-cache' + cacheVersion +}; +const offlineUrl = 'offline'; + +this.addEventListener('install', event => { + event.waitUntil( + caches.open(currentCache.offline).then(function (cache) { + return cache.addAll([ + offlineUrl + ]); + }) + ); +}); + +this.addEventListener('fetch', event => { + if (event.request.mode === 'navigate' || (event.request.method === 'GET' && event.request.headers.get('accept').includes('text/html'))) { + event.respondWith( + fetch(event.request.url).catch(error => { + return caches.match(offlineUrl); + }) + ); + } + else { + event.respondWith(caches.match(event.request) + .then(function (response) { + return response || fetch(event.request); + }) + ); + } +}); \ No newline at end of file From 92709cca8dd07e9a6ce520f1d29926efd48cc5d4 Mon Sep 17 00:00:00 2001 From: Korbs Date: Fri, 15 Dec 2023 00:08:58 -0500 Subject: [PATCH 6/8] Add offline page --- pwa/offline.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 pwa/offline.html diff --git a/pwa/offline.html b/pwa/offline.html new file mode 100644 index 00000000..3aa7c5fb --- /dev/null +++ b/pwa/offline.html @@ -0,0 +1,47 @@ + + + + PokeTube + + +
+
+

Oh no ;-;

+

Looks like you're offline, check your internet connection and try again.

+
+
+ + + + \ No newline at end of file From e4e3ee6aa11486a968e1828bc83d5d1c28ea880d Mon Sep 17 00:00:00 2001 From: Korbs Date: Fri, 15 Dec 2023 00:09:10 -0500 Subject: [PATCH 7/8] Link service worker on main pages --- html/account-me.ejs | 8 +++++++- html/channel.ejs | 7 ++++++- html/landing.ejs | 7 ++++++- html/poketube.ejs | 8 +++++++- html/search-web.ejs | 6 +++++- html/search.ejs | 6 +++++- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/html/account-me.ejs b/html/account-me.ejs index 7c5b353a..4528f476 100644 --- a/html/account-me.ejs +++ b/html/account-me.ejs @@ -92,4 +92,10 @@ a { - \ No newline at end of file + + + \ No newline at end of file diff --git a/html/channel.ejs b/html/channel.ejs index 65f0e388..f2869bd6 100644 --- a/html/channel.ejs +++ b/html/channel.ejs @@ -1416,4 +1416,9 @@ document.getElementById('search').addEventListener('keyup', function () { <% } catch (error) { %> - <% } %> \ No newline at end of file + <% } %> + \ No newline at end of file diff --git a/html/landing.ejs b/html/landing.ejs index db7a823b..164341da 100644 --- a/html/landing.ejs +++ b/html/landing.ejs @@ -108,4 +108,9 @@ body { - \ No newline at end of file + + \ No newline at end of file diff --git a/html/poketube.ejs b/html/poketube.ejs index a34b6259..48f366d5 100644 --- a/html/poketube.ejs +++ b/html/poketube.ejs @@ -3130,4 +3130,10 @@ window.addEventListener('load', () => { <% } catch (error) { %> <%- error %> - <% } %> \ No newline at end of file + <% } %> + + \ No newline at end of file diff --git a/html/search-web.ejs b/html/search-web.ejs index 085cbb01..5177c905 100644 --- a/html/search-web.ejs +++ b/html/search-web.ejs @@ -469,4 +469,8 @@ Web - \ No newline at end of file + \ No newline at end of file diff --git a/html/search.ejs b/html/search.ejs index afa3933c..7a7bc521 100644 --- a/html/search.ejs +++ b/html/search.ejs @@ -578,4 +578,8 @@ font-weight: 1000; - \ No newline at end of file + \ No newline at end of file From 8bf14891d0aa3bd642fee14b79e3b7bc3c240b13 Mon Sep 17 00:00:00 2001 From: Korbs Date: Fri, 15 Dec 2023 05:23:11 +0000 Subject: [PATCH 8/8] Keep SudoVanilla's instance in for school --- instances.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/instances.json b/instances.json index e4f3b050..a3e23283 100644 --- a/instances.json +++ b/instances.json @@ -16,6 +16,20 @@ } } ], + [ + "poketube.sudovanilla.com", + { + "uri": "https://poketube.sudovanilla.com", + "CLOUDFLARE": true, + "piwik": false, + "region": "🇺🇸", + "software": { + "name": "poketube", + "version": "lastest", + "branch": "dev" + } + } + ], [ "poke.vern.cc", {