summaryrefslogtreecommitdiffstats
path: root/__init__.py
diff options
context:
space:
mode:
authorAgathe Porte <microjoe@microjoe.org>2017-09-02 21:49:40 +0200
committerAgathe Porte <microjoe@microjoe.org>2017-09-02 21:49:40 +0200
commit41fbcd99201301836bbaa7b4d1e639dbf737946d (patch)
treeab771ce33c12072f21779a5f0298f416d28666b1 /__init__.py
downloadpelican-gen-date-41fbcd99201301836bbaa7b4d1e639dbf737946d.tar.gz
pelican-gen-date-41fbcd99201301836bbaa7b4d1e639dbf737946d.zip
Initial commit
Diffstat (limited to '__init__.py')
-rw-r--r--__init__.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/__init__.py b/__init__.py
new file mode 100644
index 0000000..2d6e837
--- /dev/null
+++ b/__init__.py
@@ -0,0 +1,33 @@
+import datetime
+
+from pelican import signals
+
+
+class GenDate:
+ def __init__(self, gen):
+ self.settings = gen.settings
+ self.process()
+
+ def process(self):
+ """Initialization process."""
+ pass
+
+ def defer_process(self):
+ """Check and return git describe value."""
+ return datetime.datetime.now()
+
+
+def initialize(gen):
+ """Function called upon article generator initialization."""
+ gen.plugin_instance = GenDate(gen)
+
+
+def fetch(gen, metadata):
+ """Function called upon article generation context fetching."""
+ gen.context['gen_date'] = gen.plugin_instance.defer_process()
+
+
+def register():
+ """Register Pelican signals to dedicated functions."""
+ signals.article_generator_init.connect(initialize)
+ signals.article_generator_context.connect(fetch)