From 92a5df6e3ac3df4108607f70930f5b1e6ff94f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 1 Nov 2014 13:25:14 +0100 Subject: [PATCH] move flattr code to external files --- ...013-01-20-add-flattr-to-octopress.markdown | 155 +----------------- source/downloads/code/flattr/atom.xml | 25 +++ source/downloads/code/flattr/atom2.xml | 26 +++ .../downloads/code/flattr/flattr_buttom.html | 9 + .../code/flattr/flattr_feed_buttom.html | 5 + .../downloads/code/flattr/flattr_param.html | 13 ++ source/downloads/code/flattr/head.html | 13 ++ source/downloads/code/flattr/head2.html | 16 ++ source/downloads/code/flattr/sharing.html | 6 + 9 files changed, 122 insertions(+), 146 deletions(-) create mode 100644 source/downloads/code/flattr/atom.xml create mode 100644 source/downloads/code/flattr/atom2.xml create mode 100644 source/downloads/code/flattr/flattr_buttom.html create mode 100644 source/downloads/code/flattr/flattr_feed_buttom.html create mode 100644 source/downloads/code/flattr/flattr_param.html create mode 100644 source/downloads/code/flattr/head.html create mode 100644 source/downloads/code/flattr/head2.html create mode 100644 source/downloads/code/flattr/sharing.html diff --git a/source/_posts/2013-01-20-add-flattr-to-octopress.markdown b/source/_posts/2013-01-20-add-flattr-to-octopress.markdown index f6e7ab1..93d0a2e 100644 --- a/source/_posts/2013-01-20-add-flattr-to-octopress.markdown +++ b/source/_posts/2013-01-20-add-flattr-to-octopress.markdown @@ -25,52 +25,15 @@ flattr_user: YourFlattrName ``` To add a flattr button to the sharing section of your posts, add this template: -{% raw %} -``` html source/_includes/post/flattr_button.html - -``` -{% endraw %} +{% include_code source/_includes/post/flattr_button.html lang:html flattr/flattr_buttom.html %} and add the following javascript to your custom head.html -{% raw %} -``` html source/_includes/custom/head.html - {% if site.flattr_user %} - - {% endif %} -``` -{% endraw %} +{% include_code source/_includes/custom/head.html lang:html flattr/head.html %} Now include it in your sharing template: -{% raw %} -``` html source/_includes/post/sharing.html -
- {% if site.flattr_user %} - {% include post/flattr_button.html %} - {% endif %} - ... -
-``` -{% endraw %} +{% include_code source/_includes/post/sharing.html lang:html flattr/sharing.html %} The result will look like this: @@ -90,134 +53,34 @@ To make flattr discoverable by programs (feed reader, podcatcher, browser extens First add this (lengthy) template... -{% raw %} -``` html source/_includes/flattr_param.html -{% if post %} -{% assign item = post %} -{% else %} -{% assign item = page %} -{% endif %} - -{% capture flattr_url %}{{ site.url }}{{ item.url }}{% endcapture %} - -{% capture flattr_title %}{% if item.title %}{{ item.title }}{% else %}{{ site.title }}{% endif %}{% endcapture %} - -{% capture flattr_description %}{% if item.description %}{{ item.description}}{% else index == true %}{{ site.description }}{% endif %}{% endcapture %} - -{% capture flattr_param %}url={{ flattr_url | cgi_escape }}&user_id={{site.flattr_user | cgi_escape }}&title={{ flattr_title | cgi_escape }}&category=text&description={{ flattr_description | truncate: 1000 | cgi_escape }}&tags={{ item.categories | join: "," | cgi_escape }}{% endcapture %} -``` -{% endraw %} +{% include_code source/_includes/flattr_param.html lang:html flattr/flattr_param.html %} ... then include it in your feed ... -{% raw %} -``` xml source/atom.xml ---- -layout: null ---- - - - <![CDATA[{{ site.title }}]]> - - ... - - {% for post in site.posts limit: 20 %} - - <![CDATA[{{ post.title | cdata_escape }}]]> - - {{ post.date | date_to_xmlschema }} - {{ site.url }}{{ post.id }} - {% if site.flattr_user %} - {% include flattr_param.html %} - - {% endif %} - - - {% endfor %} - -``` -{% endraw %} +{% include_code source/atom.xml lang:xml flattr/atom.xml %} and in your head template: -{% raw %} -``` html source/_includes/custom/head.html -{% if site.flattr_user %} - - -{% include flattr_param.html %} - -{% endif %} -``` -{% endraw %} +{% include_code source/_includes/custom/head.html lang:html flattr/head2.html %} Because not (yet) all feed reader support this feature, you can add a dedicated flattr link. Therefor create a new template: -{% raw %} -```html source/_includes/flattr_feed_button.html -{% include flattr_param.html %} - - Flattr this - -``` -{% endraw %} +{% include_code source/_includes/flattr_feed_button.html lang:html flattr/flattr_feed_buttom.html %} Compared to the other button, this one will not require javascript, which isn't always available in feed readers. Finally add it your feed template: -{% raw %} -``` xml source/atom.xml ---- -layout: null ---- - - - <![CDATA[{{ site.title }}]]> - - ... - - {% for post in site.posts limit: 20 %} - - <![CDATA[{{ post.title | cdata_escape }}]]> - - {{ post.date | date_to_xmlschema }} - {{ site.url }}{{ post.id }} - {% if site.flattr_user %} - {% include flattr_param.html %} - - {% endif %} - - - {% endfor %} - -``` -{% endraw %} +{% include_code source/atom.xml lang:xml flattr/atom2.xml %} This will add a flattr button to each entry in your feed. Preview: {% include flattr_param.html %} -[{% img left https://api.flattr.com/button/flattr-badge-large.png Alt Flattr this %}](https://flattr.com/submit/auto?{{ flattr_param }}) +[{% img left //api.flattr.com/button/flattr-badge-large.png Alt Flattr this %}](https://flattr.com/submit/auto?{{ flattr_param }}) That's all folks! I hope you will become rich by your flattr income. diff --git a/source/downloads/code/flattr/atom.xml b/source/downloads/code/flattr/atom.xml new file mode 100644 index 0000000..528e748 --- /dev/null +++ b/source/downloads/code/flattr/atom.xml @@ -0,0 +1,25 @@ +--- +layout: null +--- + + + <![CDATA[{{ site.title }}]]> + + ... + + {% for post in site.posts limit: 20 %} + + <![CDATA[{{ post.title | cdata_escape }}]]> + + {{ post.date | date_to_xmlschema }} + {{ site.url }}{{ post.id }} + {% if site.flattr_user %} + {% include flattr_param.html %} + + {% endif %} + + + {% endfor %} + diff --git a/source/downloads/code/flattr/atom2.xml b/source/downloads/code/flattr/atom2.xml new file mode 100644 index 0000000..218e4bd --- /dev/null +++ b/source/downloads/code/flattr/atom2.xml @@ -0,0 +1,26 @@ +--- +layout: null +--- + + + <![CDATA[{{ site.title }}]]> + + ... + + {% for post in site.posts limit: 20 %} + + <![CDATA[{{ post.title | cdata_escape }}]]> + + {{ post.date | date_to_xmlschema }} + {{ site.url }}{{ post.id }} + {% if site.flattr_user %} + {% include flattr_param.html %} + + {% endif %} + + + {% endfor %} + diff --git a/source/downloads/code/flattr/flattr_buttom.html b/source/downloads/code/flattr/flattr_buttom.html new file mode 100644 index 0000000..c0a1841 --- /dev/null +++ b/source/downloads/code/flattr/flattr_buttom.html @@ -0,0 +1,9 @@ + diff --git a/source/downloads/code/flattr/flattr_feed_buttom.html b/source/downloads/code/flattr/flattr_feed_buttom.html new file mode 100644 index 0000000..cadaac8 --- /dev/null +++ b/source/downloads/code/flattr/flattr_feed_buttom.html @@ -0,0 +1,5 @@ +{% include flattr_param.html %} + + Flattr this + diff --git a/source/downloads/code/flattr/flattr_param.html b/source/downloads/code/flattr/flattr_param.html new file mode 100644 index 0000000..2be74ba --- /dev/null +++ b/source/downloads/code/flattr/flattr_param.html @@ -0,0 +1,13 @@ +{% if post %} +{% assign item = post %} +{% else %} +{% assign item = page %} +{% endif %} + +{% capture flattr_url %}{{ site.url }}{{ item.url }}{% endcapture %} + +{% capture flattr_title %}{% if item.title %}{{ item.title }}{% else %}{{ site.title }}{% endif %}{% endcapture %} + +{% capture flattr_description %}{% if item.description %}{{ item.description}}{% else index == true %}{{ site.description }}{% endif %}{% endcapture %} + +{% capture flattr_param %}url={{ flattr_url | cgi_escape }}&user_id={{site.flattr_user | cgi_escape }}&title={{ flattr_title | cgi_escape }}&category=text&description={{ flattr_description | truncate: 1000 | cgi_escape }}&tags={{ item.categories | join: "," | cgi_escape }}{% endcapture %} diff --git a/source/downloads/code/flattr/head.html b/source/downloads/code/flattr/head.html new file mode 100644 index 0000000..242fc28 --- /dev/null +++ b/source/downloads/code/flattr/head.html @@ -0,0 +1,13 @@ +{% if site.flattr_user %} + +{% endif %} diff --git a/source/downloads/code/flattr/head2.html b/source/downloads/code/flattr/head2.html new file mode 100644 index 0000000..f8dd9fd --- /dev/null +++ b/source/downloads/code/flattr/head2.html @@ -0,0 +1,16 @@ +{% if site.flattr_user %} + + +{% include flattr_param.html %} + +{% endif %} diff --git a/source/downloads/code/flattr/sharing.html b/source/downloads/code/flattr/sharing.html new file mode 100644 index 0000000..7cea4ca --- /dev/null +++ b/source/downloads/code/flattr/sharing.html @@ -0,0 +1,6 @@ +
+ {% if site.flattr_user %} + {% include post/flattr_button.html %} + {% endif %} + ... +