diff --git a/docs/docs/configuration/client.rst b/docs/docs/configuration/client.rst index 9328357..779f47e 100644 --- a/docs/docs/configuration/client.rst +++ b/docs/docs/configuration/client.rst @@ -20,7 +20,8 @@ preferably in the script tag which embeds the JS: data-isso-avatar-bg="#f0f0f0" data-isso-avatar-fg="#9abf88 #5698c4 #e279a3 #9163b6 ..." data-isso-vote="true" - data-vote-levels="" + data-isso-vote-levels="" + data-isso-feed="false" src="/prefix/js/embed.js"> Furthermore you can override the automatic title detection inside @@ -125,3 +126,10 @@ For example, the value `"-5,5"` will cause each `isso-comment` to be given one o - `isso-vote-level-2` for scores of `5` and greater These classes can then be used to customize the appearance of comments (eg. put a star on popular comments) + +data-isso-feed +-------------- + +Enable or disable the addition of a link to the feed for the comment +thread. The link will only be valid if the appropriate setting, in +``[rss]`` section, is also enabled server-side. diff --git a/docs/docs/configuration/server.rst b/docs/docs/configuration/server.rst index 1a443f8..5327c96 100644 --- a/docs/docs/configuration/server.rst +++ b/docs/docs/configuration/server.rst @@ -308,6 +308,27 @@ algorithm Arguments have to be in that order, but can be reduced to `pbkdf2:4096` for example to override the iterations only. +.. _configure-rss: + +RSS +--- + +Isso can provide an Atom feed for each comment thread. Users can use +them to subscribe to comments and be notified of changes. Atom feeds +are enabled as soon as there is a base URL defined in this section. + +.. code-block:: ini + + [rss] + base = + limit = 100 + +base + base URL to use to build complete URI to pages (by appending the URI from Isso) + +limit + number of most recent comments to return for a thread + Appendum -------- diff --git a/isso/js/app/config.js b/isso/js/app/config.js index 952d588..258da6d 100644 --- a/isso/js/app/config.js +++ b/isso/js/app/config.js @@ -15,7 +15,8 @@ define(function() { "avatar-fg": ["#9abf88", "#5698c4", "#e279a3", "#9163b6", "#be5168", "#f19670", "#e4bf80", "#447c69"].join(" "), "vote": true, - "vote-levels": null + "vote-levels": null, + "feed": false }; var js = document.getElementsByTagName("script"); diff --git a/isso/js/embed.js b/isso/js/embed.js index 715413c..a0a53da 100644 --- a/isso/js/embed.js +++ b/isso/js/embed.js @@ -27,11 +27,13 @@ require(["app/lib/ready", "app/config", "app/i18n", "app/api", "app/isso", "app/ return console.log("abort, #isso-thread is missing"); } - var feedLink = $.new('a', i18n.translate('atom-feed')); - var feedLinkWrapper = $.new('span.isso-feedlink'); - feedLink.href = api.feed($("#isso-thread").getAttribute("data-isso-id")); - feedLinkWrapper.append(feedLink); - $("#isso-thread").append(feedLinkWrapper); + if (config["feed"]) { + var feedLink = $.new('a', i18n.translate('atom-feed')); + var feedLinkWrapper = $.new('span.isso-feedlink'); + feedLink.href = api.feed($("#isso-thread").getAttribute("data-isso-id")); + feedLinkWrapper.append(feedLink); + $("#isso-thread").append(feedLinkWrapper); + } $("#isso-thread").append($.new('h4')); $("#isso-thread").append(new isso.Postbox(null)); $("#isso-thread").append('
'); diff --git a/isso/tests/test_comments.py b/isso/tests/test_comments.py index a58ae62..4ba67c8 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -31,9 +31,9 @@ class TestComments(unittest.TestCase): fd, self.path = tempfile.mkstemp() conf = config.load(os.path.join(dist.location, "share", "isso.conf")) conf.set("general", "dbpath", self.path) - conf.set("general", "host", "https://example.org") conf.set("guard", "enabled", "off") conf.set("hash", "algorithm", "none") + self.conf = conf class App(Isso, core.Mixin): pass @@ -326,7 +326,13 @@ class TestComments(unittest.TestCase): self.assertListEqual(list(rv.keys()), []) + def testNoFeed(self): + rv = self.get('/feed?uri=%2Fpath%2Fnothing') + self.assertEqual(rv.status_code, 404) + def testFeedEmpty(self): + self.conf.set("rss", "base", "https://example.org") + rv = self.get('/feed?uri=%2Fpath%2Fnothing') self.assertEqual(rv.status_code, 200) self.assertEqual(rv.headers['ETag'], '"empty"') @@ -335,6 +341,8 @@ class TestComments(unittest.TestCase):