Use custom template to render meta tags properly
This commit is contained in:
parent
ec319bd286
commit
2490447f44
6 changed files with 60 additions and 5 deletions
|
@ -19,6 +19,7 @@ HELPER_SETTINGS = dict(
|
||||||
'taggit',
|
'taggit',
|
||||||
'taggit_autosuggest',
|
'taggit_autosuggest',
|
||||||
'aldryn_apphooks_config',
|
'aldryn_apphooks_config',
|
||||||
|
'tests.test_utils',
|
||||||
],
|
],
|
||||||
LANGUAGE_CODE='en',
|
LANGUAGE_CODE='en',
|
||||||
LANGUAGES=(
|
LANGUAGES=(
|
||||||
|
@ -72,6 +73,9 @@ HELPER_SETTINGS = dict(
|
||||||
MIGRATION_MODULES={
|
MIGRATION_MODULES={
|
||||||
'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
|
'cmsplugin_filer_image': 'cmsplugin_filer_image.migrations_django',
|
||||||
},
|
},
|
||||||
|
CMS_TEMPLATES=(
|
||||||
|
('blog.html', 'Blog template'),
|
||||||
|
),
|
||||||
META_SITE_PROTOCOL='http',
|
META_SITE_PROTOCOL='http',
|
||||||
META_SITE_DOMAIN='example.com',
|
META_SITE_DOMAIN='example.com',
|
||||||
META_USE_OG_PROPERTIES=True,
|
META_USE_OG_PROPERTIES=True,
|
||||||
|
|
|
@ -203,7 +203,21 @@ class Post(ModelMeta, TranslatableModel):
|
||||||
Retrieves django-meta attributes from apphook config instance
|
Retrieves django-meta attributes from apphook config instance
|
||||||
:param param: django-meta attribute passed as key
|
: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):
|
def save_translation(self, translation, *args, **kwargs):
|
||||||
if not translation.slug and translation.title:
|
if not translation.slug and translation.title:
|
||||||
|
|
|
@ -31,14 +31,14 @@ class BaseTest(BaseTestCase):
|
||||||
thumb_2 = None
|
thumb_2 = None
|
||||||
|
|
||||||
_pages_data = (
|
_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},
|
'fr': {'title': 'page un', 'publish': True},
|
||||||
'it': {'title': 'pagina uno', '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'},
|
'apphook': 'BlogApp', 'apphook_namespace': 'sample_app'},
|
||||||
'fr': {'title': 'page deux', 'publish': True},
|
'fr': {'title': 'page deux', 'publish': True},
|
||||||
'it': {'title': 'pagina due', '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'},
|
'apphook': 'BlogApp', 'apphook_namespace': 'sample_app2'},
|
||||||
'fr': {'title': 'page trois', 'publish': True},
|
'fr': {'title': 'page trois', 'publish': True},
|
||||||
'it': {'title': 'pagina tre', 'publish': True}},
|
'it': {'title': 'pagina tre', 'publish': True}},
|
||||||
|
|
|
@ -54,7 +54,7 @@ class SetupTest(BaseTest):
|
||||||
if not home:
|
if not home:
|
||||||
home = create_page(
|
home = create_page(
|
||||||
'a new home', language=lang,
|
'a new home', language=lang,
|
||||||
template='page.html', in_navigation=True, published=True
|
template='blog.html', in_navigation=True, published=True
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
create_title(
|
create_title(
|
||||||
|
|
1
tests/test_utils/models.py
Normal file
1
tests/test_utils/models.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
36
tests/test_utils/templates/blog.html
Normal file
36
tests/test_utils/templates/blog.html
Normal 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>
|
Loading…
Reference in a new issue