jsonld support added. og as seperate partials

This commit is contained in:
Arul 2016-12-17 06:47:22 +05:30
parent 02dcad911b
commit f3930d159d
8 changed files with 194 additions and 101 deletions

View file

@ -24,68 +24,9 @@
{% for tag in article.tags %}
<meta name="tags" content="{{tag}}">
{% endfor %}
{% endblock %}
{% block twitter_card %}
{% for name,link in SOCIAL if name.lower() in ['twitter'] %}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@{{ link|replace('http://', 'https://')|replace('https://twitter.com/', '') }}">
<meta name="twitter:title" content="{{ article.title }}">
<meta name="twitter:url" content="{{ SITEURL }}/{{ article.url }}">
{% if article.twitter_image %}
{% if article.twitter_image|lower|truncate(4, True, '') == "http" %}
<meta name="twitter:image:src" content="{{ article.twitter_image }}">
{% else %}
<meta name="twitter:image:src" content="{{ SITEURL }}/{{ article.twitter_image }}">
{% endif %}
{% elif article.header_cover %}
<meta name="twitter:image:src" content="{{ SITEURL }}/{{ article.header_cover }}">
{% elif HEADER_COVER %}
<meta name="twitter:image:src" content="{{ SITEURL }}/{{ HEADER_COVER }}">
{% else %}
<meta name="twitter:image:src" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/images/post-bg.jpg">
{% endif %}
{% if description %}
<meta name="twitter:description" content="{{ description }}">
{% elif article.headline %}
<meta name="twitter:description" content="{{ article.headline }}">
{% else %}
<meta name="twitter:description" content="{{ article.summary|striptags|truncate(140) }}">
{% endif %}
{% endfor %}
{% endblock %}
{% block opengraph %}
{{ super() }}
<meta property="og:type" content="article">
{% for author in article.authors %}
<meta property="article:author" content="{{ SITEURL }}/{{ author.url }}">
{% endfor %}
<meta property="og:url" content="{{ SITEURL }}/{{ article.url }}">
<meta property="og:title" content="{{ article.title }}">
<meta property="article:published_time" content="{{ article.date }}">
{% if description %}
<meta property="og:description" content="{{ description }}">
{% elif article.headline %}
<meta property="og:description" content="{{ article.headline }}">
{% elif article.summary %}
<meta property="og:description" content="{{ article.summary|striptags|truncate(140) }}">
{% endif %}
{% if article.og_image %}
{% if article.og_image|lower|truncate(4, True, '') == "http" %}
<meta property="og:image" content="{{ article.og_image }}">
{% else %}
<meta property="og:image" content="{{ SITEURL }}/{{ article.og_image }}">
{% endif %}
{% elif article.header_cover %}
<meta property="og:image" content="{{ SITEURL }}/{{ article.header_cover }}">
{% elif HEADER_COVER %}
<meta property="og:image" content="{{ SITEURL }}/{{ HEADER_COVER }}">
{% else %}
<meta property="og:image" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/images/post-bg.jpg">
{% endif %}
{% include 'partials/og_article.html' %}
{% include 'partials/jsonld_article.html' %}
{% endblock %}
{% block header %}

View file

@ -80,42 +80,6 @@
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
{% endblock head %}
{% block opengraph %}
{% for admin in FACEBOOK_ADMINS %}
<meta property="fb:admins" content="{{ admin }}" />
{% endfor %}
{% for LOC in LOCALE %}
<meta property="og:locale" content="{{ LOC }}" />
{% endfor %}
<meta property="og:site_name" content="{{ SITENAME }}" />
<meta property="og:type" content="website" />
<meta property="og:title" content="{{ SITENAME }}" />
<meta property="og:description" content="{{ SITESUBTITLE|default('View the blog.') }}" />
<meta property="og:url" content="{{ SITEURL }}" />
{% if HEADER_COVER %}
<meta property="og:image" content="{{ SITEURL }}/{{ HEADER_COVER }}" />
{% else %}
<meta name="og:image" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/images/post-bg.jpg">
{% endif %}
{% for name,link in SOCIAL if name.lower() in ['facebook'] %}
<meta property="article:publisher" content="{{ link }}" />
{% endfor %}
{% endblock opengraph %}
{% block twitter_card %}
{% for name,link in SOCIAL if name.lower() in ['twitter'] %}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@{{ link|replace('http://', 'https://')|replace('https://twitter.com/', '') }}">
<meta name="twitter:title" content="{{ SITENAME }}">
<meta name="twitter:description" content="{{ SITESUBTITLE|default('View the blog.') }}">
<meta name="twitter:url" content="{{ SITEURL }}">
{% if HEADER_COVER %}
<meta name="twitter:image:src" content="{{ SITEURL }}/{{ HEADER_COVER }}">
{% else %}
<meta name="twitter:image:src" content="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/images/post-bg.jpg">
{% endif %}
{% endfor %}
{% endblock twitter_card %}
</head>
<!-- TODO : Body class -->
<body class="home-template">

View file

@ -1,5 +1,11 @@
{% extends "base.html" %}
{% block head %}
{{ super() }}
{% include 'partials/og.html' %}
{% include 'partials/jsonld.html' %}
{% endblock %}
{% block header %}
<!-- Page Header -->
<!-- Set your background image for this header on the line below. -->

View file

@ -21,11 +21,11 @@
<a class="menu-button"><i class="ic ic-menu"></i> Menu</a>
</span>
</nav>
<h1 class="post-title">{{ page.title }}</h1>
{% if page.header_cover %}
<div class="post-cover cover" style="background-image: url('{{ page.header_cover }}')">
<h1 class="post-title">{{ page.title }}</h1>
{% if page.og_image %}
<div class="post-cover cover" style="background-image: url('{{ page.og_image }}')">
{% elif HEADER_COVER %}
<div class="post-cover cover" style="background-image: url('{{ HEADER_COVER }}')">
<div class="post-cover cover" style="background-image: url('{{ HEADER_COVER }}')">
{% elif HEADER_COLOR %}
<div class="post-cover cover" style="background-color: {{ HEADER_COLOR }}">
{% else %}

View file

@ -0,0 +1,23 @@
{# <!-- Choosing cover image --> #}
{% if HEADER_COVER %}
{% set default_cover = SITEURL+"/"+HEADER_COVER %}
{% else %}
{% set default_cover = SITEURL+"/"+THEME_STATIC_DIR+"/images/home-bg.jpg" %}
{% endif %}
{# <!-- Choosing description --> #}
{% if SITESUBTITLE %}
{% set description = SITESUBTITLE %}
{% else %}
{% set description = 'View the blog.' %}
{% endif %}
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Website",
"name": " {{ SITENAME }} ",
"url" : "{{ SITEURL }}",
"image": "{{ default_cover }}",
"description": "{{ description }}"
}
</script>

View file

@ -0,0 +1,43 @@
{# <!-- Choosing cover image --> #}
{% if article.og_image %}
{% if article.og_image|lower|truncate(4, True, '') == "http" %}
set default_cover = article.og_image
{% else %}
set default_cover = SITEURL+"/"+article.og_image
{% endif %}
{% elif article.cover %}
{% if article.cover|lower|truncate(4, True, '') == "http" %}
set default_cover = article.cover
{% else %}
set default_cover = SITEURL+"/"+article.cover
{% endif %}
{% elif HEADER_COVER %}
{% set default_cover = SITEURL+"/"+HEADER_COVER %}
{% else %}
{% set default_cover = SITEURL+"/"+THEME_STATIC_DIR+"/images/post-bg.jpg" %}
{% endif %}
{# <!-- Choosing description --> #}
{% if article.headline %}
{% set description = article.headline %}
{% elif article.summary %}
{% set description = article.summary|striptags|truncate(140) %}
{% endif %}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"name": "{{ article.title|striptags }}",
"headline": "{{ article.title|striptags }}",
"datePublished": "{{ article.date }}",
"dateModified": "{{ article.modified }}",
"author": {
"@type": "Person",
"name": "{{ article.author.name }}",
"url": "{{ SITEURL }}/{{ article.author.url }}"
},
"image": "{{ default_cover }}",
"url": "{{ SITEURL }}/{{ article.url }}",
"description": "{{ description }}"
}
</script>

View file

@ -0,0 +1,42 @@
{# <!-- Choosing locale --> #}
{% if OG_LOCALE %}
{% set default_locale = OG_LOCALE %}
{% else %}
{% set default_locale = 'en_US' %}
{% endif %}
{# <!-- Choosing cover image --> #}
{% if HEADER_COVER %}
{% set default_cover = SITEURL+"/"+HEADER_COVER %}
{% else %}
{% set default_cover = SITEURL+"/"+THEME_STATIC_DIR+"/images/home-bg.jpg" %}
{% endif %}
{# <!-- Choosing description --> #}
{% if SITESUBTITLE %}
{% set description = SITESUBTITLE %}
{% else %}
{% set description = 'View the blog.' %}
{% endif %}
<!-- Open Graph -->
{% for admin in FACEBOOK_ADMINS %}
<meta property="fb:admins" content="{{ admin }}" />
{% endfor %}
<meta property="og:site_name" content="{{ SITENAME }}"/>
<meta property="og:type" content="blog"/>
<meta property="og:title" content="{{ SITENAME }}"/>
<meta property="og:description" content="{{ description }}"/>
<meta property="og:locale" content="{{ default_locale }}"/>
<meta property="og:url" content="{{ SITEURL }}"/>
<meta property="og:image" content="{{ default_cover }}">
<!-- Twitter Card -->
{% for name,link in SOCIAL if name.lower() in ['twitter'] %}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@{{ link|replace('http://', 'https://')|replace('https://twitter.com/', '') }}">
<meta name="twitter:title" content="{{ SITENAME }}">
<meta name="twitter:description" content="{{ description}}">
<meta name="twitter:url" content="{{ SITEURL }}">
<meta name="twitter:image:src" content="{{ default_cover }}">
{% endfor %}

View file

@ -0,0 +1,74 @@
{# <!-- Choosing locale --> #}
{% if OG_LOCALE %}
{% set default_locale = OG_LOCALE %}
{% else %}
{% set default_locale = 'en_US' %}
{% endif %}
{# <!-- Choosing cover image --> #}
{% if article.og_image %}
{% if article.og_image|lower|truncate(4, True, '') == "http" %}
set default_cover = article.og_image
{% else %}
set default_cover = SITEURL+"/"+article.og_image
{% endif %}
{% elif article.cover %}
{% if article.cover|lower|truncate(4, True, '') == "http" %}
set default_cover = article.cover
{% else %}
set default_cover = SITEURL+"/"+article.cover
{% endif %}
{% elif HEADER_COVER %}
{% set default_cover = SITEURL+"/"+HEADER_COVER %}
{% else %}
{% set default_cover = SITEURL+"/"+THEME_STATIC_DIR+"/images/post-bg.jpg" %}
{% endif %}
{# <!-- Choosing description --> #}
{% if article.headline %}
{% set description = article.headline %}
{% elif article.summary %}
{% set description = article.summary|striptags|truncate(140) %}
{% endif %}
<!-- Open Graph -->
{% for admin in FACEBOOK_ADMINS %}
<meta property="fb:admins" content="{{ admin }}" />
{% endfor %}
<meta property="og:site_name" content="{{ SITENAME }}"/>
<meta property="og:title" content="{{ article.title|striptags }}"/>
<meta property="og:description" content="{{ description }}"/>
<meta property="og:locale" content="{{ article.metadata.get('og_locale', default_locale) }}"/>
<meta property="og:url" content="{{ SITEURL }}/{{ article.url }}"/>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="{{ article.date }}"/>
<meta property="article:modified_time" content="{{ article.modified }}"/>
<meta property="article:author" content="{{ SITEURL }}/{{ article.author.url }}">
{% for name,link in SOCIAL if name.lower() in ['facebook'] %}
<meta property="article:publisher" content="{{ link }}" />
{% endfor %}
<meta property="article:section" content="{{ article.category.name }}"/>
{% for tag in article.tags %}
<meta property="article:tag" content="{{ tag.name }}"/>
{% endfor %}
<meta property="og:image" content="{{ default_cover }}">
<!-- Twitter Card -->
{% for name,link in SOCIAL if name.lower() in ['twitter'] %}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@{{ link|replace('http://', 'https://')|replace('https://twitter.com/', '') }}">
<meta name="twitter:title" content="{{ article.title }}">
<meta name="twitter:url" content="{{ SITEURL }}/{{ article.url }}">
{% if article.twitter_image %}
{% if article.twitter_image|lower|truncate(4, True, '') == "http" %}
<meta name="twitter:image:src" content="{{ article.twitter_image }}">
{% else %}
<meta name="twitter:image:src" content="{{ SITEURL }}/{{ article.twitter_image }}">
{% endif %}
{% else %}
<meta name="twitter:image:src" content="{{ default_cover }}">
{% endif %}
<meta name="twitter:description" content="{{ description }}">
{% endfor %}