From f3930d159debae7a8edbd76ebbae79d3e0029c23 Mon Sep 17 00:00:00 2001 From: Arul Date: Sat, 17 Dec 2016 06:47:22 +0530 Subject: [PATCH] jsonld support added. og as seperate partials --- templates/article.html | 63 +--------------------- templates/base.html | 36 ------------- templates/index.html | 6 +++ templates/page.html | 8 +-- templates/partials/jsonld.html | 23 ++++++++ templates/partials/jsonld_article.html | 43 +++++++++++++++ templates/partials/og.html | 42 +++++++++++++++ templates/partials/og_article.html | 74 ++++++++++++++++++++++++++ 8 files changed, 194 insertions(+), 101 deletions(-) create mode 100644 templates/partials/jsonld.html create mode 100644 templates/partials/jsonld_article.html create mode 100644 templates/partials/og.html create mode 100644 templates/partials/og_article.html diff --git a/templates/article.html b/templates/article.html index ce8cd75..8900367 100644 --- a/templates/article.html +++ b/templates/article.html @@ -24,68 +24,9 @@ {% for tag in article.tags %} {% endfor %} -{% endblock %} -{% block twitter_card %} - {% for name,link in SOCIAL if name.lower() in ['twitter'] %} - - - - - - {% if article.twitter_image %} - {% if article.twitter_image|lower|truncate(4, True, '') == "http" %} - - {% else %} - - {% endif %} - {% elif article.header_cover %} - - {% elif HEADER_COVER %} - - {% else %} - - {% endif %} - - {% if description %} - - {% elif article.headline %} - - {% else %} - - {% endif %} - {% endfor %} -{% endblock %} -{% block opengraph %} - {{ super() }} - - {% for author in article.authors %} - - {% endfor %} - - - - {% if description %} - - {% elif article.headline %} - - {% elif article.summary %} - - {% endif %} - - {% if article.og_image %} - {% if article.og_image|lower|truncate(4, True, '') == "http" %} - - {% else %} - - {% endif %} - {% elif article.header_cover %} - - {% elif HEADER_COVER %} - - {% else %} - - {% endif %} + {% include 'partials/og_article.html' %} + {% include 'partials/jsonld_article.html' %} {% endblock %} {% block header %} diff --git a/templates/base.html b/templates/base.html index 9c38693..4d691b9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -80,42 +80,6 @@ {% endblock head %} - - {% block opengraph %} - {% for admin in FACEBOOK_ADMINS %} - - {% endfor %} - {% for LOC in LOCALE %} - - {% endfor %} - - - - - - {% if HEADER_COVER %} - - {% else %} - - {% endif %} - {% for name,link in SOCIAL if name.lower() in ['facebook'] %} - - {% endfor %} - {% endblock opengraph %} - {% block twitter_card %} - {% for name,link in SOCIAL if name.lower() in ['twitter'] %} - - - - - - {% if HEADER_COVER %} - - {% else %} - - {% endif %} - {% endfor %} - {% endblock twitter_card %} diff --git a/templates/index.html b/templates/index.html index 70a51d4..ea10a4f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,5 +1,11 @@ {% extends "base.html" %} +{% block head %} + {{ super() }} + {% include 'partials/og.html' %} + {% include 'partials/jsonld.html' %} +{% endblock %} + {% block header %} diff --git a/templates/page.html b/templates/page.html index f813681..408739f 100644 --- a/templates/page.html +++ b/templates/page.html @@ -21,11 +21,11 @@ Menu -

{{ page.title }}

- {% if page.header_cover %} -
+

{{ page.title }}

+ {% if page.og_image %} +
{% elif HEADER_COVER %} -
+
{% elif HEADER_COLOR %}
{% else %} diff --git a/templates/partials/jsonld.html b/templates/partials/jsonld.html new file mode 100644 index 0000000..ac5ae4e --- /dev/null +++ b/templates/partials/jsonld.html @@ -0,0 +1,23 @@ +{# #} +{% if HEADER_COVER %} + {% set default_cover = SITEURL+"/"+HEADER_COVER %} +{% else %} + {% set default_cover = SITEURL+"/"+THEME_STATIC_DIR+"/images/home-bg.jpg" %} +{% endif %} + +{# #} +{% if SITESUBTITLE %} + {% set description = SITESUBTITLE %} +{% else %} + {% set description = 'View the blog.' %} +{% endif %} + diff --git a/templates/partials/jsonld_article.html b/templates/partials/jsonld_article.html new file mode 100644 index 0000000..642310d --- /dev/null +++ b/templates/partials/jsonld_article.html @@ -0,0 +1,43 @@ +{# #} +{% 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 %} + +{# #} +{% if article.headline %} + {% set description = article.headline %} +{% elif article.summary %} + {% set description = article.summary|striptags|truncate(140) %} +{% endif %} + diff --git a/templates/partials/og.html b/templates/partials/og.html new file mode 100644 index 0000000..8a8e5a5 --- /dev/null +++ b/templates/partials/og.html @@ -0,0 +1,42 @@ +{# #} +{% if OG_LOCALE %} + {% set default_locale = OG_LOCALE %} +{% else %} + {% set default_locale = 'en_US' %} +{% endif %} + +{# #} +{% if HEADER_COVER %} + {% set default_cover = SITEURL+"/"+HEADER_COVER %} +{% else %} + {% set default_cover = SITEURL+"/"+THEME_STATIC_DIR+"/images/home-bg.jpg" %} +{% endif %} + +{# #} +{% if SITESUBTITLE %} + {% set description = SITESUBTITLE %} +{% else %} + {% set description = 'View the blog.' %} +{% endif %} + + +{% for admin in FACEBOOK_ADMINS %} + +{% endfor %} + + + + + + + + + +{% for name,link in SOCIAL if name.lower() in ['twitter'] %} + + + + + + +{% endfor %} diff --git a/templates/partials/og_article.html b/templates/partials/og_article.html new file mode 100644 index 0000000..820c03b --- /dev/null +++ b/templates/partials/og_article.html @@ -0,0 +1,74 @@ +{# #} +{% if OG_LOCALE %} + {% set default_locale = OG_LOCALE %} +{% else %} + {% set default_locale = 'en_US' %} +{% endif %} + +{# #} +{% 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 %} + +{# #} +{% if article.headline %} + {% set description = article.headline %} +{% elif article.summary %} + {% set description = article.summary|striptags|truncate(140) %} +{% endif %} + + +{% for admin in FACEBOOK_ADMINS %} + +{% endfor %} + + + + + + + + + +{% for name,link in SOCIAL if name.lower() in ['facebook'] %} + +{% endfor %} + +{% for tag in article.tags %} + +{% endfor %} + + + +{% for name,link in SOCIAL if name.lower() in ['twitter'] %} + + + + + + {% if article.twitter_image %} + {% if article.twitter_image|lower|truncate(4, True, '') == "http" %} + + {% else %} + + {% endif %} + {% else %} + + {% endif %} + + +{% endfor %}