From 7123fbcab15c43bbb962d1312a465fddf164493c Mon Sep 17 00:00:00 2001 From: cel Date: Fri, 17 Aug 2018 15:28:01 -0700 Subject: [PATCH] Default to require opt-in for publicWebHosting --- README.md | 1 + index.js | 5 ++++- render.js | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 420837d..bc73b92 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ e.g. `--viewer.port 8807`. - `viewer.blob_base`: base url for links to ssb blobs - `viewer.img_base`: base url for embedded blobs (images) - `viewer.emoji_base`: base url for emoji images +- `viewer.require_opt_in`: whether to serve content from feeds that have not published a `publicWebHosting` `about` message. default: `true` ## References diff --git a/index.js b/index.js index 9e9ad07..30e73ff 100644 --- a/index.js +++ b/index.js @@ -50,6 +50,7 @@ exports.init = function (sbot, config) { blob_base: conf.blob_base || base, img_base: conf.img_base || base, emoji_base: conf.emoji_base || (base + 'emoji/'), + requireOptIn: conf.require_opt_in == null ? true : conf.require_opt_in, } defaultOpts.marked = { @@ -113,7 +114,9 @@ exports.init = function (sbot, config) { renderRssItem(defaultOpts), wrapRss(about.name, defaultOpts) ); default: - var name = about.publicWebHosting === false ? feedId.substr(0, 10) + '…' : about.name + var publicWebHosting = about.publicWebHosting == null + ? !defaultOpts.requireOptIn : about.publicWebHosting + var name = publicWebHosting ? about.name : feedId.substr(0, 10) + '…' return pull( renderAbout(defaultOpts, about, renderShowAll(showAll, req.url)), wrapPage(name) diff --git a/render.js b/render.js index d6790f8..58a9a86 100644 --- a/render.js +++ b/render.js @@ -114,7 +114,7 @@ function toolTipTop() { } function renderAbout(opts, about, showAllHTML = "") { - if (about.publicWebHosting === false) { + if (about.publicWebHosting === false || (about.publicWebHosting == null && opts.requireOptIn)) { return pull( pull.map(renderMsg.bind(this, opts, '')), wrap(toolTipTop() + '
', '
' + callToAction()) @@ -362,6 +362,7 @@ function renderMsg(opts, id, msg) { if (opts.renderAbout == false && c.type == "about") return '' if (opts.renderPub == false && c.type == "pub") return '' if (msg.author.publicWebHosting === false) return h('article', 'User has chosen not to be hosted publicly').outerHTML; + if (msg.author.publicWebHosting == null && opts.requireOptIn) return h('article', 'User has not chosen to be hosted publicly').outerHTML; var name = encodeURIComponent(msg.key); return h('article#' + name,