Pārlūkot izejas kodu

Merge pull request #223 from Scheirle/pcs_i18n_fix

[pelican_comment_system] Fixed wrongly reinitialization + updated requirements list.
Justin Mayer 10 gadi atpakaļ
vecāks
revīzija
0526123104

+ 2 - 0
pelican_comment_system/Readme.md

@@ -23,6 +23,8 @@ Bernhard Scheirle  | <http://blog.scheirle.de> | <https://github.com/Scheirle>
  - [Comment Form (aka: never gather Metadata)](doc/form.md)
  
 ## Requirements
+Pelican 3.4 or newer is required.
+
 To create identicons the Python Image Library is needed. Therefore you either need PIL **or** Pillow (recommended).
 
 ##### Install Pillow

+ 3 - 1
pelican_comment_system/avatars.py

@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 """
-
+Author: Bernhard Scheirle
 """
 
 from __future__ import unicode_literals
@@ -44,6 +44,8 @@ def init(pelican_output_path, identicon_output_path, identicon_data, identicon_s
 	global _identicon_size
 	global _initialized
 	global _authors
+	if _initialized:
+		return
 	_identicon_save_path = os.path.join(pelican_output_path, identicon_output_path)
 	_identicon_output_path = identicon_output_path
 	_identicon_data = identicon_data

+ 1 - 1
pelican_comment_system/comment.py

@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 """
-
+Author: Bernhard Scheirle
 """
 from __future__ import unicode_literals
 from pelican import contents

+ 12 - 5
pelican_comment_system/pelican_comment_system.py

@@ -53,6 +53,15 @@ def initialize(article_generator):
 		article_generator.settings['PELICAN_COMMENT_SYSTEM_AUTHORS'],
 		)
 
+def write_feed(gen, items, context, slug):
+	if gen.settings['PELICAN_COMMENT_SYSTEM_FEED'] == None:
+		return
+
+	path = gen.settings['PELICAN_COMMENT_SYSTEM_FEED'] % slug
+
+	writer = Writer(gen.output_path, settings=gen.settings)
+	writer.write_feed(items, context, path)
+
 def add_static_comments(gen, content):
 	if gen.settings['PELICAN_COMMENT_SYSTEM'] != True:
 		return
@@ -63,16 +72,14 @@ def add_static_comments(gen, content):
 	#Modify the local context, so we get proper values for the feed
 	context = copy.copy(gen.context)
 	context['SITEURL'] += "/" + content.url
-	context['SITENAME'] = "Comments for: " + content.title
+	context['SITENAME'] += " - Comments: " + content.title
 	context['SITESUBTITLE'] = ""
-	path = gen.settings['PELICAN_COMMENT_SYSTEM_FEED'] % content.slug
-	writer = Writer(gen.output_path, settings=gen.settings)
 
 	folder = os.path.join(gen.settings['PELICAN_COMMENT_SYSTEM_DIR'], content.slug)
 
 	if not os.path.isdir(folder):
 		logger.debug("No comments found for: " + content.slug)
-		writer.write_feed( [], context, path)
+		write_feed(gen, [], context, content.slug)
 		return
 
 	reader = MarkdownReader(gen.settings)
@@ -93,7 +100,7 @@ def add_static_comments(gen, content):
 			else:
 				comments.append( com )
 
-	writer.write_feed( comments + replies, context, path)
+	write_feed(gen, comments + replies, context, content.slug)
 
 	#TODO: Fix this O(n²) loop
 	for reply in replies: