]> git.llucax.com Git - personal/website.git/blobdiff - source/blog/blog.cgi
resume: Use download instead of manual copy
[personal/website.git] / source / blog / blog.cgi
index f59201af49d5c03d521e6871fe2472c689731729..ba9db9fc37a18d1db668f4ddb0b52de92f1264b9 100755 (executable)
@@ -982,6 +982,7 @@ class Article (object):
                        'uuid': self.uuid,
                        'tags': self.get_tags_links(),
                        'comments': len(self.comments),
+                       'flattrbtn': self.get_flattr_btn(),
 
                        'created': self.created.isoformat(' '),
                        'ciso': self.created.isoformat(),
@@ -1011,6 +1012,33 @@ class Article (object):
                                (blog_url, urllib.quote(t), sanitize(t) ))
                return ', '.join(l)
 
+       def get_flattr_btn(self):
+               v = dict()
+               v['tags'] = ','.join([sanitize(tag) for tag in self.tags])
+               v['tags'] = v['tags'].replace('"', '-').replace(':', '-')
+               v['tags'] = v['tags'].replace(';', '-')
+               v['title'] = sanitize(self.title)
+               v['qtitle'] = title.replace('"', '')
+               v['url'] = full_url + '/post/' + self.uuid
+               v['furl'] = 'https://flattr.com/submit/auto?' + urllib.urlencode(
+                               dict(user_id='llucax', url=v['url'],
+                                       title=self.title,
+                                       description="Blog article titled: " +
+                                               self.title,
+                                       language='en', tags=','.join(self.tags),
+                                       category='text'))
+               return '''
+<a class="FlattrButton" style="display:none;"
+   rel="flattr;uid:llucax;category:text;tags:%(tags)s;button:compact;"
+   title="%(qtitle)s" lang="en"
+   href="%(url)s">Blog article titled: %(title)s</a>
+<noscript><a href="%(furl)s" target="_blank">
+        <img src="http://api.flattr.com/button/flattr-badge-large.png"
+            alt="Flattr this" title="Flattr this" border="0" />
+       </a>
+</noscript>
+''' % v
+
 
 class ArticleDB (object):
        def __init__(self, dbpath):