A new Riff-radio.org site with a static approach.

social_buttons.html 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Using Alternative Social Buttons with Nikola | Riff</title>
  7. <link href="../assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
  8. <link rel="alternate" type="application/rss+xml" title="RSS" href="../rss.xml">
  9. <link rel="canonical" href="http://media.pagelibre.org/riff/site/pages/social_buttons.html">
  10. <link rel="icon" href="../favicon.ico" sizes="16x16">
  11. <!--[if lt IE 9]><script src="../assets/js/html5.js"></script><![endif]--><meta name="author" content="The Nikola Team">
  12. <meta property="og:site_name" content="Riff">
  13. <meta property="og:title" content="Using Alternative Social Buttons with Nikola">
  14. <meta property="og:url" content="http://media.pagelibre.org/riff/site/pages/social_buttons.html">
  15. <meta property="og:description" content='Version:
  16. 8.2.3
  17. Contents
  18. The Default
  19. ShareNice
  20. SocialSharePrivacy
  21. The Hard Way
  22. The Easy Way
  23. The Default
  24. By Default, the themes provided with Nikola will add to your pages a "slide in" widget a'>
  25. <meta property="og:type" content="article">
  26. <meta property="article:published_time" content="2013-08-19T23:00:00-03:00">
  27. </head>
  28. <body>
  29. <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
  30. <!-- Menubar -->
  31. <div class="blog-masthead">
  32. <div class="container">
  33. <!-- This keeps the margins nice -->
  34. <nav class="blog-nav" role="navigation"><a href="../index.html" class="blog-nav-item">Accueil</a>
  35. <a href="about.html" class="blog-nav-item">About Riff</a>
  36. <a href="../rss.xml" class="blog-nav-item">RSS feed</a>
  37. </nav>
  38. </div>
  39. <!-- /.container -->
  40. </div>
  41. <!-- End of Menubar -->
  42. <div class="container" id="content" role="main">
  43. <div class="body-content">
  44. <div class="blog-header">
  45. <h1 class="blog-title">
  46. <a href="http://media.pagelibre.org/riff/site/">
  47. <span id="blog-title">Riff</span>
  48. </a>
  49. </h1>
  50. <p class="lead blog-description">Riff la radio rock</p>
  51. </div>
  52. <!--Body content-->
  53. <div class="row">
  54. <div class="col-sm-8 blog-main">
  55. <article class="post-text storypage" itemscope="itemscope" itemtype="http://schema.org/Article"><header><h2 class="p-name entry-title blog-post-title" itemprop="headline name"><a href="#" class="u-url">Using Alternative Social Buttons with Nikola</a></h2>
  56. </header><div class="e-content entry-content" itemprop="articleBody text">
  57. <dl class="docinfo simple">
  58. <dt class="version">Version<span class="colon">:</span>
  59. </dt>
  60. <dd class="version">8.2.3</dd>
  61. </dl>
  62. <nav class="contents alert alert-primary float-md-right" id="contents" role="doc-toc"><p class="topic-title">Contents</p>
  63. <ul class="simple">
  64. <li><p><a class="reference internal" href="social_buttons.html#the-default" id="toc-entry-1">The Default</a></p></li>
  65. <li><p><a class="reference internal" href="social_buttons.html#sharenice" id="toc-entry-2">ShareNice</a></p></li>
  66. <li>
  67. <p><a class="reference internal" href="social_buttons.html#socialshareprivacy" id="toc-entry-3">SocialSharePrivacy</a></p>
  68. <ul>
  69. <li><p><a class="reference internal" href="social_buttons.html#the-hard-way" id="toc-entry-4">The Hard Way</a></p></li>
  70. <li><p><a class="reference internal" href="social_buttons.html#the-easy-way" id="toc-entry-5">The Easy Way</a></p></li>
  71. </ul>
  72. </li>
  73. </ul></nav><section id="the-default"><h2><a class="toc-backref" href="social_buttons.html#toc-entry-1" role="doc-backlink">The Default</a></h2>
  74. <p>By Default, the themes provided with Nikola will add to your pages a "slide in" widget at
  75. the bottom right of the page, provided by Addthis. This is the HTML code for that:</p>
  76. <pre class="code html"><a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-1"></a><span class="c">&lt;!-- Social buttons --&gt;</span>
  77. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-2"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">"addthisbox"</span> <span class="na">class</span><span class="o">=</span><span class="s">"addthis_toolbox addthis_peekaboo_style</span>
  78. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-3"></a><span class="s"> addthis_default_style addthis_label_style addthis_32x32_style"</span><span class="p">&gt;</span>
  79. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-4"></a><span class="p">&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"addthis_button_more"</span><span class="p">&gt;</span>Share<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  80. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-5"></a><span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"addthis_button_facebook"</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  81. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-6"></a><span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"addthis_button_google_plusone_share"</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  82. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-7"></a><span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"addthis_button_linkedin"</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  83. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-8"></a><span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"addthis_button_twitter"</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  84. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-9"></a><span class="p">&lt;/</span><span class="nt">ul</span><span class="p">&gt;</span>
  85. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-10"></a><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  86. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-11"></a><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f7088a56bb93798"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  87. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-12"></a><span class="c">&lt;!-- End of social buttons --&gt;</span>
  88. <a name="rest_code_fdbd4b2582b34ec78f82fe9fab67f0d6-13"></a>"""
  89. </pre>
  90. <p>You can change that using the <code class="docutils literal">SOCIAL_BUTTONS_CODE</code> option in your conf.py. In some cases, just
  91. doing that will be enough but in others, it won't. This document tries to describe all the bits
  92. involved in making this work correctly.</p>
  93. <dl>
  94. <dt>Part 1: <code class="docutils literal">SOCIAL_BUTTONS_CODE</code>
  95. </dt>
  96. <dd>
  97. <p>Social sharing services like addthis and others will provide you a HTML snippet.
  98. If it is self-contained, then just setting <code class="docutils literal">SOCIAL_BUTTONS_CODE</code> may be enough.
  99. Try :-)</p>
  100. </dd>
  101. <dt>Part 2: The theme</dt>
  102. <dd>
  103. <p>The <code class="docutils literal">SOCIAL_BUTTONS_CODE</code> HTML fragment will be embedded <em>somewhere</em> by the theme. Whether that
  104. is the correct place or not is not something the theme author can truly know, so it is possible that
  105. you may have to tweak the <code class="docutils literal">base.html</code> template to make it look good.</p>
  106. </dd>
  107. <dt>Part 3: <code class="docutils literal">BODY_END</code> and <code class="docutils literal">EXTRA_HEAD_DATA</code>
  108. </dt>
  109. <dd>
  110. <p>Some social sharing code requires JS execution that depends on JQuery being available
  111. (example: <a class="reference external" href="https://github.com/panzi/SocialSharePrivacy">SocialSharePrivacy</a>). It's good
  112. practice (and often, the only way that will work) to put those at the end of <code class="docutils literal">&lt;BODY&gt;</code>,
  113. and one easy way to do that is to put them in <code class="docutils literal">BODY_END</code></p>
  114. <p>On the other hand, it's possible that it requires you to load some CSS files.
  115. The right place for that is in the document's <code class="docutils literal">&lt;HEAD&gt;</code> so they should be added
  116. in <code class="docutils literal">EXTRA_HEAD_DATA</code></p>
  117. </dd>
  118. <dt>Part 4: assets</dt>
  119. <dd>
  120. <p>For sharing code that doesn't rely on a social sharing service, you may need to add CSS, Image, or JS
  121. files to your site</p>
  122. </dd>
  123. </dl></section><section id="sharenice"><h2><a class="toc-backref" href="social_buttons.html#toc-entry-2" role="doc-backlink">ShareNice</a></h2>
  124. <p><a class="reference external" href="https://graingert.co.uk/shareNice/">ShareNice</a> is "written in order to provide social sharing features to
  125. web developers and website administrators who wish to maintain and protect their users' privacy"
  126. which sounds cool to me.</p>
  127. <p>Let's go step by step into integrating the hosted version of ShareNice into a Nikola site.</p>
  128. <p>For testing purposes, let's do it on a demo site:</p>
  129. <pre class="literal-block">$ nikola init --demo sharenice_test
  130. A new site with example data has been created at sharenice_test.
  131. See README.txt in that folder for more information.
  132. $ cd sharenice_test/</pre>
  133. <p>To see what's going on, let's start Nikola in "auto mode". This should build the
  134. site and open a web browser showing the default configuration, with the AddThis widget:</p>
  135. <pre class="literal-block">$ nikola auto -b</pre>
  136. <p>First, let's add the HTML snippet that will show the sharing options. In your conf.py, set this, which
  137. is the HTML code suggested by ShareNice:</p>
  138. <pre class="code python"><a name="rest_code_d45bd5e47f254bfeb9aa565ed399def8-1"></a><span class="n">SOCIAL_BUTTONS_CODE</span> <span class="o">=</span> <span class="s2">"""&lt;div id="shareNice" data-share-label="Share"</span>
  139. <a name="rest_code_d45bd5e47f254bfeb9aa565ed399def8-2"></a><span class="s2"> data-color-scheme="black" data-icon-size="32" data-panel-bottom="plain"</span>
  140. <a name="rest_code_d45bd5e47f254bfeb9aa565ed399def8-3"></a><span class="s2"> data-services="plus.google.com,facebook.com,digg.com,email,delicious.com,twitter.com"</span>
  141. <a name="rest_code_d45bd5e47f254bfeb9aa565ed399def8-4"></a><span class="s2"> style="float:right"&gt;&lt;/div&gt;"""</span>
  142. <a name="rest_code_d45bd5e47f254bfeb9aa565ed399def8-5"></a>
  143. <a name="rest_code_d45bd5e47f254bfeb9aa565ed399def8-6"></a><span class="n">BODY_END</span> <span class="o">=</span> <span class="s2">"""&lt;script src="https://graingert.co.uk/shareNice/code.js"&gt;&lt;/script&gt;"""</span>
  144. </pre>
  145. <p>And you should now see a sharing box at the bottom right of the page.</p>
  146. <p>Main problem remaining is that it doesn't really look good and integrated in the page layout.
  147. I suggest changing the code to this which looks nicer, but still has some placement issues:</p>
  148. <pre class="code python"><a name="rest_code_b749fc146e7e47cc8686e5aaf4c038f1-1"></a><span class="n">SOCIAL_BUTTONS_CODE</span> <span class="o">=</span> <span class="s2">"""&lt;div id="shareNice" data-share-label="Share"</span>
  149. <a name="rest_code_b749fc146e7e47cc8686e5aaf4c038f1-2"></a><span class="s2"> data-color-scheme="black" data-icon-size="32" data-panel-bottom="plain"</span>
  150. <a name="rest_code_b749fc146e7e47cc8686e5aaf4c038f1-3"></a><span class="s2"> data-services="plus.google.com,facebook.com,email,twitter.com"</span>
  151. <a name="rest_code_b749fc146e7e47cc8686e5aaf4c038f1-4"></a><span class="s2"> style="position: absolute; left: 20px; top: 60px;"&gt;&lt;/div&gt;"""</span>
  152. </pre>
  153. <p>If anyone comes up with a better idea of styling/placement, just let me know ;-)</p>
  154. <p>One bad bit of this so far is that you are now using a script from another site, and that
  155. doesn't let Nikola perform as many optimizations to your page as it could.
  156. So, if you really want to go the extra mile to save a few KB and round trips, you <em>could</em>
  157. install your own copy from the <a class="reference external" href="https://github.com/mischat/shareNice">github repo</a> and
  158. use that instead of the copy at <a class="reference external" href="https://graingert.co.uk/shareNice">ShareNice</a>.</p>
  159. <p>Then, you can create your own theme inheriting from the one you are using and add the CSS
  160. and JS files from ShareNice into your <code class="docutils literal">bundles</code> configuration so they are combined and
  161. minified.</p>
  162. </section><section id="socialshareprivacy"><h2><a class="toc-backref" href="social_buttons.html#toc-entry-3" role="doc-backlink">SocialSharePrivacy</a></h2>
  163. <section id="the-hard-way"><h3><a class="toc-backref" href="social_buttons.html#toc-entry-4" role="doc-backlink">The Hard Way</a></h3>
  164. <p><a class="reference external" href="https://github.com/panzi/SocialSharePrivacy">SocialSharePrivacy</a> is "a jQuery plugin that
  165. lets you add social share buttons to your website that don't allow the social sites to track
  166. your users." Nice!</p>
  167. <p>Let's go step-by-step into integrating SocialSharePrivacy into a Nikola site. To improve
  168. privacy, they recommend you not use the hosted service so we'll do it the hard way, by
  169. getting and distributing everything in our own site.</p>
  170. <p><a class="reference external" href="https://github.com/panzi/SocialSharePrivacy">https://github.com/panzi/SocialSharePrivacy</a></p>
  171. <p>For testing purposes, let's do it on a demo site:</p>
  172. <pre class="literal-block">$ nikola init --demo ssp_test
  173. A new site with example data has been created at ssp_test.
  174. See README.txt in that folder for more information.
  175. $ cd ssp_test/</pre>
  176. <p>To see what's going on, let's start Nikola in "auto mode". This should build the
  177. site and open a web browser showing the default configuration, with the AddThis widget:</p>
  178. <pre class="literal-block">$ nikola auto -b</pre>
  179. <p>Now, download <a class="reference external" href="https://github.com/panzi/SocialSharePrivacy/archive/master.zip">the current version</a>
  180. and unzip it. You will have a <code class="docutils literal"><span class="pre">SocialSharePrivacy-master</span></code> folder with lots of stuff in it.</p>
  181. <p>First, we need to build it (this requires a working and modern uglifyjs, this may not be easy):</p>
  182. <pre class="literal-block">$ cd SocialSharePrivacy-master
  183. $ sh build.sh -m gplus,twitter,facebook,mail -s "/assets/css/socialshareprivacy.css" -a off</pre>
  184. <p>You will now have several files in a <code class="docutils literal">build</code> folder. We need to bring them into the site:</p>
  185. <pre class="literal-block">$ cp -Rv SocialSharePrivacy-master/build/* files/
  186. $ cp -R SocialSharePrivacy-master/images/ files/assets/</pre>
  187. <p>Edit your <code class="docutils literal">conf.py</code>:</p>
  188. <pre class="code python"><a name="rest_code_65b770dc716e498eb31cf1abee0d274c-1"></a><span class="n">BODY_END</span> <span class="o">=</span> <span class="s2">"""</span>
  189. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-2"></a><span class="s2">&lt;script src="/javascripts/jquery.socialshareprivacy.min.js"&gt;&lt;/script&gt;</span>
  190. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-3"></a><span class="s2">&lt;script&gt;</span>
  191. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-4"></a><span class="s2">$(document).ready(function () {</span>
  192. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-5"></a><span class="s2"> $('.share').socialSharePrivacy();</span>
  193. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-6"></a><span class="s2">});</span>
  194. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-7"></a><span class="s2">&lt;/script&gt;</span>
  195. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-8"></a><span class="s2">"""</span>
  196. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-9"></a>
  197. <a name="rest_code_65b770dc716e498eb31cf1abee0d274c-10"></a><span class="n">SOCIAL_BUTTONS_CODE</span> <span class="o">=</span> <span class="s2">"""&lt;div class="share"&gt;&lt;/div&gt;"""</span>
  198. </pre>
  199. <p>In my experience this produces a broken, duplicate, semi-working thing. YMMV and if you make it work correctly, let me know how :-)</p>
  200. </section><section id="the-easy-way"><h3><a class="toc-backref" href="social_buttons.html#toc-entry-5" role="doc-backlink">The Easy Way</a></h3>
  201. <p>Go to <a class="reference external" href="https://panzi.github.io/SocialSharePrivacy/">https://panzi.github.io/SocialSharePrivacy/</a> and use the provided form to get the code. Make sure you check "I already use JQuery"
  202. if you are using one of the themes that require it, like site or default, select the services you want, and use your disqus name if
  203. you have one.</p>
  204. <p>It will give you 3 code snippets:</p>
  205. <dl class="simple">
  206. <dt>"Insert this once in the head of your page"</dt>
  207. <dd>
  208. <p>Put it in <code class="docutils literal">BODY_END</code></p>
  209. </dd>
  210. <dt>"Insert this wherever you want a share widget displayed"</dt>
  211. <dd>
  212. <p>Put it in <code class="docutils literal">SOCIAL_BUTTONS_CODE</code></p>
  213. </dd>
  214. <dt>"Insert this once anywhere after the other code"</dt>
  215. <dd>
  216. <p>Put it in <code class="docutils literal">BODY_END</code></p>
  217. </dd>
  218. </dl>
  219. <p>That should give you a working integration (not tested)</p>
  220. </section></section>
  221. </div>
  222. </article>
  223. </div>
  224. <div class="col-sm-3 col-sm-offset-1 blog-sidebar">
  225. <div class="sidebar-module sidebar-module-inset">
  226. <h4>About</h4>
  227. <div id="shoutcastdiv">
  228. <script type="text/javascript">
  229. refreshdiv();
  230. </script>
  231. </div>
  232. </div>
  233. <div class="sidebar-module">
  234. <h4>Links</h4>
  235. <ol class="list-unstyled">
  236. <li><a href="http://getbootstrap.com/examples/blog/">Bootstrap Blog Theme</a></li>
  237. <li><a href="https://getnikola.com/">Nikola</a></li>
  238. <li><a href="https://twitter.com/mdo">@mdo</a></li>
  239. <li><a href="https://twitter.com/Kwpolska">@Kwpolska</a></li>
  240. <li><a href="https://twitter.com/GetNikola">@GetNikola</a></li>
  241. </ol>
  242. </div>
  243. </div>
  244. <!--End of body content-->
  245. </div>
  246. </div>
  247. </div>
  248. <footer class="blog-footer" id="footer">
  249. Contents © 2023 <a href="mailto:contact@riff-radio.org">Riff</a> - Powered by <a href="https://getnikola.com" rel="nofollow">Nikola</a>
  250. </footer><script src="../assets/js/all-nocdn.js"></script><!-- fancy dates --><script>
  251. moment.locale("en");
  252. fancydates(0, "YYYY-MM-DD HH:mm");
  253. </script><!-- end fancy dates --><script>
  254. baguetteBox.run('div#content', {
  255. ignoreClass: 'islink',
  256. captions: function(element) {
  257. return element.getElementsByTagName('img')[0].alt;
  258. }});
  259. </script><script type="text/javascript" src="../refresh.js"></script>
  260. </body>
  261. </html>