1st version
This commit is contained in:
commit
764745a1a4
73
.gitignore
vendored
Normal file
73
.gitignore
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
# ---> Vim
|
||||
[._]*.s[a-w][a-z]
|
||||
[._]s[a-w][a-z]
|
||||
*.un~
|
||||
Session.vim
|
||||
.netrwhist
|
||||
*~
|
||||
|
||||
|
||||
|
||||
# ---> Pelican
|
||||
output/
|
||||
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
16
__init__.py
Normal file
16
__init__.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from pelican import signals
|
||||
|
||||
from . import j2filters
|
||||
|
||||
import datetime
|
||||
|
||||
def add_filter(pelican):
|
||||
"""Add date filter to Pelican."""
|
||||
pelican.env.filters.update({'date': j2filters.j2filter_date})
|
||||
pelican.env.filters.update({'date_from_to': j2filters.j2filter_date_from_to})
|
||||
pelican.env.filters.update({'date_from_to_long': j2filters.j2filter_date_from_to_long})
|
||||
|
||||
def register():
|
||||
"""Plugin registration."""
|
||||
signals.generator_init.connect(add_filter)
|
||||
|
25
j2filters.py
Normal file
25
j2filters.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
def j2filter_date(dt, frmt):
|
||||
return dt.strftime(frmt)
|
||||
|
||||
|
||||
def j2filter_date_from_to(dts, dte):
|
||||
if dts.year != dte.year:
|
||||
out = dts.strftime("%d.%m.%Y")
|
||||
elif dts.month != dte.month:
|
||||
out = dts.strftime("%d.%m.")
|
||||
else:
|
||||
out = dts.strftime("%d.")
|
||||
|
||||
return out + " - " + dte.strftime("%d.%m.%Y")
|
||||
|
||||
|
||||
def j2filter_date_from_to_long(dts, dte):
|
||||
if dts.year != dte.year:
|
||||
out = dts.strftime("%d. %B %Y")
|
||||
elif dts.month != dte.month:
|
||||
out = dts.strftime("%d. %B")
|
||||
else:
|
||||
out = dts.strftime("%d.")
|
||||
|
||||
return out + " - " + dte.strftime("%d. %B %Y")
|
||||
|
Loading…
Reference in a new issue