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