diff --git a/.gitignore b/.gitignore index 480bc72..d66a9c8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ resources/_gen/ themes/base16* commit-msg.txt +static/server-apps.json diff --git a/assets/sass/main.scss b/assets/sass/main.scss index f2d46f4..631d0e8 100644 --- a/assets/sass/main.scss +++ b/assets/sass/main.scss @@ -722,7 +722,8 @@ article.single section.body h4 { color: #f2777a; } article.single section.body h5 { color: #515151; } article.single section.body h6 { color: #747369; } -article.single section.body a,a:visited { color: #a06700; } +// article.single section.body a,a:visited { color: #a06700; } +article.single section.body a,a:visited { color: $base-sky-blue; } /* Article Elements */ diff --git a/content/server/_index.md b/content/server/_index.md index defb07b..b7f13e3 100644 --- a/content/server/_index.md +++ b/content/server/_index.md @@ -6,9 +6,11 @@ layout: single js: ["server-table"] --- Here is a list of apps that I am running a my [DigitalOcean -droplet][do-droplet] along with their statuses, which are updated -every hour using [this Node.js script][update-script]. +droplet][do-droplet]. Their [statuses] are updated every hour using a +[Node.js script][update-script] and a [systemd service]/[timer]. [do-droplet]: https://www.digitalocean.com/products/droplets/ -[update-script]: -https://git.kevin-mok.com/Kevin-Mok/server-pages/src/branch/master/server-status.js +[statuses]: https://kevin-mok.com/server-apps.json +[systemd service]: https://git.kevin-mok.com/Kevin-Mok/server-pages/src/branch/master/server-pages.service +[timer]: https://git.kevin-mok.com/Kevin-Mok/server-pages/src/branch/master/server-pages.timer +[update-script]: https://git.kevin-mok.com/Kevin-Mok/server-pages/src/branch/master/server-status.js diff --git a/static/server-apps.json b/static/server-apps.json deleted file mode 100644 index 4385fa9..0000000 --- a/static/server-apps.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "sites": [ - { - "shortUrl": "kevin-mok.com", - "url": "https://kevin-mok.com", - "siteTitle": " Kevin Mok ", - "description": "Personal site (this site).", - "repo": "Kevin-Mok/my-site", - "repoUrl": "https://git.kevin-mok.com/Kevin-Mok/my-site", - "status": "up" - }, - { - "shortUrl": "git.kevin-mok.com", - "url": "https://git.kevin-mok.com", - "siteTitle": "Kevin Mok's Gitea", - "description": "Lightweight Git server.", - "repo": "go-gitea/gitea", - "repoUrl": "https://github.com/go-gitea/gitea", - "status": "up" - }, - { - "shortUrl": "cal.khkm.tk", - "url": "https://cal.khkm.tk", - "siteTitle": "Baïkal server", - "description": "CalDAV/CardDAV server.", - "repo": "sabre-io/Baikal", - "repoUrl": "https://github.com/sabre-io/Baikal", - "status": "up" - }, - { - "shortUrl": "matrix.ataraxy.tk", - "url": "https://matrix.ataraxy.tk/.well-known/matrix/server", - "siteTitle": "", - "description": "Matrix chat server. Only accessible through Riot client.", - "repo": "matrix-org/synapse", - "repoUrl": "https://github.com/matrix-org/synapse", - "status": "up" - }, - { - "shortUrl": "mnpd.gq", - "url": "https://mnpd.gq/test", - "siteTitle": "test", - "description": "Minimalistic live web notepad.", - "repo": "pereorga/minimalist-web-notepad", - "repoUrl": "https://github.com/pereorga/minimalist-web-notepad", - "status": "up" - }, - { - "shortUrl": "pste.gq", - "url": "https://pste.gq", - "siteTitle": "hastebin", - "description": "Pastebin.", - "repo": "seejohnrun/haste-server", - "repoUrl": "https://github.com/seejohnrun/haste-server", - "status": "up" - }, - { - "shortUrl": "smol.gq", - "url": "https://smol.gq", - "siteTitle": "Kevin's URL Shortener", - "description": "URL shortener.", - "repo": "132ikl/liteshort", - "repoUrl": "https://github.com/132ikl/liteshort", - "status": "up" - }, - { - "shortUrl": "taskd.khkm.tk", - "url": "taskd.khkm.tk:53589", - "siteTitle": "", - "description": "Taskwarrior (task manager) server. No web interface.", - "repo": "GothenburgBitFactory/taskserver", - "repoUrl": "https://github.com/GothenburgBitFactory/taskserver", - "status": "up" - } - ], - "updateTime": 1569204723194, - "upSince": "2019-09-22 19:30:10" -} diff --git a/static/server-table.js b/static/server-table.js index df2e000..6c1cae3 100644 --- a/static/server-table.js +++ b/static/server-table.js @@ -50,17 +50,42 @@ const generateTable = (table, data) => { }) } -const getDurationSince = date => { +const getDurationSince = (date, verbose) => { const milli = Math.abs(Date.now() - date) let mins = Math.floor(milli/1000/60) const days = Math.floor(mins/60/24) mins %= 60*24 const hours = Math.floor(mins/60) mins %= 60 - let durationString = (days > 0) ? `${days}d ` : '' - durationString += (hours > 0) ? `${hours} hours, ` : '' - durationString += (mins > 0) ? `${mins} minutes` : '0m' - return durationString + + let dayString = '' + let hourString = '' + let minString = '' + if (days > 0) { + dayString += days + if (!verbose) { + dayString += 'd ' + } else { + dayString += (days == 1) ? ' day' : ' days' + dayString += ', ' + } + } + if (hours > 0) { + hourString += hours + if (!verbose) { + hourString += 'h ' + } else { + hourString += (hours == 1) ? ' hour' : ' hours' + hourString += ', ' + } + } + minString += (mins > 0) ? mins: '0' + if (!verbose) { + minString += 'm' + } else { + minString += (mins == 1) ? ' minute' : ' minutes' + } + return dayString + hourString + minString } fetch("/server-apps.json") @@ -70,7 +95,7 @@ fetch("/server-apps.json") generateTable(table, json['sites']); generateTableHead(table); document.querySelector('#last-updated-time').textContent = - getDurationSince(new Date(json['updateTime'])) + ' ago.' + getDurationSince(new Date(json['updateTime']), false) + ' ago.' document.querySelector('#server-uptime-time').textContent = - getDurationSince(new Date(json['upSince'])) + '.' + getDurationSince(new Date(json['upSince']), true) + '.' });