You are here: start » Snippets » dokuwiki » Flattr Plugin

Flattr Plugin

I no longer actively maintain this plugin, it therefore is only provided “as is”.

Description

The flattr plugin provides a syntax for adding a flattr button to arbitrary wiki pages, like the one you see on the right.

The Git repository of the plugin can be found at Github.

Updates

Last updated: 2011/05/31

  • 2011/05/31:
    • Removed restriction to numbers for user id since flattr now demands usage of flattr login name (see also Issue #10). Many thanks to Stéphane Gully for the patch.
  • 2010/08/22:
  • 2010/06/29:
    • Added ability to create static (HTML only) buttons (Implements Issue #4)
  • 2010/06/16:
  • 2010/05/17:
    • Initial release

Installation

With plugin manager

Let the manager do the dirty work, just give him this link to eat: plugin-flattr.tar.gz

Without plugin manager

  1. Download the plugin: plugin-flattr.tar.gz
  2. Extract it into your dokuwiki plugin folder (eg lib/plugins)

Configuration

The flattr plugin has three configurable options:

Option Description
default_uid The default flattr user id to use for the button. Empty by default.
default_category The default category to assign to buttons. Defaults to text.
default_language The default language to assign to buttons. See here for a list of supported languages by flattr. Defaults to en.

Usage

The general command syntax for both is the following:

<flattr>
[parameter1]=[value1]
[parameter2]=[value2]
...
</flattr>

with a shorthand <flattr /> provided that creates a dynamic button using page title, page abstract and configured uid, category and language with a minimum of user input required.

The supported parameters are the following:

Name Description Possible values Default
uid The flattr user id1) for which to create the button. any string Default id as set in the configuration
button The style of the button to display, if a different one is to be used. normal, compact, static normal
align The alignment of the button on the wiki page. left, right or center left
Dynamic mode
title Title of the thing to post to flattr. any string page title
description A description of the thing to post to flattr. any string page abstract
category The category of the thing to post to flattr. text, audio, images, video, software or rest Default category as set in the configuration
language The language of the thing to post to flattr. any string, but see the flattr language listing for languages supported by flattr Default language as set in the configuration
tag A comma-separated list of tags to the assign to the thing on flattr. Optional. any string
url The url of the thing to post, in case it is not the same as the page on which the button is displayed. any string
Static mode
thing The flattr id of the “thing” to link a static button to. See below for an explanation on how to find this. any numeric id

Dynamic vs. static

The flattr plugin allows creation of two types of buttons: dynamic (Javascript based) and static (HTML only) ones. While the dynamic buttons make use of the flattr JavaScript API and by this can take care of registering your “thing” with flattr themselves, the static button needs a little extra work.

First, login onto flattr and add your thing using the "Submit your thing" form. After you have done this, take a look at your newly created thing's url. It will look something like this:

https://flattr.com/thing/<thing's id>/<thing's title>

The ”thing's id” part is what you will need to insert for the thing parameter in your static button. The markup for a static button for the thing created for the flattr plugin (URL: https://flattr.com/thing/2735/DokuWiki-Flattr-Plugin) would thus look something like this2):

<flattr>
button=static
thing=2735
</flattr>

Examples

You can see an example button right on this page 3). The code used to create this one was the following:

<flattr>
title=DokuWiki Flattr Plugin
description=The DokuWiki Flattr Plugin provides a syntax [...] 
category=software
align=right
</flattr>

with the uid and language configured in the settings being used.

Usage from within a template

Thanks to the contribution of Adrian Lang and Andreas Gohr, you can use the new helper plugin function tpl_flattrbtn($params = array(), $ret = false). Using the $params parameter you can define button parameters, missing ones will be automatically inserted (as far as possible, make sure to set the default values for uid, language and category in your configuration in order for this to work properly). Setting $ret to true will return the button embed code instead of directly printing it.

Here is a short example for embedding a compact button in your template:

$flattr =& plugin_load('helper', 'flattr');
$flattr->tpl_flattrbtn(array('button' => 'compact'));
1) the flattr username of the owner of the thing
2) given that I have my uid saved in the plugin configuration
3) try clicking it ;-)

Discussion

sebseb, 2010/06/07 21:39

Hi there,

I would love to have the option to choose between a static and a java button. Would that be possible :?:

fooselfoosel, 2010/06/16 21:04

Should be doable. Just to make sure I don't lose track of this: Could you add it as an issue to the bugtracker please?

Olivier MehaniOlivier Mehani, 2010/06/16 07:53

Shouldn't the plugin also take care of registering/updating the page as a “thing” with Flattr? It would be great!

fooselfoosel, 2010/06/16 21:06

It currently does in a way by using the JS API provided by flattr. If you embed a fresh button on some page, it will be automagically added to flattr once someone flattrs it.

There currently exists no other way to add new items from code, but I'm keeping my hopes hight for the announced REST API and will surely build it in once it becomes possible.

Olivier MehaniOlivier Mehani, 2010/06/17 10:36

Hum, I thought that there may already have been some code to do that, but couldn't quite identify where in the source…

However, what prompted my previous command is that the few pages to which I added the button did not seem to be registered at all. I had to manually submit them to Flattr.

This leads me to my next question: is there any specific extension/option that needs to be installed/enabled within DokuWiki for the automagic registration to work?

fooselfoosel, 2010/06/17 13:35

Nope, there isn't anything you need to enable. But keep in mind that said “automagic registration” is built into the flattr button (which comes from flattr directly and has nothing to do with my plugin) and only happens once someone flattrs your thing. Before this first flattr, the thing won't be registered with flattr and naturally won't show up on any of those listings. If you want your thing to show up on flattrs various listings even before its flattred the first time, you'll have to manually register it and then set the url Parameter in the plugin to the url you used for registering. I have currently no way (in form of an API) to take that step away from you.

Olivier MehaniOlivier Mehani, 2010/06/18 05:16

Ha!

I found the problem. This has indeed nothing to do with your plugin. For some reason, Flattr seems to not really like https URLs in their API. I'll report that directyl to them.

Thanks a lot for the plugin and your answers (:

Olivier MehaniOlivier Mehani, 2010/06/17 10:37

(This is a reply to the previous comment by foosel…)

SocketubsSocketubs, 2010/07/28 12:02

Oh thx for this nice plugin ! :)

I “flattr” you.

DominikDominik, 2010/08/05 23:38

Thanks, nice work! (flattred)

davidakdavidak, 2010/08/21 00:40

How can i add automatically a button on every wiki-page?

Can i integrate it in the template?

fooselfoosel, 2010/08/22 19:59

As of today's release, this is now possible, see this section of the documentation.

Arno WelzelArno Welzel, 2011/05/16 01:37

Hmmm… just registered at Flattr and tried to use your plugin - but it seems, it is either outdated, or Flattr changed things:

1) At least my Flattr UID is not numeric (did they change this?).

2) Flattr provides markup, which shows a static button and a JavaScript version. It would be nice, if the plugin could use this markup - so the button will always be there - either static or dynamic, if possible.

PS: There are better ways to prevent spam than using captchas (e.g. invisible “E-Mail: ”-fields with a note for humans to not to enter anything, which bots will fill, but humans not - so if this field was filled, you know it's a bot… works for me for more than a year).

fooselfoosel, 2011/05/31 18:59

1) They did changed this. The plugin is now adjusted accordingly.

2) Hm… can you provide a link where I can find this markup? I currently can only find the JS-only and the static-only versions, which are already integrated…

Prekates AlexandrosPrekates Alexandros, 2012/01/02 15:46

I tried the plugin in http://librephone.gr/ . The icon will show but is non-responsive.

In the settings as user id i set my account name in flattr.

You could leave a comment if you were logged in.
snippets/dokuwiki/flattr.txt · Last modified: 2013/02/04 19:23 by foosel