2018-06-19 01:47:10 -04:00
|
|
|
from django.contrib.humanize.templatetags.humanize import naturaltime
|
2018-05-28 07:15:02 -04:00
|
|
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
2018-06-24 23:53:11 -04:00
|
|
|
from django.conf import settings
|
2018-05-28 07:15:02 -04:00
|
|
|
from django.urls import reverse
|
|
|
|
from jinja2 import Environment
|
2018-06-11 20:47:53 -04:00
|
|
|
|
2018-05-28 07:15:02 -04:00
|
|
|
from compressor.contrib.jinja2ext import CompressorExtension
|
2018-06-11 20:47:53 -04:00
|
|
|
from django_activeurl.ext.django_jinja import ActiveUrl
|
2018-05-28 07:15:02 -04:00
|
|
|
|
2018-06-11 20:47:53 -04:00
|
|
|
from entries.kinds import all as entry_kinds
|
2018-06-24 20:11:52 -04:00
|
|
|
from .markdown import markdown
|
2018-06-27 21:10:56 -04:00
|
|
|
from ..theme import color as theme_color
|
2018-06-24 20:11:52 -04:00
|
|
|
from ..utils import friendly_url, load_package_json
|
2018-05-28 07:15:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
def environment(**options):
|
|
|
|
env = Environment(
|
2018-06-11 20:47:53 -04:00
|
|
|
extensions=[ActiveUrl, CompressorExtension],
|
2018-05-28 07:15:02 -04:00
|
|
|
trim_blocks=True,
|
|
|
|
lstrip_blocks=True,
|
|
|
|
**options
|
|
|
|
)
|
2018-06-19 01:47:10 -04:00
|
|
|
env.filters.update({
|
|
|
|
'friendly_url': friendly_url,
|
2018-06-24 20:11:52 -04:00
|
|
|
'markdown': markdown,
|
2018-06-19 01:47:10 -04:00
|
|
|
'naturaltime': naturaltime,
|
|
|
|
})
|
2018-05-28 07:15:02 -04:00
|
|
|
env.globals.update({
|
2018-06-11 20:47:53 -04:00
|
|
|
'entry_kinds': entry_kinds,
|
2018-05-28 07:15:02 -04:00
|
|
|
'package': load_package_json(),
|
2018-06-24 23:53:11 -04:00
|
|
|
'settings': settings,
|
2018-05-28 07:15:02 -04:00
|
|
|
'static': staticfiles_storage.url,
|
2018-06-27 21:10:56 -04:00
|
|
|
'theme_color': theme_color,
|
2018-05-28 07:15:02 -04:00
|
|
|
'url': reverse,
|
|
|
|
})
|
|
|
|
return env
|