mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #1050 from getpelican/content-written-signal
Add a content_written signal
This commit is contained in:
commit
2e845feb02
3 changed files with 11 additions and 0 deletions
|
|
@ -84,6 +84,7 @@ page_generate_context page_generator, metadata
|
|||
page_generator_init page_generator invoked in the PagesGenerator.__init__
|
||||
page_generator_finalized page_generator invoked at the end of PagesGenerator.generate_context
|
||||
content_object_init content_object invoked at the end of Content.__init__ (see note below)
|
||||
content_written path, context invoked each time a content file is written.
|
||||
============================= ============================ ===========================================================================
|
||||
|
||||
The list is currently small, so don't hesitate to add signals and make a pull
|
||||
|
|
|
|||
|
|
@ -37,3 +37,6 @@ static_generator_preread = signal('static_generator_preread')
|
|||
static_generator_context = signal('static_generator_context')
|
||||
|
||||
content_object_init = signal('content_object_init')
|
||||
|
||||
# Writers signals
|
||||
content_written = signal('content_written')
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ if not six.PY3:
|
|||
|
||||
from feedgenerator import Atom1Feed, Rss201rev2Feed
|
||||
from jinja2 import Markup
|
||||
|
||||
from pelican.paginator import Paginator
|
||||
from pelican.utils import get_relative_path, path_to_url, set_date_tzinfo
|
||||
from pelican import signals
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -151,10 +153,15 @@ class Writer(object):
|
|||
os.makedirs(os.path.dirname(path))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
with self._open_w(path, 'utf-8', override=override) as f:
|
||||
f.write(output)
|
||||
logger.info('writing {}'.format(path))
|
||||
|
||||
# Send a signal to say we're writing a file with some specific
|
||||
# local context.
|
||||
signals.content_written.send(path, context=localcontext)
|
||||
|
||||
localcontext = context.copy()
|
||||
if relative_urls:
|
||||
relative_url = path_to_url(get_relative_path(name))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue