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

View File

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