Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xen/sfbadge
sfbadge
https://github.com/xen/sfbadge
Last synced: about 1 month ago
JSON representation
sfbadge
- Host: GitHub
- URL: https://github.com/xen/sfbadge
- Owner: xen
- Created: 2013-01-28T06:12:23.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-02-20T16:39:51.000Z (over 11 years ago)
- Last Synced: 2024-04-19T15:23:58.977Z (7 months ago)
- Language: Python
- Size: 113 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sfbadge
Small API to use sourceforge.com downloads statistics embeded as AJAX calls hosted on Heroku. Sourceforge.com don't allow cross origin calls so that is primary reason to make this project.
## Install
Read this [official tutorial](https://devcenter.heroku.com/articles/python#start-flask-app-inside-a-virtualenv)
## Usage
Format is very simple:
http://sfbadge.herokuapp.com/sf/:reponame/:set
Parameters:
- `reponame` is your repository on sf.net, for example "fontforge"
- `set` is size of result set. Now it accept only two values: `json` and `fulljson`. `json` returns only total downloads number.Optional parameters:
- `start_date` sourceforge allow to limit statistic to particular date range. If not provided then limited to 7 days ago. Format `%Y-%m-%d`
- `end_date`, if not provided then today, format the same
- `jsonp` callback function name for JSONP requests## Example
For example you can use this code on [FontForge homepage](http://fontforge.github.com/en-US/index.html):
Downloads
function humanise(n){
var d = ',';
var s = '.';
n = n.toString().split('.');
n[0] = n[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + d);
return n.join(s);
};$(document).ready(function(){
$.getJSON("http://sfbadge.herokuapp.com/sf/fontforge/json", function(json) {
$('#cnt-downloads').html(humanise(json.total));
});
});