liquid_feedback_frontend
view env/util/autoapi.lua @ 52:88ac7798b562
Several bugfixes (getpic.c, accepted but canceled issues, ...); Listing of available policies
- Bugfixes in fastpath/getpic.c (related to crashes since alpha5)
- Respect Content-Types of images in database
(needs database update, as Content-Type was incorrectly stored by previous versions)
- Typo fixed in help messages
- RSS-Feed (currently only after manual authentication while session is valid)
- Listing of available policies
- German translation fixed: "gebe" -> "gib" (Imperativ)
- Bugfixes related to issues which had been accepted but canceled afterwards
- Prohibit creation of initiatives in disabled areas or with disabled policies
- Bugfixes in fastpath/getpic.c (related to crashes since alpha5)
- Respect Content-Types of images in database
(needs database update, as Content-Type was incorrectly stored by previous versions)
- Typo fixed in help messages
- RSS-Feed (currently only after manual authentication while session is valid)
- Listing of available policies
- German translation fixed: "gebe" -> "gib" (Imperativ)
- Bugfixes related to issues which had been accepted but canceled afterwards
- Prohibit creation of initiatives in disabled areas or with disabled policies
author | bsw/jbe |
---|---|
date | Thu Apr 15 19:58:25 2010 +0200 (2010-04-15) |
parents | 0849be391140 |
children | 733f65c0c0a0 |
line source
1 function util.autoapi_xml(args)
2 local selector = assert(args.selector)
3 local fields = assert(args.fields)
4 local rows = selector:exec()
5 slot.set_layout("xml")
6 slot.put("<initiative_list>\n")
7 for i_row, row in ipairs(rows) do
8 slot.put(" <initiative>\n")
9 for i_field, field in ipairs(fields) do
10 slot.put(" <", field.name, ">")
11 local value
12 if field.func then
13 value = field.func(row)
14 elseif field.field then
15 value = row[field.name]
16 end
17 if value ~= nil then
18 slot.put(encode.html(tostring(value)))
19 else
20 slot.put("NULL")
21 end
22 slot.put("</", field.name, ">\n")
23 end
24 slot.put(" </initiative>\n")
25 end
26 slot.put("</initiative_list>\n")
27 end
29 function util.autoapi_json(args)
30 slot.set_layout("blank")
31 local selector = assert(args.selector)
32 local fields = assert(args.fields)
33 local rows = selector:exec()
34 slot.put("{\n")
35 for i_row, row in ipairs(rows) do
36 slot.put(" {\n")
37 for i_field, field in ipairs(fields) do
38 slot.put(" ", field.name, ": ")
39 local value
40 if field.func then
41 value = field.func(row)
42 elseif field.field then
43 value = row[field.name]
44 end
45 slot.put(encode.json(value))
46 slot.put(",\n")
47 end
48 slot.put(" },\n")
49 end
50 slot.put("}\n")
51 end
53 function util.autoapi(args)
54 local selector = assert(args.selector)
55 local fields = assert(args.fields)
56 local api_engine = assert(args.api_engine)
58 selector:reset_fields()
60 for i_field, field in ipairs(fields) do
61 if field.field then
62 selector:add_field(field.field, field.name)
63 end
64 end
66 if api_engine == "xml" then
67 util.autoapi_xml{
68 selector = selector,
69 fields = fields
70 }
71 elseif api_engine == "json" then
72 util.autoapi_json{
73 selector = selector,
74 fields = fields
75 }
76 end
78 end