From 590457dcdcd444687761d5a8fbb41bef9e60299c Mon Sep 17 00:00:00 2001 From: Cryptonomicon Date: Sat, 19 Mar 2016 00:43:02 +0000 Subject: [PATCH 1/3] User can now disable comments for the current post. - Added a :nocomment: option to the .. post:: directive - Added documentation for :nocomment: option - Added line breaks in ablog/template/page.html to improve readability --- ablog/blog.py | 7 ++++--- ablog/post.py | 3 +++ ablog/templates/page.html | 6 +++++- docs/manual/posting-and-listing.rst | 8 +++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ablog/blog.py b/ablog/blog.py index 53e9c66..167b20b 100644 --- a/ablog/blog.py +++ b/ablog/blog.py @@ -80,9 +80,9 @@ CONFIG = [ ('post_redirect_refresh', 5, True), ('post_always_section', False, True), - ('disqus_shortname', None, True), - ('disqus_drafts', False, True), - ('disqus_pages', False, True), + ('ablog_disqus_shortname', None, True), + ('ablog_disqus_drafts', False, True), + ('ablog_disqus_pages', False, True), ] @@ -329,6 +329,7 @@ class Post(BlogPageMixin): self.order = info['order'] self.date = date = info['date'] self.update = info['update'] + self.nocomments = info['nocomments'] self.published = date and date < TOMORROW self.draft = not self.published self._title = info['title'] diff --git a/ablog/post.py b/ablog/post.py index 3d1a6e8..efe0e8b 100644 --- a/ablog/post.py +++ b/ablog/post.py @@ -64,6 +64,7 @@ class PostDirective(Directive): 'image': int, 'excerpt': int, 'exclude': directives.flag, + 'nocomments': directives.flag, } def run(self): @@ -85,6 +86,7 @@ class PostDirective(Directive): node['image'] = self.options.get('image', None) node['excerpt'] = self.options.get('excerpt', None) node['exclude'] = 'exclude' in self.options + node['nocomments'] = 'nocomments' in self.options return [node] @@ -337,6 +339,7 @@ def process_posts(app, doctree): 'location': node['location'], 'language': node['language'], 'redirect': node['redirect'], + 'nocomments': node['nocomments'], 'image': node['image'], 'exclude': node['exclude'], 'doctree': section_copy diff --git a/ablog/templates/page.html b/ablog/templates/page.html index f19096b..c7e89ef 100644 --- a/ablog/templates/page.html +++ b/ablog/templates/page.html @@ -26,7 +26,11 @@ {% if pagename in ablog %} {% include "postnavy.html" %} {% endif %} - {% if ablog.disqus_shortname and ablog.blog_baseurl and ((pagename in ablog and (ablog[pagename].published or ablog.disqus_drafts)) or (not pagename in ablog and ablog.disqus_pages)) %} + {% if ablog.disqus_shortname and ablog.blog_baseurl and + (not ablog[pagename].nocomments) and + ((pagename in ablog and (ablog[pagename].published or + ablog.disqus_drafts)) or + (not pagename in ablog and ablog.disqus_pages)) %}

Comments

diff --git a/docs/manual/posting-and-listing.rst b/docs/manual/posting-and-listing.rst index f5f0aef..b4a74a0 100644 --- a/docs/manual/posting-and-listing.rst +++ b/docs/manual/posting-and-listing.rst @@ -29,6 +29,7 @@ following directive: :redirect: blog/old-page-name-for-the-post :excerpt: 2 :image: 1 + :nocoments: **Drafts & Posts** @@ -68,6 +69,11 @@ following directive: relative to the root folder. The redirect page waits for :confval:`post_redirect_refresh` seconds before redirection occurs. + **Disable comments** + + You can disable comments for the current post using the ``:nocomment:`` + option. Currently there is no way to disable comments in a specific page. + **Excerpts & Images** By default, ABlog uses the first paragraph of a page as post excerpt. @@ -188,4 +194,4 @@ A list of posts can be displayed in any page using the following directive: .. update:: Apr 14, 2015 Added ``:list-style:`` option to :rst:dir:`postlist` to control bullet - list style. *circle*, *disk*, and *none* (default) are recognized. \ No newline at end of file + list style. *circle*, *disk*, and *none* (default) are recognized. From 2e357da7d9e739a720f0784344e10c1b525e893f Mon Sep 17 00:00:00 2001 From: Cryptonomicon Date: Sat, 19 Mar 2016 00:49:00 +0000 Subject: [PATCH 2/3] fixed disqus options --- ablog/blog.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ablog/blog.py b/ablog/blog.py index 167b20b..e6a979f 100644 --- a/ablog/blog.py +++ b/ablog/blog.py @@ -80,9 +80,9 @@ CONFIG = [ ('post_redirect_refresh', 5, True), ('post_always_section', False, True), - ('ablog_disqus_shortname', None, True), - ('ablog_disqus_drafts', False, True), - ('ablog_disqus_pages', False, True), + ('disqus_shortname', None, True), + ('disqus_drafts', False, True), + ('disqus_pages', False, True), ] From 4e11caf1f7ebe611ffb08f8a6909ac6752d784cd Mon Sep 17 00:00:00 2001 From: Cryptonomicon Date: Tue, 22 Mar 2016 21:48:15 +0000 Subject: [PATCH 3/3] Fixed typo --- docs/manual/posting-and-listing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/manual/posting-and-listing.rst b/docs/manual/posting-and-listing.rst index b4a74a0..3e6abad 100644 --- a/docs/manual/posting-and-listing.rst +++ b/docs/manual/posting-and-listing.rst @@ -71,7 +71,7 @@ following directive: **Disable comments** - You can disable comments for the current post using the ``:nocomment:`` + You can disable comments for the current post using the ``:nocomments:`` option. Currently there is no way to disable comments in a specific page. **Excerpts & Images**