Commit 445c5735109436be4d2b29ffafa9437cd6c2475f
Merge commit 'c1b5c8d'
For About data, use most popular (d87029da1cdaa2cd2211d1e5ef45962db26afcb9) instead of self-picked (dffd43f062a271d3a9be609e1129bf5ad153a4ff)cel committed on 5/15/2017, 1:57:27 AM
Parent: d87029da1cdaa2cd2211d1e5ef45962db26afcb9
Parent: c1b5c8d3560b86c156450c93e8be1a9fe4205a20
Files changed
index.js | changed |
lib/about.js | changed |
render.js | changed |
index.js | ||
---|---|---|
@@ -14,9 +14,10 @@ | ||
14 | 14 … | MdRenderer, |
15 | 15 … | renderEmoji, |
16 | 16 … | formatMsgs, |
17 | 17 … | wrapPage, |
18 | - renderThread | |
18 … | + renderThread, | |
19 … | + renderAbout | |
19 | 20 … | } = require('./render'); |
20 | 21 … | |
21 | 22 … | var appHash = hash([fs.readFileSync(__filename)]) |
22 | 23 … | |
@@ -107,9 +108,9 @@ | ||
107 | 108 … | paramap(addAuthorAbout, 8), |
108 | 109 … | paramap(addFollowAbout, 8), |
109 | 110 … | paramap(addVoteMessage, 8), |
110 | 111 … | paramap(addGitLinks, 8), |
111 | - pull(renderThread(defaultOpts), wrapPage(about.name)), | |
112 … | + pull(renderAbout(defaultOpts, about), wrapPage(about.name)), | |
112 | 113 … | toPull(res, function (err) { |
113 | 114 … | if (err) console.error('[viewer]', err) |
114 | 115 … | }) |
115 | 116 … | ) |
@@ -176,8 +177,9 @@ | ||
176 | 177 … | pull.values(logs), |
177 | 178 … | paramap(addAuthorAbout, 8), |
178 | 179 … | paramap(addFollowAbout, 8), |
179 | 180 … | paramap(addVoteMessage, 8), |
181 … | + paramap(addGitLinks, 8), | |
180 | 182 … | pull(renderThread(defaultOpts), wrapPage(name)), |
181 | 183 … | toPull(res, function (err) { |
182 | 184 … | if (err) console.error('[viewer]', err) |
183 | 185 … | }) |
lib/about.js | ||
---|---|---|
@@ -13,8 +13,9 @@ | ||
13 | 13 … | var aboutByFeed = {} |
14 | 14 … | pull( |
15 | 15 … | sbot.links({ |
16 | 16 … | rel: 'about', |
17 … | + source: id, | |
17 | 18 … | dest: id, |
18 | 19 … | values: true, |
19 | 20 … | }), |
20 | 21 … | pull.drain(function (msg) { |
@@ -23,8 +24,9 @@ | ||
23 | 24 … | if (!c) return |
24 | 25 … | var feedAbout = aboutByFeed[author] || (aboutByFeed[author] = {}) |
25 | 26 … | if (c.name) feedAbout.name = c.name.replace(/^@?/, '@') |
26 | 27 … | if (c.image) feedAbout.image = linkDest(c.image) |
28 … | + if (c.description) feedAbout.description = c.description | |
27 | 29 … | }, function (err) { |
28 | 30 … | if (err) return cb(err) |
29 | 31 … | // Use whatever properties have the most counts. |
30 | 32 … | // Usually we would want to handle renames for dead feeds and such, |
render.js | ||
---|---|---|
@@ -11,8 +11,9 @@ | ||
11 | 11 … | exports.MdRenderer = MdRenderer; |
12 | 12 … | exports.renderEmoji = renderEmoji; |
13 | 13 … | exports.formatMsgs = formatMsgs; |
14 | 14 … | exports.renderThread = renderThread; |
15 … | +exports.renderAbout = renderAbout; | |
15 | 16 … | |
16 | 17 … | function MdRenderer(opts) { |
17 | 18 … | marked.Renderer.call(this, {}); |
18 | 19 … | this.opts = opts; |
@@ -93,8 +94,32 @@ | ||
93 | 94 … | return cat([pull.once(before), read, pull.once(after)]); |
94 | 95 … | }; |
95 | 96 … | } |
96 | 97 … | |
98 … | +function renderAbout(opts, about) { | |
99 … | + return pull( | |
100 … | + pull.map(renderMsg.bind(this, opts)), | |
101 … | + wrap( | |
102 … | + '<span class="top-tip">You are reading content from ' + | |
103 … | + '<a href="https://www.scuttlebutt.nz">Scuttlebutt</a>' + | |
104 … | + '</span>' + | |
105 … | + '<main>' + | |
106 … | + '<article><header><figure>' + | |
107 … | + '<img src="' + opts.img_base + escape(about.image) + '" ' + | |
108 … | + 'height="200" width="200"><figcaption>' + | |
109 … | + 'Feed of ' + about.name + '<br/>' + | |
110 … | + (about.description != undefined ? | |
111 … | + marked(about.description, opts.marked) : '') + | |
112 … | + '</figcaption></figure></header></article>', | |
113 … | + | |
114 … | + '</main>' + | |
115 … | + '<a class="call-to-action" href="https://www.scuttlebutt.nz">' + | |
116 … | + 'Join Scuttlebutt now' + | |
117 … | + '</a>' | |
118 … | + ) | |
119 … | + ); | |
120 … | +} | |
121 … | + | |
97 | 122 … | function renderThread(opts) { |
98 | 123 … | return pull( |
99 | 124 … | pull.map(renderMsg.bind(this, opts)), |
100 | 125 … | wrap( |
@@ -390,9 +415,8 @@ | ||
390 | 415 … | else if (c.type == "issue") { |
391 | 416 … | return '<span class="status">' + |
392 | 417 … | "Created a git issue" + (c.repoName != undefined ? " in repo " + c.repoName : "") + renderPost(opts, c) + |
393 | 418 … | '</span>'; |
394 | - //renderDefault(c); | |
395 | 419 … | } |
396 | 420 … | else if (c.type == "git-update") { |
397 | 421 … | return '<span class="status">' + |
398 | 422 … | "Did a git update " + (c.repoName != undefined ? " in repo " + c.repoName : "") + |
@@ -407,11 +431,10 @@ | ||
407 | 431 … | renderDefault(c); |
408 | 432 … | } |
409 | 433 … | else if (c.type == "pub") { |
410 | 434 … | return '<span class="status">' + |
411 | - "Connected to a pub" + | |
412 | - '</span>' + | |
413 | - renderDefault(c); | |
435 … | + "Connected to the pub " + c.address.host + | |
436 … | + '</span>' | |
414 | 437 … | } |
415 | 438 … | else if (c.type == "channel" && c.subscribed) |
416 | 439 … | return '<span class="status">' + |
417 | 440 … | 'Subscribed to channel <a href="' + base + 'channel/' + |
Built with git-ssb-web