Skip to content

Commit

Permalink
Emit an event when a post/page already exists, also.
Browse files Browse the repository at this point in the history
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 d33a023
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nikola/plugins/command/new_post.py
Expand Up @@ -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)

Expand Down

2 comments on commit d33a023

@ralsina
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These things should come with doc patches. Specifically:

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

@Kwpolska
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 046002a

Please sign in to comment.