Upgrade pelican and internalise plugin
This commit is contained in:
parent
ab96288948
commit
049f4152cc
5 changed files with 54 additions and 15 deletions
5
.gitmodules
vendored
5
.gitmodules
vendored
|
@ -1,8 +1,3 @@
|
|||
[submodule "pelican_plugins"]
|
||||
path = pelican_plugins
|
||||
url = https://github.com/getpelican/pelican-plugins
|
||||
|
||||
[submodule "plugins/pelican-jinja2content"]
|
||||
path = plugins/pelican-jinja2content
|
||||
url = https://github.com/RealOrangeOne/pelican-jinja2content.git
|
||||
branch = patch-1
|
||||
|
|
|
@ -81,14 +81,15 @@ MINIFY = {
|
|||
from fontawesome_markdown import FontAwesomeExtension
|
||||
from pyembed.markdown import PyEmbedMarkdown
|
||||
from mkdcomments import CommentsExtension
|
||||
MD_EXTENSIONS = [
|
||||
MARKDOWN = {
|
||||
'extensions': [
|
||||
FontAwesomeExtension(),
|
||||
PyEmbedMarkdown(),
|
||||
CommentsExtension(),
|
||||
'codehilite(css_class=highlight)',
|
||||
'extra'
|
||||
]
|
||||
|
||||
}
|
||||
# Setup jinja2 filters
|
||||
from plugins import filters
|
||||
JINJA_FILTERS = {
|
||||
|
@ -96,3 +97,9 @@ JINJA_FILTERS = {
|
|||
"category_find": filters.category_find,
|
||||
"limit": filters.limit
|
||||
}
|
||||
|
||||
JINJA_ENVIRONMENT = {
|
||||
'trim_blocks': True,
|
||||
'lstrip_blocks': True,
|
||||
'extensions': {}
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 81333781964a57d5f590730d0ba419377f0ff022
|
38
plugins/pelican-jinja2content.py
Normal file
38
plugins/pelican-jinja2content.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
import os
|
||||
|
||||
from pelican import signals
|
||||
from pelican import contents
|
||||
|
||||
from jinja2 import Environment, ChoiceLoader, FileSystemLoader
|
||||
|
||||
|
||||
def execjinja2(instance):
|
||||
if type(instance) in (contents.Article, contents.Page):
|
||||
base_path = os.path.dirname(os.path.abspath(__file__))
|
||||
jinja2_env = Environment(
|
||||
loader=ChoiceLoader([
|
||||
FileSystemLoader(
|
||||
os.path.join(base_path, instance.settings['THEME'], 'templates')
|
||||
),
|
||||
FileSystemLoader(
|
||||
os.path.join(base_path, instance.settings['PATH'])
|
||||
)
|
||||
]),
|
||||
**instance.settings['JINJA_ENVIRONMENT'],
|
||||
)
|
||||
|
||||
jinja2_env.filters.update(instance.settings['JINJA_FILTERS'])
|
||||
|
||||
jinja2_template = jinja2_env.from_string(instance._content)
|
||||
|
||||
kwargs = instance._context
|
||||
if type(instance) is contents.Article:
|
||||
kwargs['article'] = instance
|
||||
elif type(instance) is contents.Page:
|
||||
kwargs['page'] = instance
|
||||
|
||||
instance._content = jinja2_template.render(**kwargs)
|
||||
|
||||
|
||||
def register():
|
||||
signals.content_object_init.connect(execjinja2)
|
|
@ -7,7 +7,7 @@ iso8601==0.1.11
|
|||
markdown==2.6.7
|
||||
nose2==0.6.5
|
||||
pelican-minify==0.9
|
||||
pelican==3.6.3
|
||||
pelican==3.7.1
|
||||
pyembed-markdown==1.1.0
|
||||
pygments-style-github==0.4
|
||||
python-resize-image==1.1.3
|
||||
|
|
Reference in a new issue