fix and re-add facebook share button

gutenberg1
eric 2020-08-28 13:48:30 -04:00
parent 656fdd3063
commit afdb0a1266
2 changed files with 14 additions and 19 deletions

View File

@ -106,7 +106,10 @@ ${site_top()}
<div id="social" class="noprint">
<ul>
<li>
${tw_share (os.canonical_url, os.twit)}
${tw_share(os.canonical_url, os.twit)}
</li>
<li>
${fb_share(os.canonical_url)}
</li>
<li>
<a onclick="printpage()" title="Print this page"><span class="icon icon_print" /></a>

View File

@ -10,48 +10,40 @@
<?python
from six.moves import urllib
def p (params):
return urllib.parse.urlencode (params).replace ('+', '%20')
def p(params):
return urllib.parse.urlencode(params).replace('+', '%20')
?>
<py:def function="fb_share(url, title, description, picture)">
<py:def function="fb_share(url)">
<?python
params = {
'link': url,
'app_id': cherrypy.config['facebook_app_id'],
'name': title,
'description': description,
'redirect_uri': 'https://www.gutenberg.org/fb_redirect.html',
'u': url,
}
if picture is not None:
params['picture'] = picture
?>
<div class="social-button fb-share-button" i18n:comment="Share on Facebook.">
<a href="https://www.facebook.com/dialog/feed?${p (params)}"
<div class="social-button fb-share-button">
<a href="https://www.facebook.com/sharer.php?${p(params)}"
title="Share on Facebook"
onclick="open_share_popup(this.href, this.target, 1024, 560)" target="_fb_share_popup">
onclick="open_share_popup(this.href, this.target, 640, 320)"
target="_top">
<span class="icon icon_facebook" />
</a>
</div>
</py:def>
<py:def function="tw_share(url, text)">
<!-- tweet without javascript -->
<?python
params = {
'url': url,
'text': text.encode ('utf-8'),
'text': text.encode('utf-8'),
'count': 'none',
'lang': os.twitter_lang,
'related': "gutenberg_new:Project Gutenberg New Books"
}
?>
<div class="social-button twitter-share-button">
<!--! https://dev.twitter.com/docs/tweet-button -->
<a href="https://twitter.com/share?${p (params)}"
<a href="https://twitter.com/share?${p(params)}"
title="Share on Twitter"
onclick="open_share_popup(this.href, this.target, 640, 320)"
target="_top">