aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-05-31 12:47:57 +0000
committerNicolas Vigier <boklm@mageia.org>2013-05-31 12:47:57 +0000
commit8103337ecdc5ffef6c9a45e002539dcac8053735 (patch)
treec633b7bf9584d1401cb235d6c5a6019aca105181
parentcbb2246b5a306a424e65d288885f3caf2c5812f2 (diff)
downloadmgatres-8103337ecdc5ffef6c9a45e002539dcac8053735.tar
mgatres-8103337ecdc5ffef6c9a45e002539dcac8053735.tar.gz
mgatres-8103337ecdc5ffef6c9a45e002539dcac8053735.tar.bz2
mgatres-8103337ecdc5ffef6c9a45e002539dcac8053735.tar.xz
mgatres-8103337ecdc5ffef6c9a45e002539dcac8053735.zip
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
-rw-r--r--NEWS1
-rw-r--r--config_default1
-rw-r--r--tmpl/index.html8
-rw-r--r--tmpl/index.json21
4 files changed, 31 insertions, 0 deletions
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 @@
<p><a href="donations.rss">Donations RSS Feed <img src="[% config.staticdir_url %]/feed-16x16.png" alt="RSS feed" /></a></p>
<p><a href="transactions.rss">Transactions RSS Feed <img src="[% config.staticdir_url %]/feed-16x16.png" alt="RSS feed" /></a></p>
+ <h2>JSON data</h2>
+
+ Some data is available in json format :
+ <ul>
+ <li><a href="index.json">index.json</a>: balance, donations received in
+ the last 30 days, and the list of the last 10 donations</li>
+ </ul>
+
<h2>Grisbi</h2>
<p>
Mageia.Org accounts are managed using <a href="http://grisbi.org/">grisbi</a>.
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 -%]