From 8103337ecdc5ffef6c9a45e002539dcac8053735 Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Fri, 31 May 2013 12:47:57 +0000 Subject: Provide some data in JSON format git-svn-id: svn+ssh://svn.mageia.org/svn/soft/mga-treasurer/trunk@8408 5b7c3c08-40e5-403b-9995-ace06908e4af --- NEWS | 1 + config_default | 1 + tmpl/index.html | 8 ++++++++ tmpl/index.json | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 tmpl/index.json diff --git a/NEWS b/NEWS index 4d45682..a3158ef 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +- provide some data in JSON format - sort donations by date on monthly page Version 0.4 diff --git a/config_default b/config_default index 82db5c0..adea3d8 100644 --- a/config_default +++ b/config_default @@ -3,6 +3,7 @@ tmpl_dir: /usr/share/mga-treasurer/tmpl output_format: - html - rss + - json out_dir: /var/www/mga-treasurer sitename: Mageia.Org siteurl: http://treasurer.mageia.org diff --git a/tmpl/index.html b/tmpl/index.html index c4d71bd..2939fc4 100644 --- a/tmpl/index.html +++ b/tmpl/index.html @@ -165,6 +165,14 @@

Donations RSS Feed RSS feed

Transactions RSS Feed RSS feed

+

JSON data

+ + Some data is available in json format : + +

Grisbi

Mageia.Org accounts are managed using grisbi. diff --git a/tmpl/index.json b/tmpl/index.json new file mode 100644 index 0000000..1f60acf --- /dev/null +++ b/tmpl/index.json @@ -0,0 +1,21 @@ +[%- USE JSON ( pretty => 1 ) -%] +[%- USE date(format='%Y/%m/%d') -%] +[%- + SET out = {}; + SET out.balance = transactions.balance.bstr; + SET out.donations_30days = donations.total_30.bstr; + SET out.last_donations = []; + SET i=0; + SET l=10; + FOREACH don IN donations.donations.sort('date').reverse; + SET i = i + 1; + LAST IF i > l; + SET n = {}; + SET n.pa = don.pa; + SET n.who = don.who; + SET n.amount = don.amount.bstr; + SET n.date = date.format(don.date); + out.last_donations.push(n); + END; +-%] +[% out.json -%] -- cgit v1.2.1