-
Notifications
You must be signed in to change notification settings - Fork 118
Optional Meta Page Support #398
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{% load meta_extra %} | ||
{% if meta %} | ||
{% autoescape off %} | ||
{% if meta.description %}{% meta 'description' meta.description %}{% endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't this be automatically generated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used this template: Perhaps @nephila also want to review how to improve it. PS: Thanks to @nephila for his work! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this requires djangocms-page-meta @Nekmo you could simply do:
instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I know, but I've made small changes and thought it would be necessary to make further changes in the future. Moreover, this creates a dependency with DjangoCMS-Page-Meta for something for which it was not intended. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though we should find then a smarter solution by auto generating it. We need to keep it DRY |
||
{% if meta.str_keywords %}{% meta 'keywords' meta.str_keywords %}{% endif %} | ||
{% if meta.use_og %} | ||
{% if meta.title %}{% og_prop 'title' meta.title %}{% endif %} | ||
{% if meta.url %}{% og_prop 'url' meta.url %}{% endif %} | ||
{% if meta.og_description %}{% og_prop 'description' meta.og_description %}{% endif %} | ||
{% if meta.image %}{% og_prop 'image' meta.image %}{% endif %} | ||
{% if meta.og_type %}{% og_prop 'type' meta.og_type %}{% endif %} | ||
{% if meta.site_name %}{% og_prop 'site_name' meta.site_name %}{% endif %} | ||
{% if meta.og_author_url %} | ||
{% generic_prop 'article' 'author' meta.og_author_url %} | ||
{% elif meta.og_author %} | ||
{% generic_prop 'article' 'author:first_name' meta.og_author.first_name %} | ||
{% generic_prop 'article' 'author:last_name' meta.og_author.last_name %} | ||
{% endif %} | ||
{% if meta.published_time %}{% generic_prop 'article' 'published_time' meta.published_time %}{% endif %} | ||
{% if meta.modified_time %}{% generic_prop 'article' 'modified_time' meta.modified_time %}{% endif %} | ||
{% if meta.expiration_time %}{% generic_prop 'article' 'expiration_time' meta.expiration_time %}{% endif %} | ||
{% if meta.og_publisher %}{% generic_prop 'article' 'publisher' meta.og_publisher %}{% endif %} | ||
{% if meta.og_app_id %}{% generic_prop 'fb' 'app_id' meta.og_app_id %}{% endif %} | ||
{% if meta.og_profile_id %}{% generic_prop 'fb' 'profile_id' meta.og_profile_id %}{% endif %} | ||
{% if meta.fb_pages %}{% generic_prop 'fb' 'pages' meta.fb_pages %}{% endif %} | ||
{% if meta.tag %}{% generic_prop 'article' 'tag' meta.tag %}{% endif %} | ||
{% if meta.locale %}{% og_prop 'locale' meta.locale %}{% endif %} | ||
{% endif %} | ||
{% if meta.use_twitter %} | ||
{% twitter_prop 'domain' meta.get_domain %} | ||
{% if meta.twitter_type %}{% twitter_prop 'card' meta.twitter_type %}{% endif %} | ||
{% if meta.title %}{% twitter_prop 'title' meta.title %}{% endif %} | ||
{% if meta.url %}{% twitter_prop 'url' meta.url %}{% endif %} | ||
{% if meta.twitter_description %}{% twitter_prop 'description' meta.twitter_description %}{% endif %} | ||
{% if meta.image %}{% twitter_prop 'image:src' meta.image %}{% endif %} | ||
{% if meta.twitter_author %}{% twitter_prop 'creator' meta.twitter_author %}{% endif %} | ||
{% if meta.twitter_site %}{% twitter_prop 'site_name' meta.twitter_site %}{% endif %} | ||
{% endif %} | ||
{% if meta.use_googleplus %} | ||
{% if meta.gplus_author %} | ||
<link rel="author" href="{{ meta.gplus_author }}"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove slash at |
||
{% endif %} | ||
{% if meta.title %}{% googleplus_prop 'name' meta.title %}{% endif %} | ||
{% if meta.published_time %}{% googleplus_prop 'datePublished' meta.published_time %}{% endif %} | ||
{% if meta.modified_time %}{% googleplus_prop 'dateModified' meta.modified_time %}{% endif %} | ||
{% if meta.url %}{% googleplus_prop 'url' meta.url %}{% endif %} | ||
{% if meta.gplus_description %}{% googleplus_prop 'description' meta.gplus_description %}{% endif %} | ||
{% if meta.image %}{% googleplus_prop 'image' meta.image %}{% endif %} | ||
{% endif %} | ||
{% endautoescape %} | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meta_tags is very generic here, that can break your frontend. Should be something like {% blog_meta_tags %} or so. Also the viewport meta tag should be handled by the project frontend, not the blog /cc @vxsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To elaborate further: https://github.com/aldryn/aldryn-newsblog/blob/master/aldryn_newsblog/boilerplates/bootstrap3/templates/aldryn_newsblog/base.html#L3 is the standard template. If you want meta integration you just adapt the base.html template to look like:
and the article_detail.html just provides the facilities to overwrite it:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this solution :D If you want I can add it to the pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aye 👍