3.3.0 • Published 8 months ago

shariff v3.3.0

Weekly downloads
3,393
License
MIT
Repository
github
Last release
8 months ago

Shariff – Give Social Media Buttons Some Privacy Build Status

Shariff enables website users to share their favorite content without compromising their privacy. Demo

Shariff Logo © 2015 Heise Medien

Some social service providers like e.g. Facebook supply official sharing code snippets which quietly siphon personal data from all page visitors. Shariff enables visitors to see how popular your page is on Facebook and share your content with others without needless data leaks.

Shariff (/ˈʃɛɹɪf/) is an open-source, low-maintenance, high-privacy solution maintained by German computer magazine c't and heise online.

Shariff consists of two parts: a simple JavaScript client library and an optional server-side component. The latter fetches the number of likes or shares. Share buttons and share counts work without a connection between your visitors' browsers and social networks (unless they decide to share, of course).

Getting Started

  1. Download the latest release
  2. Upload all files included in the release
  3. Include CSS in <head>:
    • shariff.complete.css uses the dependencies included in the release files
    • if Font Awesome is already included in your site, use build/shariff.min.css
  4. Include JavaScript right before </body>:
    • shariff.complete.js uses the dependencies included in the release files
    • if jQuery is already included in your site, use build/shariff.min.js
  5. Insert one or more <div class="shariff"> elements.
  6. Customize the look using data-* attributes.

To enable the counters in the buttons, see section Backends.

Usage example:

<!DOCTYPE html>
<html>
<head>
    <link href="/path/to/shariff.min.css" rel="stylesheet">
</head>
<body>
    <h1>My article</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>

    <h2>Minimum buttons:</h2>
    <div class="shariff"></div>

    <h2>More advanced buttons:</h2>
    <div class="shariff" data-backend-url="/path/to/backend" data-url="http://www.example.com/my-article.html" data-theme="grey" data-orientation="vertical"></div>

    <!-- immediately before </body> -->
    <script src="/path/to/shariff.min.js"></script>
</body>
</html>

Getting Started using npm

You can also use Shariff's node package by installing it via npm:

$ cd my-project
$ npm install shariff --save

Edit your JS main script, include Shariff and initialize it in one or more containers:

// my-app.js
var Shariff = require('shariff');
var $ = require('jquery');
var buttonsContainer = $('.some-selector');
new Shariff(buttonsContainer, {
    orientation: 'vertical'
});

Running demo site

After downloading Shariff, install its dependencies by running npm install.

$ git clone https://github.com/heiseonline/shariff.git
$ cd shariff
$ npm install
$ npm run dev

Options (data attributes)

AttributeDescriptionDefault
data-backend-urlThe path to your Shariff backend, see below. Setting the value to null disables the backend feature. No counts will occur.null
data-button-styleHow to display the buttons. Values: standard, icon, icon-count. With icon only the icon is shown, with icon-count icon and counter and with standard icon, text and counter are shown, depending on the display size.standard
data-flattr-categoryCategory to be used for Flattr.null
data-flattr-userUser that receives Flattr donation.null
data-info-urlURL of the info page.http://ct.de/-2467514
data-info-displayHow to display the info page. Values: blank, popup, self.blank
data-langThe localisation to use. Available: bg, cs, da, de, en, es, fi, fr, hr, hu, it, ja, ko, nl, no, pl, pt, ro, ru, sk, sl, sr, sv, tr, zhde
data-mail-bodyIf a mailto: link is used in data-mail-url, then this value is used as the mail body. The body text should contain the placeholder {url} which will be replaced with the share URL.see data-url
data-mail-subjectIf a mailto: link is used in data-mail-url, then this value is used as the mail subject.see data-title
data-mail-urlThe url target used for the mail service button?view=mail
data-media-urlMedia url to be shared (pinterest)null
data-orientationvertical will stack the buttons vertically.horizontal
data-referrer-trackA string that will be appended to the share url. Can be disabled using null.null
data-servicesAn entity-encoded JSON string containing an array of service names to be enabled. Example: data-services="[&quot;facebook&quot;,&quot;twitter&quot;]" Available service names: buffer, clipboard, diaspora, facebook, flattr, flipboard, info, linkedin, mail, pinterest, pocket, print, qzone, reddit, stumbleupon, telegram, tencent-weibo, threema, tumblr, twitter, vk, weibo, whatsapp, xingtwitter, facebook, info
data-servicesAn entity-encoded JSON string containing an array of service names to be enabled. Example: data-services="[&quot;facebook&quot;,&quot;twitter&quot;]" Available service names: twitter, facebook, linkedin, pinterest, xing, whatsapp, mail, info, tumblr, flattr, diaspora, reddit, stumbleupon, threema, weibo, tencent-weibo, qzone, print, telegram, vk, flipboard, pocket, buffertwitter, facebook, info
data-themeWe include 3 color schemes, standard, grey and white.standard
data-titleTitle to be used as share text in Twitter/Whatsapppage's DC.title/DC.creator or <title>
data-twitter-viaScreen name of the user to attribute the Tweet tonull
data-urlThe canonical URL of the page to check.page's canonical URL or og:url or current URL

Constructor arguments

All data attributes above are also available as constructor arguments in JavaScript. However, the leading data- is omitted and the name is in camelCase instead of kebab-case:

var buttonsContainer = $('.some-selector');
new Shariff(buttonsContainer, {
    backendUrl: '/my/backend/url',
    orientation: 'vertical',
    mailUrl: 'mailto:me@example.com',
});

Events

Shariff buttons emit the shariff-share event if they are clicked.

$('body').on('shariff-share', function(event) {
    var service = event.details;
    ...
});

This can be used to track shares using analytics software. It is recommended to register the event handler only after the analytics script becomes available.

Piwik example:

(function() {
  var _my_piwik_onload = function() {
    var piwik = this;

    $('body').on('shariff-share', function(event) {
      var service = event.detail;
      piwik.trackEvent('Sharing', service.name);
    });
  }

  _paq.push([ _my_piwik_onload ]);
})();

Supported browsers

Shariff supports the following Browsers:

  • Firefox
  • Google Chrome
  • Internet Explorer/Edge
  • Safari

The current and previous major releases of Firefox, Google Chrome, Internet Explorer/Edge and Safari are supported on a rolling basis.

Supported services

Shariff supports the following social sharing services:

  • buffer
  • diaspora*
  • facebook
  • Flattr
  • Flipboard
  • LinkedIn
  • Mail
  • Pinterest
  • Pocket
  • Print
  • Qzone
  • reddit
  • StumbleUpon
  • Telegram
  • Tencent Weibo
  • Threema
  • Tumblr
  • Twitter
  • VK
  • Weibo
  • WhatsApp
  • XING

In addition, the service Info provides a button to show an info page about the social sharing buttons. The URL of this page can be set with an option. Default value: http://ct.de/-2467514, i.e. the c't article introducing Shariff.

Backends

In order to display share counts with Shariff, you need the following backend:

Third-party backends:

Once you have one of these backends up and running, insert its URL into the data-backend-url attribute. For example, if the backend runs under http://example.com/my-shariff-backend/, the data-backend-url should be /my-shariff-backend/. The script will handle the rest.

Third-party integrations

This is a list of integrations for third-party systems:

3.2.2

8 months ago

3.3.0

8 months ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.1

5 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.4

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

1.26.2

7 years ago

1.26.1

7 years ago

1.26.0

7 years ago

1.25.2

7 years ago

1.25.1

7 years ago

1.24.1

7 years ago

1.24.0

8 years ago

1.23.2

8 years ago

1.23.1

8 years ago

1.23.0

8 years ago

1.22.0

8 years ago

1.21.0

9 years ago

1.20.0

9 years ago

1.19.0

9 years ago

1.18.0

9 years ago

1.17.1

9 years ago

1.17.0

9 years ago

1.16.0

9 years ago

1.15.0

9 years ago

1.14.0

9 years ago

1.13.0

9 years ago

1.12.0

9 years ago

1.11.0

9 years ago

1.10.1

9 years ago

1.10.0

9 years ago

1.9.3

9 years ago

1.9.2

9 years ago

1.9.1

9 years ago

1.9.0

9 years ago

1.8.0

9 years ago

1.7.4

9 years ago

1.7.3

9 years ago

1.7.2

9 years ago

1.7.1

9 years ago

1.7.0

9 years ago

1.6.3

9 years ago

1.6.2

9 years ago

1.6.1

9 years ago

1.6.0

9 years ago

1.5.0

9 years ago

1.4.8

9 years ago

1.4.7

9 years ago

1.4.5

9 years ago

1.4.4

9 years ago

1.4.3

9 years ago

1.4.2

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.5

9 years ago

1.3.4

9 years ago

1.3.3

9 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.2.14

9 years ago

0.2.13

9 years ago

0.2.12

9 years ago

0.2.10

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago