Re: comments enhancements
will guaraldi <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
I have a bunch of comments adjustments that I've been sitting on and keep
meaning to get around to factoring into the version that's in CVS.
Attached is a diff of my local comments plugin version with the one that's
in cvs right now.
It adds the following:
1. Users can configure the plugin to force all new comments into a "draft"
mode where they have to be manually "published". I have a script that
looks for all draft comments, prints them to my console, and asks me
whether I want to publish, delete, or ignore the comment.
2. It adds a comment rejection callback allowing people to write their own
comment rejection plugins. I have one that rejects all comments that have
a word in a word blacklist I maintain.
3. I changed the way the comments-form and comments-story templates work.
Instead of stomping on the existing template, it now appends to the story
template. This allows other plugins to set the template for the entry
without the comments plugin stomping on it.
4. I also added a $message variable so that users can see what happened to
their comment: whether it was rejected, whether it was successful, whether
it's in draft mode, ...
I use my version on my site as well as the Planet PyBlosxom site. It
works pretty well so far.
The thing it doesn't do is the secret number image thing. For example, on
Christopher Baus' site:
http://www.baus.net//goodluckkate#comments
I can't for the life of me remember who coded it up but it's the other
very solid way of preventing comment spam that I know about.
/will
On Tue, 7 Dec 2004, Ted Leung wrote:
>
> I've been surfing the pyblosxom blogs tonight -- somehow planet pyblosxom
> didn't make it into my aggregator -- but that's fixed now. I've seen a bunch
> of stuff about various improvements to the comments plugin, and I'm
> interested in trying to get all the changes integrated in one place. I have
> a few local changes of my own. If people want to post their changes, I'm
> happy to take a crack at integrating them.
>
> Ted
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Pyblosxom-devel mailing list
> Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel
>
--
whatever it is, you can find it at http://www.bluesock.org/~willg/
except Will--you can only see him in real life.
comments.py.diff
(text/plain, 4.1 KB)
Index: comments.py
===================================================================
RCS file: /cvsroot/pyblosxom/pyblosxom/contrib/plugins/comments/plugins/comments.py,v
retrieving revision 1.38
diff -r1.38 comments.py
13a14,16
> comment_draft_ext - the file extension used for new comments that have
> not been manually approved by you. this defaults
> to comment_ext (i.e. there is no draft stage)
20a24,26
> comment_rejected_words - the list of words that will cause automatic
> rejection of the comment--this is a very
> poor man's spam reducer.
44,48d49
< try:
< from email.Utils import formatdate
< except ImportError:
< from rfc822 import formatdate
<
61a63,64
> if not config.has_key('comment_draft_ext'):
> config['comment_draft_ext'] = config['comment_ext']
84c87
< optional_keys = ['comment_dir', 'comment_ext']
---
> optional_keys = ['comment_dir', 'comment_ext', 'comment_draft_ext']
134c137
< cmtDir = os.path.join(config['comment_dir'],entry['absolute_path'])
---
> cmtDir = os.path.join(config['comment_dir'], entry['absolute_path'])
170c173,174
< cmt['cmt_time'] = cmt['cmt_pubDate'] # timestamp as float for comment anchor
---
> cmt['cmt_time'] = cmt['cmt_pubDate']
> # timestamp as float for comment anchor
178c182
< def writeComment(config, data, comment):
---
> def writeComment(request, config, data, comment):
189a194,196
>
> @return: The success or failure of creating the comment.
> @rtype: string
192c199
< cdir = os.path.join(config['comment_dir'],entry['absolute_path'])
---
> cdir = os.path.join(config['comment_dir'], entry['absolute_path'])
196,197c203,211
< cfn = os.path.join(cdir,entry['fn']+"-"+comment['pubDate']+"."+config['comment_ext'])
<
---
> cfn = os.path.join(cdir,entry['fn']+"-"+comment['pubDate']+"."+config['comment_draft_ext'])
>
> argdict = { "request": request, "comment": comment }
> reject = tools.run_callback("comment_reject",
> argdict,
> donefunc=lambda x:x)
> if reject == 1:
> return "Comment rejected."
>
204c218
< return
---
> return "Error: Couldn't open comment file for writing."
211c225,226
< cfile.write('<?xml version="1.0" encoding="iso-8859-1"?>\n')
---
> encoding = config.get('blog_encoding', 'iso-8859-1')
> cfile.write('<?xml version="1.0" encoding="%s"?>\n' % encoding)
225c240
< #write latest pickle
---
> # write latest pickle
232c247
< return
---
> return "Error: Couldn't open latest comment pickle for writing."
243c258
< return
---
> return "Error: Problem dumping the pickle."
246,247c261,269
< if config.has_key('comment_smtp_server') and \
< config.has_key('comment_smtp_to'):
---
> if config.has_key('comment_smtp_server') and config.has_key('comment_smtp_to'):
>
> # import the formatdate function which is in a different
> # place in Python 2.3 and up.
> try:
> from email.Utils import formatdate
> except ImportError:
> from rfc822 import formatdate
>
254c276
< email = config['comment_smtp_from']
---
> email = config.get('comment_smtp_from', "[email protected]")
272c294,299
< pass
---
> return "Error: Problem sending notification email."
>
> msg = "Success: Comment has been registered."
> if config["comment_draft_ext"] != config["comment_ext"]:
> msg = msg + " Comment will not appear until it has been manually approved by the owner of this web-site."
> return msg
413c440
< writeComment(config, data, cdict)
---
> data["comment_message"] = writeComment(request, config, data, cdict)
443c470,471
< args['template'] = template
---
> # make this additive so that it doesn't toally fux0r me.
> args['template'] = args['template'] + template