parent
4040954244
commit
dbde097865
|
@ -1,5 +1,6 @@
|
|||
from babel import dates
|
||||
from datetime import date
|
||||
from functools import partial
|
||||
|
||||
from pyramid.events import subscriber
|
||||
from pyramid.events import BeforeRender
|
||||
|
@ -9,11 +10,13 @@ from .models import load_yaml
|
|||
|
||||
@subscriber(BeforeRender)
|
||||
def add_global(event):
|
||||
dates.LC_TIME = event['request'].locale_name
|
||||
event['globals'] = {
|
||||
'format_date': dates.format_date,
|
||||
'format_datetime': dates.format_datetime,
|
||||
'today': date.today(),
|
||||
'format_date':
|
||||
partial(dates.format_date, locale=event['request'].locale_name),
|
||||
'format_datetime':
|
||||
partial(dates.format_datetime, locale=event['request'].locale_name),
|
||||
'today':
|
||||
date.today(),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<meta name="theme-color" content="#333333">
|
||||
<meta name="twitter:title" content="{{title}}">
|
||||
<meta property="og:title" content="{{title}}" />
|
||||
<meta property="og:url" content="{{data.base_url|join_url(request.path_qs)}}" />
|
||||
<meta property="og:url" content="{{data['base_url']|join_url(request.path_qs)}}" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta name="twitter:card" content="{{summary or description}}">
|
||||
<meta name="twitter:description" content="{{description}}">
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
{{content|safe}}
|
||||
{% endif %}
|
||||
{% for name in ['why', 'what', 'who', 'call'] %}
|
||||
{% if name in data %}
|
||||
{% if name in page %}
|
||||
{{("{% call macros.b(tag='section', id='"+name+"') %}")|safe}}
|
||||
|
||||
{{data[name]|safe}}
|
||||
{{page[name]|safe}}
|
||||
|
||||
{{"{% endcall %}"|safe}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if 'abbr' in data %}
|
||||
{{data['abbr']|safe}}
|
||||
{% if 'abbr' in page %}
|
||||
{{page['abbr']|safe}}
|
||||
{% endif %}
|
||||
{% endfilter %}
|
||||
{% endblock %}
|
||||
|
|
Reference in New Issue