summaryrefslogtreecommitdiffstats
path: root/like.py
diff options
context:
space:
mode:
Diffstat (limited to 'like.py')
-rw-r--r--like.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/like.py b/like.py
new file mode 100644
index 0000000..20b082f
--- /dev/null
+++ b/like.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# This program is free software. It comes without any warranty, to
+# the extent permitted by applicable law. You can redistribute it
+# and/or modify it under the terms of the Do What The Fuck You Want
+# To Public License, Version 2, as published by Sam Hocevar. See
+# http://sam.zoy.org/wtfpl/COPYING for more details.
+
+# Author: Stefan Ritter <xeno@thehappy.de>
+# Description: Add social network buttons under your entry titles
+# Version: 1.0
+
+print("""
+ <script type="text/javascript">
+ $(document).ready(function() {
+ blog_url = window.location;
+ $("div.entry_title").after(" \\
+ <a target='_blank' class='link_fb'><img src='plugins/like/icons/facebook.png' alt='facebook' /></a> \\
+ <a target='_blank' class='link_gp'><img src='plugins/like/icons/google-plus.png' alt='google-plus' /></a> \\
+ <a target='_blank' class='link_tw'><img src='plugins/like/icons/twitter.png' alt='twitter' /></a> \\
+ ");
+ $('a.link_fb a.link_gp a.link_tw').each(function(i) { // Add index class to all icons
+ $(this).addClass('link_' + i);
+ });
+ $('div.entry_title').each(function(i) { // Add index class to every entry title
+ $(this).addClass('link_' + i);
+ });
+ $('a.link_fb').each(function(i) { // Generate href for facebook icons
+ title = $('div.link_' + i).text().trim();
+ url = blog_url + '?p=' + encodeURIComponent(title.replace(/\s/g, '-'));
+ $(this).attr({'href': 'https://www.facebook.com/sharer.php?u=' + url + '&t=' + title});
+ });
+ $('a.link_gp').each(function(i) { // Generate href for google plus icons
+ title = $('div.link_' + i).text().trim();
+ url = blog_url + '?p=' + encodeURIComponent(title.replace(/\s/g, '-'));
+ $(this).attr({'href': 'https://m.google.com/app/plus/x/?v=compose&content=' + title + '%20' + url});
+ });
+ $('a.link_tw').each(function(i) { // Generate href for twitter icons
+ title = $('div.link_' + i).text().trim();
+ url = blog_url + '?p=' + encodeURIComponent(title.replace(/\s/g, '-'));
+ $(this).attr({'href': 'https://twitter.com/home?status=' + title + ' ' + url});
+ });
+ });
+ </script>
+""")
+
+# vim: set sw=4 tw=0 ts=4 expandtab: