Create a gist now

Instantly share code, notes, and snippets.

Google Gadget for Flattr.
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Flattr button" author="Stefan Sundin" width="55" height="62" scrolling="false"></ModulePrefs>
<UserPref name="url" datatype="string" default_value="" />
<UserPref name="uid" datatype="string" default_value="" />
<UserPref name="title" datatype="string" default_value="" />
<UserPref name="desc" datatype="string" default_value="" />
<UserPref name="cat" datatype="string" default_value="software" />
<UserPref name="lang" datatype="string" default_value="en_GB" />
<UserPref name="tags" datatype="string" default_value="" />
<UserPref name="button" datatype="string" default_value="" />
<UserPref name="https" datatype="string" default_value="" />
<UserPref name="hidden" datatype="string" default_value="" />
<Content type="html">
<![CDATA[
<style type="text/css">
body {
overflow: hidden;
}
</style>
<script type="text/javascript">
//Get options
var prefs = new gadgets.Prefs();
var options = {
uid: prefs.getString("uid"),
url: prefs.getString("url"),
title: prefs.getString("title"),
description: prefs.getString("desc"),
category: prefs.getString("cat"),
language: prefs.getString("lang"),
tags: prefs.getString("tags"),
button: prefs.getString("button"),
hidden: prefs.getString("hidden")
};
//IE
if (!window.innerWidth && document.body.offsetWidth) {
window.innerWidth = document.body.offsetWidth;
window.innerHeight = document.body.offsetHeight;
}
//Auto-detect compact button
if (options.button == "" && (window.innerWidth && window.innerWidth > 100)) {
options.button = "compact";
}
//https
var https = prefs.getString("https");
if (https == "" && document.location.protocol == "https:") {
https = 1;
}
//Load API
var ga = document.createElement("script");
ga.type = "text/javascript";
ga.async = true;
ga.src = (https?"https:":"http:")+"//api.flattr.com/js/0.6/load.js";
ga.onload = addbutton;
ga.onreadystatechange = function() { //Stupid IE :-(
if (this.readyState == "loaded" || this.readyState == "complete") {
addbutton();
}
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(ga, s);
//Failsafe if script onload trigger doesn't fire
var failsafe = setTimeout(addbutton, 5000);
//Add button
function addbutton() {
clearTimeout(failsafe);
FlattrLoader.render(options, "button", "replace");
}
</script>
<div id="button"></div>
]]>
</Content>
</Module>
Flattr button for Google Project Hosting
This button was originally intended for Google Project Hosting, but it should be usable wherever you can use Google Gadgets.
You can use either the usual button or the compact button.
You can specify all the parameters which are available in the official JavaScript API:
up_url - This is the URL of the thing, if this is not always the same on your site. Maybe you have multiple domains with the same content. This is to lock the content to always be recognized as the same content for Flattr.
up_uid - This is your personal user id. You can also use your username.
up_title - This is the title of the thing you want to submit. This is typically the name of your software.
up_desc - This is the description of your thing.
up_cat - (Optional) This is the flattr category the content belongs to. You can choose between the following: text, images, video, audio, software, rest. If you don't specify a category, this gadget will automatically choose software.
up_lang - (Optional) Language of the submitted thing. If you don't specify a language, en_GB (English) is automatically chosen. See a list of all languages here (use the code on the left): http://developers.flattr.net/api/resources/languages/
up_tags - (Optional) This is the tags of the thing, to help people finding your content easier on the Flattr website. If you want to use multiple tags, separate using a normal comma (,) sign.
up_button - (Optional) This is the type of button you would like to display. To get the compact button use up_button="compact" otherwise the default is displayed. This gadget will automatically choose compact button if you specify a width > 100.
up_hidden - (Optional) Not all content is suitable for public listing. If you for one reason or another don't want your content to be listed on Flattr.com set this parameter to 1.
up_https - (Optional) This forces https. This gadget will automatically choose https if possible, so you don't have to specify this parameter.
If the thing is already on Flattr.com, then only up_url is required!
You must also specify the width and height of the gadget when using this button.
For normal buttons use: width="55" height="62"
For compact buttons use: width="110" height="20"
Here are two examples:
<wiki:gadget border="0" url="https://gist.githubusercontent.com/stefansundin/8195226/raw/flattr-gadget.xml" width="55" height="62" up_uid="recover" up_title="SuperF4" up_desc="Kill programs with Ctrl+Alt+F4" up_tags="stefansundin" up_url="https://code.google.com/p/superf4/" />
<wiki:gadget border="0" url="https://gist.githubusercontent.com/stefansundin/8195226/raw/flattr-gadget.xml" width="110" height="20" up_uid="recover" up_title="SuperF4" up_desc="Kill programs with Ctrl+Alt+F4" up_tags="stefansundin" up_url="https://code.google.com/p/superf4/" />
Version history
---------------
0.4 - 2013-05-02:
* Fix scrollbars appearing when hovering button in Firefox.
0.3 - 2010-11-29:
* Gadget will now auto-detect compact button if you use width > 100.
* Added support for https.
* Added support for "hidden" submissions.
* Updated to latest API.
* Updated documentation.
0.2 - 2010-06-10:
* Fixed problem with the character ' in any of the parameters. Should now work flawlessly.
0.1 - 2010-05-09:
* First release
Made by Stefan Sundin.
Read more:
http://developers.flattr.net/button/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment