|
@@ -12,6 +12,7 @@ try:
|
|
except ImportError:
|
|
except ImportError:
|
|
from urllib import quote
|
|
from urllib import quote
|
|
from pelican import signals, contents
|
|
from pelican import signals, contents
|
|
|
|
+from pelican.generators import ArticlesGenerator, PagesGenerator
|
|
|
|
|
|
|
|
|
|
def article_title(content):
|
|
def article_title(content):
|
|
@@ -40,7 +41,7 @@ def share_post(content):
|
|
|
|
|
|
tweet = ('%s%s%s' % (title, quote(' '), 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)
|
|
diaspora_link = 'https://sharetodiaspora.github.io/?title=%s&url=%s' % (title, url)
|
|
- facebook_link = 'http://www.facebook.com/sharer/sharer.php?s=100&p%%5Burl%%5D=%s' % url
|
|
|
|
|
|
+ facebook_link = 'http://www.facebook.com/sharer/sharer.php?u=%s' % url
|
|
gplus_link = 'https://plus.google.com/share?url=%s' % url
|
|
gplus_link = 'https://plus.google.com/share?url=%s' % url
|
|
twitter_link = 'http://twitter.com/home?status=%s' % tweet
|
|
twitter_link = 'http://twitter.com/home?status=%s' % tweet
|
|
linkedin_link = 'https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s&source=%s' % (
|
|
linkedin_link = 'https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s&source=%s' % (
|
|
@@ -54,13 +55,27 @@ def share_post(content):
|
|
'twitter': twitter_link,
|
|
'twitter': twitter_link,
|
|
'facebook': facebook_link,
|
|
'facebook': facebook_link,
|
|
'google-plus': gplus_link,
|
|
'google-plus': gplus_link,
|
|
- 'linkedin': linkedin_link,
|
|
|
|
|
|
+ 'linkedin': linkedin_link,
|
|
'email': mail_link
|
|
'email': mail_link
|
|
}
|
|
}
|
|
content.share_post = share_links
|
|
content.share_post = share_links
|
|
|
|
|
|
|
|
|
|
-def register():
|
|
|
|
- signals.content_object_init.connect(share_post)
|
|
|
|
|
|
+def run_plugin(generators):
|
|
|
|
+ for generator in generators:
|
|
|
|
+ if isinstance(generator, ArticlesGenerator):
|
|
|
|
+ for article in generator.articles:
|
|
|
|
+ share_post(article)
|
|
|
|
+ elif isinstance(generator, PagesGenerator):
|
|
|
|
+ for page in generator.pages:
|
|
|
|
+ share_post(page)
|
|
|
|
+
|
|
|
|
|
|
|
|
+def register():
|
|
|
|
+ try:
|
|
|
|
+ signals.all_generators_finalized.connect(run_plugin)
|
|
|
|
+ except AttributeError:
|
|
|
|
+ # NOTE: This results in #314 so shouldn't really be relied on
|
|
|
|
+ # https://github.com/getpelican/pelican-plugins/issues/314
|
|
|
|
+ signals.content_object_init.connect(share_post)
|
|
|
|
|