From 4df3b5156fb4da751b4a31aa77a1c39faf4f891d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 9 Oct 2018 23:39:41 +0200 Subject: [PATCH] Bring back Content._summary. It's now just a (mutable) copy of metadata["summary"] and changes to it are integrated back to the original. --- pelican/contents.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pelican/contents.py b/pelican/contents.py index dd2a74fa..8d534976 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -142,6 +142,10 @@ class Content(object): if not hasattr(self, 'status'): self.status = getattr(self, 'default_status', None) + # store the summary metadata if it is set + if 'summary' in metadata: + self._summary = metadata['summary'] + signals.content_object_init.send(self) def __str__(self): @@ -465,7 +469,7 @@ class Content(object): def refresh_metadata_intersite_links(self): for key in self.settings['FORMATTED_FIELDS']: - if key in self.metadata: + if key in self.metadata and key != 'summary': value = self._update_content( self.metadata[key], self.get_siteurl() @@ -473,6 +477,16 @@ class Content(object): self.metadata[key] = value setattr(self, key.lower(), value) + # _summary is an internal variable that some plugins may be writing to, + # so ensure changes to it are picked up + if ('summary' in self.settings['FORMATTED_FIELDS'] and + 'summary' in self.metadata): + self._summary = self._update_content( + self._summary, + self.get_siteurl() + ) + self.metadata['summary'] = self._summary + class Page(Content): mandatory_properties = ('title',)