Use custom template to render meta tags properly

This commit is contained in:
Iacopo Spalletti 2015-10-18 12:46:50 +02:00
parent ec319bd286
commit 2490447f44
6 changed files with 60 additions and 5 deletions

View file

@ -19,6 +19,7 @@ HELPER_SETTINGS = dict(
'taggit',
'taggit_autosuggest',
'aldryn_apphooks_config',
'tests.test_utils',
],
LANGUAGE_CODE='en',
LANGUAGES=(
@ -72,6 +73,9 @@ HELPER_SETTINGS = dict(
MIGRATION_MODULES={
'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
},
CMS_TEMPLATES=(
('blog.html', 'Blog template'),
),
META_SITE_PROTOCOL='http',
META_SITE_DOMAIN='example.com',
META_USE_OG_PROPERTIES=True,

View file

@ -203,7 +203,21 @@ class Post(ModelMeta, TranslatableModel):
Retrieves django-meta attributes from apphook config instance
:param param: django-meta attribute passed as key
"""
return getattr(self.app_config, param)
attr = None
value = getattr(self.app_config, param)
if value:
attr = getattr(self, value, None)
if attr is not None:
if callable(attr):
try:
data = attr(param)
except TypeError:
data = attr()
else:
data = attr
else:
data = value
return data
def save_translation(self, translation, *args, **kwargs):
if not translation.slug and translation.title:

View file

@ -31,14 +31,14 @@ class BaseTest(BaseTestCase):
thumb_2 = None
_pages_data = (
{'en': {'title': 'page one', 'template': 'page.html', 'publish': True},
{'en': {'title': 'page one', 'template': 'blog.html', 'publish': True},
'fr': {'title': 'page un', 'publish': True},
'it': {'title': 'pagina uno', 'publish': True}},
{'en': {'title': 'page two', 'template': 'page.html', 'publish': True,
{'en': {'title': 'page two', 'template': 'blog.html', 'publish': True,
'apphook': 'BlogApp', 'apphook_namespace': 'sample_app'},
'fr': {'title': 'page deux', 'publish': True},
'it': {'title': 'pagina due', 'publish': True}},
{'en': {'title': 'page three', 'template': 'page.html', 'publish': True,
{'en': {'title': 'page three', 'template': 'blog.html', 'publish': True,
'apphook': 'BlogApp', 'apphook_namespace': 'sample_app2'},
'fr': {'title': 'page trois', 'publish': True},
'it': {'title': 'pagina tre', 'publish': True}},

View file

@ -54,7 +54,7 @@ class SetupTest(BaseTest):
if not home:
home = create_page(
'a new home', language=lang,
template='page.html', in_navigation=True, published=True
template='blog.html', in_navigation=True, published=True
)
else:
create_title(

View file

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View file

@ -0,0 +1,36 @@
{% load cms_tags static menu_tags sekizai_tags %}
<!DOCTYPE html {% render_block 'html_extra' %}>
<html>
<head>
<title>{% block title %}{% page_attribute 'title' %}{% endblock title %}</title>
{% render_block "css" %}
{% include "meta_mixin/meta.html" %}
<style type="text/css">
.nav {
padding-left: 0;
}
.nav li {
display: inline;
list-style-type: none;
padding-right: 20px;
}
</style>
</head>
<body>
Post
{% cms_toolbar %}
<div style="width: 940px; margin:0 auto">
<ul class="nav">
{% show_menu 0 100 100 100 %}
</ul>
{% block content %}
{% placeholder "content" %}
{% endblock content %}
</div>
{% render_block "js" %}
{% with_data "js-script" as jsset %}
{% for js in jsset %}<script type="text/javascript" src="{% static js %}"></script>{% endfor %}
{% end_with_data %}
{% render_block "js_end" %}
</body>
</html>