blob: 14dba58ec3fadb5bcc06f218667b3c1c9900736b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/usr/bin/env lua5.1
local marigold = require 'marigold-cgi.marigold'
local h = marigold.h
local b64 = require '3rdparty.base64'
local json = require '3rdparty.json'
local draw = require 'draw'
local function error(message)
print('Content-type: text/plain\n')
print(string.format('ERROR: %s', message))
os.exit(1)
end
-- get statistics
local metavars = marigold.get_metavars()
local query = marigold.decode_query(metavars.query_string or '')
if not query.statistics then
error('no statistics submitted!')
end
local statistics = json.decode(b64.decode(query.statistics))
local theme = (query.theme and json.decode(b64.decode(query.theme))) or {
bg='white', text='black', flair='darkred',
}
-- create & respond with image
local svg = draw.draw(statistics, theme)
print('Content-type: image/svg+xml\n')
print(svg)
|