ソースを参照

Merge pull request #390 from muggenhor/share-post-update

Share post: fix twitter quoting and add Diaspora support
Justin Mayer 10 年 前
コミット
a17e9ec953
共有2 個のファイルを変更した7 個の追加2 個の削除を含む
  1. 2 0
      share_post/README.md
  2. 5 2
      share_post/share_post.py

+ 2 - 0
share_post/README.md

@@ -51,6 +51,8 @@ Template Example
 <section>
     <p id="post-share-links">
         Share on:
+        <a href="{{article.share_post['diaspora']}}" target="_blank" title="Share on Diaspora">Diaspora*</a>
+        ❄
         <a href="{{article.share_post['twitter']}}" target="_blank" title="Share on Twitter">Twitter</a>
         <a href="{{article.share_post['facebook']}}" target="_blank" title="Share on Facebook">Facebook</a>

+ 5 - 2
share_post/share_post.py

@@ -38,13 +38,16 @@ def share_post(content):
     url = article_url(content)
     summary = article_summary(content)
 
-    tweet = quote(('%s %s' % (title, url)).encode('utf-8'))
+    tweet = ('%s%s%s' % (title, quote(' '), url)).encode('utf-8')
+    diaspora_link = 'https://sharetodiaspora.github.io/?title=%s&url=%s' % (title, url)
     facebook_link = 'http://www.facebook.com/sharer/sharer.php?s=100&amp;p%%5Burl%%5D=%s' % url
     gplus_link = 'https://plus.google.com/share?url=%s' % url
     twitter_link = 'http://twitter.com/home?status=%s' % tweet
     mail_link = 'mailto:?subject=%s&amp;body=%s' % (title, url)
 
-    share_links = {'twitter': twitter_link,
+    share_links = {
+                   'diaspora': diaspora_link,
+                   'twitter': twitter_link,
                    'facebook': facebook_link,
                    'google-plus': gplus_link,
                    'email': mail_link