summaryrefslogtreecommitdiffstats
path: root/like
diff options
context:
space:
mode:
authorStefan Ritter <xeno@thehappy.de>2012-02-14 15:13:26 +0100
committerStefan Ritter <xeno@thehappy.de>2012-02-14 15:13:26 +0100
commit94a8e64e801eb1b8126c91240b47e5933494de0e (patch)
tree7f0126ac235b323f29bfbbed8dc1608908561125 /like
Initial releaseHEADmaster
* jquery * like * gitignore
Diffstat (limited to '')
-rw-r--r--like.py48
-rw-r--r--like/icons/facebook.pngbin0 -> 433 bytes
-rw-r--r--like/icons/google-plus.pngbin0 -> 597 bytes
-rw-r--r--like/icons/twitter.pngbin0 -> 418 bytes
4 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:
diff --git a/like/icons/facebook.png b/like/icons/facebook.png
new file mode 100644
index 0000000..5ada323
--- /dev/null
+++ b/like/icons/facebook.png
Binary files differ
diff --git a/like/icons/google-plus.png b/like/icons/google-plus.png
new file mode 100644
index 0000000..1df516c
--- /dev/null
+++ b/like/icons/google-plus.png
Binary files differ
diff --git a/like/icons/twitter.png b/like/icons/twitter.png
new file mode 100644
index 0000000..5020193
--- /dev/null
+++ b/like/icons/twitter.png
Binary files differ