Browse Source

Merge pull request #950 from DEKHTIARJonathan/master

Add HackerNews link to Share Post plugin
Justin Mayer 7 years ago
parent
commit
7aa2b30df7
2 changed files with 32 additions and 21 deletions
  1. 13 3
      share_post/README.md
  2. 19 18
      share_post/share_post.py

+ 13 - 3
share_post/README.md

@@ -11,6 +11,9 @@ Author Email    | talha131@gmail.com
 Author Homepage | http://onCrashReboot.com
 Github Account  | https://github.com/talha131
 
+## Contributors:
+* [Jonathan DEKHTIAR](https://github.com/DEKHTIARJonathan) - contact@jonathandekhtiar.eu
+
 Why do you need it?
 ===================
 
@@ -39,9 +42,12 @@ How to Use
 `article.share_post`. Keys of the dictionary are as follows,
 
 1. `facebook`
-1. `google-plus`
-1. `email`
-1. `twitter`
+2. `google-plus`
+3. `email`
+4. `twitter`
+5. `diaspora`
+6. `linkedin`
+7. `hacker-news`
 
 Template Example
 ================
@@ -59,6 +65,10 @@ Template Example
         <a href="{{article.share_post['google-plus']}}" target="_blank" title="Share on Google Plus">Google+</a>
+        <a href="{{article.share_post['linkedin']}}" target="_blank" title="Share on LinkedIn">LinkedIn</a>
+        ❄
+        <a href="{{article.share_post['hacker-news']}}" target="_blank" title="Share on HackerNews">HackerNews</a>
+        ❄
         <a href="{{article.share_post['email']}}" target="_blank" title="Share via Email">Email</a>
     </p>
 </section>

+ 19 - 18
share_post/share_post.py

@@ -35,29 +35,30 @@ def article_summary(content):
 def share_post(content):
     if isinstance(content, contents.Static):
         return
-    title = article_title(content)
-    url = article_url(content)
+
+    title   = article_title(content)
+    url     = article_url(content)
     summary = article_summary(content)
 
-    diaspora_link = 'https://sharetodiaspora.github.io/?title=%s&url=%s' % (title, url)
-    facebook_link = 'http://www.facebook.com/sharer/sharer.php?u=%s' % url
-    gplus_link = 'https://plus.google.com/share?url=%s' % url
-    twitter_link = 'https://twitter.com/intent/tweet?text=%s&url=%s' % (title, url)
-    linkedin_link = 'https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s&source=%s' % (
+    mail_link       = 'mailto:?subject=%s&amp;body=%s' % (title, url)
+    diaspora_link   = 'https://sharetodiaspora.github.io/?title=%s&url=%s' % (title, url)
+    facebook_link   = 'http://www.facebook.com/sharer/sharer.php?u=%s' % url
+    gplus_link      = 'https://plus.google.com/share?url=%s' % url
+    twitter_link    = 'https://twitter.com/intent/tweet?text=%s&url=%s' % (title, url)
+    hackernews_link = 'https://news.ycombinator.com/submitlink?t=%s&u=%s' % (title, url)
+    linkedin_link   = 'https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s&source=%s' % (
         url, title, summary, url
     )
 
-    mail_link = 'mailto:?subject=%s&amp;body=%s' % (title, url)
-
-    share_links = {
-                   'diaspora': diaspora_link,
-                   'twitter': twitter_link,
-                   'facebook': facebook_link,
-                   'google-plus': gplus_link,
-                   'linkedin': linkedin_link,
-                   'email': mail_link
-                   }
-    content.share_post = share_links
+    content.share_post = {
+        'diaspora'   : diaspora_link,
+        'twitter'    : twitter_link,
+        'facebook'   : facebook_link,
+        'google-plus': gplus_link,
+        'linkedin'   : linkedin_link,
+        'hacker-news': hackernews_link,
+        'email'      : mail_link
+    }
 
 
 def run_plugin(generators):