From 647d01483655fc063e174e471f6cd381d7982eea Mon Sep 17 00:00:00 2001 From: juego Date: Wed, 14 May 2014 18:02:49 +0200 Subject: [PATCH 1/6] Verify that the site.url has a protocol. --- feed.xml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/feed.xml b/feed.xml index b880dc2..136e729 100644 --- a/feed.xml +++ b/feed.xml @@ -5,33 +5,34 @@ layout: none {{ site.title }} Jekyll - - +{% if site.url != '' and site.url | split: '/' | first != 'http:' and site.url | split: '/' | first != 'https:' %}{% assign url = site.url | prepend: 'http:' %}{% else %}{% assign url = site.url %}{% endif %} + + {{ site.time | date_to_xmlschema }} -{{ site.url }}/ +{{ url }}/ {{ site.owner.name }} - {{ site.url }}/ + {{ url }}/ {{ site.owner.email }} {% for post in site.posts limit:20 %} <![CDATA[{{ post.title | cdata_escape }}]]> - - {{ site.url }}{{ post.id }} + + {{ url }}{{ post.id }} {% if post.modified %}{{ post.modified | to_xmlschema }}T00:00:00-00:00 {{ post.date | date_to_xmlschema }} {% else %}{{ post.date | date_to_xmlschema }} {{ post.date | date_to_xmlschema }}{% endif %} {{ site.owner.name }} - {{ site.url }} + {{ url }} {{ site.owner.email }} - {% for tag in post.tags %}{% endfor %} + {% for tag in post.tags %}{% endfor %} {{ post.content | xml_escape }} - <p><a href="{{ site.url }}{{ post.url }}">{{ post.title }}</a> was originally published by {{ site.owner.name }} at <a href="{{ site.url }}">{{ site.title }}</a> on {{ post.date | date: "%B %d, %Y" }}.</p> + <p><a href="{{ url }}{{ post.url }}">{{ post.title }}</a> was originally published by {{ site.owner.name }} at <a href="{{ url }}">{{ site.title }}</a> on {{ post.date | date: "%B %d, %Y" }}.</p> {% endfor %} From 19f7de9bf11245fc76e6c428e0306d6407b64a72 Mon Sep 17 00:00:00 2001 From: juego Date: Wed, 14 May 2014 22:12:54 +0200 Subject: [PATCH 2/6] parse post.content and add the necessary protocol to images url --- feed.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/feed.xml b/feed.xml index 136e729..7925584 100644 --- a/feed.xml +++ b/feed.xml @@ -4,6 +4,7 @@ layout: none {{ site.title }} + Jekyll {% if site.url != '' and site.url | split: '/' | first != 'http:' and site.url | split: '/' | first != 'https:' %}{% assign url = site.url | prepend: 'http:' %}{% else %}{% assign url = site.url %}{% endif %} @@ -31,7 +32,12 @@ layout: none {{ site.owner.email }} {% for tag in post.tags %}{% endfor %} - {{ post.content | xml_escape }} + + {% if site.url != '' and site.url | split: '/' | first != 'http:' and site.url | split: '/' | first != 'https:' %} + {{ post.content | xml_escape | replace: site.url, url }} + {% else %} + {{ post.content | xml_escape }} + {% endif %} <p><a href="{{ url }}{{ post.url }}">{{ post.title }}</a> was originally published by {{ site.owner.name }} at <a href="{{ url }}">{{ site.title }}</a> on {{ post.date | date: "%B %d, %Y" }}.</p> {% endfor %} From 7f75f13e6f63020bd1e483d7969269e670a254ca Mon Sep 17 00:00:00 2001 From: juego Date: Wed, 14 May 2014 23:20:42 +0200 Subject: [PATCH 3/6] refactored code for clarity --- feed.xml | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/feed.xml b/feed.xml index 7925584..8958714 100644 --- a/feed.xml +++ b/feed.xml @@ -3,42 +3,45 @@ layout: none --- +{% if site.url != '' and + site.url | split: '/' | first != 'http:' and + site.url | split: '/' | first != 'https:' +%} + {% assign site_url = site.url | prepend: 'http:' %} + {% post_content = post.content | xml_escape | replace: site.url, url %} +{% else %} + {% assign site_url = site.url %} + {% post_content = post.content | xml_escape %} +{% endif %} {{ site.title }} - Jekyll -{% if site.url != '' and site.url | split: '/' | first != 'http:' and site.url | split: '/' | first != 'https:' %}{% assign url = site.url | prepend: 'http:' %}{% else %}{% assign url = site.url %}{% endif %} - - + + {{ site.time | date_to_xmlschema }} -{{ url }}/ +{{ site_url }}/ {{ site.owner.name }} - {{ url }}/ + {{ site_url }}/ {{ site.owner.email }} {% for post in site.posts limit:20 %} <![CDATA[{{ post.title | cdata_escape }}]]> - - {{ url }}{{ post.id }} + + {{ site_url }}{{ post.id }} {% if post.modified %}{{ post.modified | to_xmlschema }}T00:00:00-00:00 {{ post.date | date_to_xmlschema }} {% else %}{{ post.date | date_to_xmlschema }} {{ post.date | date_to_xmlschema }}{% endif %} {{ site.owner.name }} - {{ url }} + {{ site_url }} {{ site.owner.email }} - {% for tag in post.tags %}{% endfor %} - - {% if site.url != '' and site.url | split: '/' | first != 'http:' and site.url | split: '/' | first != 'https:' %} - {{ post.content | xml_escape | replace: site.url, url }} - {% else %} - {{ post.content | xml_escape }} - {% endif %} - <p><a href="{{ url }}{{ post.url }}">{{ post.title }}</a> was originally published by {{ site.owner.name }} at <a href="{{ url }}">{{ site.title }}</a> on {{ post.date | date: "%B %d, %Y" }}.</p> + {% for tag in post.tags %}{% endfor %} + {{ post_content }} + <p><a href="{{ site_url }}{{ post.url }}">{{ post.title }}</a> was originally published by {{ site.owner.name }} at <a href="{{ site_url }}">{{ site.title }}</a> on {{ post.date | date: "%B %d, %Y" }}.</p> {% endfor %} From 987f5410132dceb6468a819be488df9fb5d23296 Mon Sep 17 00:00:00 2001 From: juego Date: Wed, 14 May 2014 23:28:46 +0200 Subject: [PATCH 4/6] protocol agnostic url --- _config.yml | 29 +++++++++++++++-------------- feed.xml | 9 +++------ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/_config.yml b/_config.yml index 78ba635..3794e3f 100644 --- a/_config.yml +++ b/_config.yml @@ -1,9 +1,10 @@ title: Site Title description: Describe your website here. logo: site-logo.png -disqus_shortname: +disqus_shortname: search: true # Change url to your domain. Leave localhost server or blank when working locally. +# You don't need to specify the protocol if you want it available on http and https. Example: //localhost:4000 url: http://localhost:4000 # Owner/author information @@ -12,22 +13,22 @@ owner: avatar: bio-photo.jpg email: you@email.com # Social networking links used in footer. Update and remove as you like. - twitter: - facebook: - github: - stackexchange: - linkedin: - instagram: - flickr: - tumblr: + twitter: + facebook: + github: + stackexchange: + linkedin: + instagram: + flickr: + tumblr: # For Google Authorship https://plus.google.com/authorship - google_plus: + google_plus: # Analytics and webmaster tools stuff goes here -google_analytics: -google_verify: +google_analytics: +google_verify: # https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here -bing_verify: +bing_verify: # Links to include in top navigation # For external links add external: true @@ -59,7 +60,7 @@ kramdown: use_coderay: false coderay: - coderay_line_numbers: + coderay_line_numbers: coderay_line_numbers_start: 1 coderay_tab_width: 4 coderay_bold_every: 10 diff --git a/feed.xml b/feed.xml index 8958714..dda7909 100644 --- a/feed.xml +++ b/feed.xml @@ -3,15 +3,12 @@ layout: none --- -{% if site.url != '' and - site.url | split: '/' | first != 'http:' and - site.url | split: '/' | first != 'https:' -%} +{% if site.url != '' and site.url | split: '/' | first != 'http:' and site.url | split: '/' | first != 'https:' %} {% assign site_url = site.url | prepend: 'http:' %} - {% post_content = post.content | xml_escape | replace: site.url, url %} + {% assign post_content = post.content | xml_escape | replace: site.url, url %} {% else %} {% assign site_url = site.url %} - {% post_content = post.content | xml_escape %} + {% assign post_content = post.content | xml_escape %} {% endif %} {{ site.title }} Jekyll From e23ff65532e76ab6ea18ca56fc2b9cabbf68b196 Mon Sep 17 00:00:00 2001 From: juego Date: Thu, 15 May 2014 00:21:33 +0200 Subject: [PATCH 5/6] corrected the out of loop post.content --- feed.xml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/feed.xml b/feed.xml index dda7909..dd11239 100644 --- a/feed.xml +++ b/feed.xml @@ -3,12 +3,12 @@ layout: none --- +{% assign add_protocol = false %} {% if site.url != '' and site.url | split: '/' | first != 'http:' and site.url | split: '/' | first != 'https:' %} {% assign site_url = site.url | prepend: 'http:' %} - {% assign post_content = post.content | xml_escape | replace: site.url, url %} + {% assign add_protocol = true %} {% else %} {% assign site_url = site.url %} - {% assign post_content = post.content | xml_escape %} {% endif %} {{ site.title }} Jekyll @@ -37,7 +37,12 @@ layout: none {{ site.owner.email }} {% for tag in post.tags %}{% endfor %} - {{ post_content }} + + {% if add_protocol %} + {{ post.content | xml_escape | replace: site.url, site_url }} + {% else %} + {{ post.content | xml_escape }} + {% endif %} <p><a href="{{ site_url }}{{ post.url }}">{{ post.title }}</a> was originally published by {{ site.owner.name }} at <a href="{{ site_url }}">{{ site.title }}</a> on {{ post.date | date: "%B %d, %Y" }}.</p> {% endfor %} From 21aa8a491286440841b8dbb2b6f3c228a855b64e Mon Sep 17 00:00:00 2001 From: juego Date: Thu, 15 May 2014 02:09:09 +0200 Subject: [PATCH 6/6] finally if statements works correctly --- feed.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/feed.xml b/feed.xml index dd11239..9a2595d 100644 --- a/feed.xml +++ b/feed.xml @@ -4,7 +4,8 @@ layout: none {% assign add_protocol = false %} -{% if site.url != '' and site.url | split: '/' | first != 'http:' and site.url | split: '/' | first != 'https:' %} +{% assign protocol = site.url | split: '/' | first %} +{% if site.url != '' and protocol != 'http:' and protocol != 'https:' %} {% assign site_url = site.url | prepend: 'http:' %} {% assign add_protocol = true %} {% else %}