git ssb

0+

Daan Patchwork / ssb-viewer



forked from cel / ssb-viewer

Commit aa1697181e2065d65b336d19ad06501921b37c39

Add footer with copyright and source link

cel committed on 6/11/2020, 6:20:06 PM
Parent: 514c401ff151036c45361377130d23877d57bec1

Files changed

README.mdchanged
package.jsonchanged
render.jschanged
README.mdView
@@ -100,9 +100,9 @@
100100 [ssb-ws]: %tFjo5SoD+Y0SaB5vqZYppmoPmv9LKB5wMPl96qtu4qk=.sha256
101101
102102 ## License
103103
104-Copyright (c) 2016-2017 Secure Scuttlebutt Consortium
104+Copyright (c) 2016-2020 Secure Scuttlebutt Consortium
105105
106106 This program is free software: you can redistribute it and/or modify
107107 it under the terms of the GNU Affero General Public License as
108108 published by the Free Software Foundation, either version 3 of the
package.jsonView
@@ -3,8 +3,13 @@
33 "version": "1.0.0",
44 "description": "serve ssb threads as (embeddable) web pages",
55 "main": "index.js",
66 "bin": "bin.js",
7+ "homepage": "https://git.scuttlebot.io/%25MeCTQrz9uszf9EZoTnKCeFeIedhnKWuB3JHW2l1g9NA%3D.sha256",
8+ "repository": {
9+ "type": "git",
10+ "url": "ssb://%MeCTQrz9uszf9EZoTnKCeFeIedhnKWuB3JHW2l1g9NA=.sha256"
11+ },
712 "dependencies": {
813 "asyncmemo": "^1.0.0",
914 "emoji-named-characters": "^1.0.2",
1015 "emoji-server": "^1.0.0",
render.jsView
@@ -1,12 +1,15 @@
1+var fs = require('fs')
12 var path = require('path')
3+var proc = require('child_process')
24 var pull = require("pull-stream")
35 var marked = require("ssb-marked")
46 var htime = require("human-time")
57 var emojis = require("emoji-named-characters")
68 var cat = require("pull-cat")
79 var h = require('hyperscript')
810 var refs = require('ssb-ref')
11+var pkg = require('./package')
912
1013 var emojiDir = path.join(require.resolve("emoji-named-characters"), "../pngs")
1114
1215 exports.wrapPage = wrapPage
@@ -156,8 +159,23 @@
156159 pull.map(renderRss.bind(this, opts))
157160 )
158161 }
159162
163+const gitHead = proc.spawnSync('git', ['rev-parse', 'HEAD'], {
164+ encoding: 'utf8',
165+ cwd: __dirname
166+}).stdout.trim()
167+const gitHeadShort = gitHead && gitHead.substr(0, 7)
168+const commitUrl = pkg.homepage &&
169+ pkg.homepage.replace(/\/+$/, '') + '/commit/' + gitHead
170+const gitLink = !gitHead ? '' :
171+ !commitUrl ? `<code title="${gitHead}">${gitHeadShort}</code>` :
172+ `<a href="${commitUrl}" title="${gitHead}"><code>${gitHeadShort}</code></a>`
173+
174+const footer = `
175+<div class=footer>AGPLv3 &copy; <a href="${pkg.homepage}">${pkg.name}</a> ${gitLink}</div>
176+`
177+
160178 function wrapPage(id) {
161179 return wrap(
162180 "<!doctype html><html><head>" +
163181 "<meta charset=utf-8>" +
@@ -166,9 +184,9 @@
166184 "</title>" +
167185 '<meta name=viewport content="width=device-width,initial-scale=1">' +
168186 styles +
169187 "</head><body>",
170- "</body></html>"
188+ footer + "\n</body></html>"
171189 )
172190 }
173191
174192 function wrapRss(id, opts) {
@@ -288,9 +306,9 @@
288306 width: 13em;
289307 text-align: center;
290308 text-decoration: none;
291309 margin-top: 20px;
292- margin-bottom: 60px;
310+ margin-bottom: 30px;
293311 background-color: #5c7cfa;
294312 padding: 15px 0;
295313 color: #edf2ff;
296314 border-radius: 3px;
@@ -302,8 +320,14 @@
302320 }
303321 .attending {
304322 text-align: center;
305323 }
324+ .footer {
325+ text-align: center;
326+ margin-bottom: 10px;
327+ font-size: 14px;
328+ color: #868e96;
329+ }
306330 </style>
307331 `
308332
309333 function wrapJSON() {

Built with git-ssb-web