Skip to content
Permalink
Browse files
Emit an event when a post/page already exists, also.
Creation of new_post successfully emits an event, but no event is fired
new_post fails because there is an existing post.  This event can be
used by plugins, for e.g. open the post in an editor or prompt to delete
the post, etc.
  • Loading branch information
punchagan committed May 13, 2015
1 parent b0bf8de commit d33a0232ff9b82ef00a6a8b60d7029af2c356623
Showing with 7 additions and 0 deletions.
  1. +7 −0 nikola/plugins/command/new_post.py
@@ -349,6 +349,13 @@ def _execute(self, options, args):

if (not onefile and os.path.isfile(meta_path)) or \
os.path.isfile(txt_path):

# Emit an event when a post exists
event = dict(path=txt_path)
if not onefile: # write metadata file
event['meta_path'] = meta_path
signal('existing_' + content_type).send(self, **event)

LOGGER.error("The title already exists!")
exit(8)

2 comments on commit d33a023

@ralsina

This comment has been minimized.

Copy link
Member

@ralsina ralsina replied May 14, 2015

These things should come with doc patches. Specifically:

https://github.com/getnikola/nikola/blob/master/docs/extending.txt#L391

@Kwpolska

This comment has been minimized.

Copy link
Member

@Kwpolska Kwpolska replied May 16, 2015

done 046002a

Please sign in to comment.