liquid_feedback_frontend
diff env/util/autoapi.lua @ 75:733f65c0c0a0
Bugfixes, feature enhancements, code-cleanup, and major work on API
Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
author | bsw |
---|---|
date | Thu Jul 08 18:44:02 2010 +0200 (2010-07-08) |
parents | 88ac7798b562 |
children |
line diff
1.1 --- a/env/util/autoapi.lua Wed May 26 15:47:52 2010 +0200 1.2 +++ b/env/util/autoapi.lua Thu Jul 08 18:44:02 2010 +0200 1.3 @@ -1,11 +1,12 @@ 1.4 function util.autoapi_xml(args) 1.5 + local relation_name = assert(args.relation_name) 1.6 local selector = assert(args.selector) 1.7 local fields = assert(args.fields) 1.8 local rows = selector:exec() 1.9 - slot.set_layout("xml") 1.10 - slot.put("<initiative_list>\n") 1.11 + slot.set_layout("xml", "application/xml") 1.12 + slot.put("<", relation_name, "_list>\n") 1.13 for i_row, row in ipairs(rows) do 1.14 - slot.put(" <initiative>\n") 1.15 + slot.put(" <", relation_name, ">\n") 1.16 for i_field, field in ipairs(fields) do 1.17 slot.put(" <", field.name, ">") 1.18 local value 1.19 @@ -21,36 +22,44 @@ 1.20 end 1.21 slot.put("</", field.name, ">\n") 1.22 end 1.23 - slot.put(" </initiative>\n") 1.24 + slot.put(" </", relation_name, ">\n") 1.25 end 1.26 - slot.put("</initiative_list>\n") 1.27 + slot.put("</", relation_name, "_list>\n") 1.28 end 1.29 1.30 function util.autoapi_json(args) 1.31 - slot.set_layout("blank") 1.32 + slot.set_layout("blank", "application/json") 1.33 local selector = assert(args.selector) 1.34 local fields = assert(args.fields) 1.35 local rows = selector:exec() 1.36 - slot.put("{\n") 1.37 + slot.put("[\n") 1.38 for i_row, row in ipairs(rows) do 1.39 slot.put(" {\n") 1.40 for i_field, field in ipairs(fields) do 1.41 - slot.put(" ", field.name, ": ") 1.42 + slot.put(" \"", field.name, "\": ") 1.43 local value 1.44 if field.func then 1.45 value = field.func(row) 1.46 elseif field.field then 1.47 value = row[field.name] 1.48 end 1.49 - slot.put(encode.json(value)) 1.50 - slot.put(",\n") 1.51 + slot.put(encode.json(value)) 1.52 + if i_field < #fields then 1.53 + slot.put(",") 1.54 + end 1.55 + slot.put("\n") 1.56 end 1.57 - slot.put(" },\n") 1.58 + slot.put(" }") 1.59 + if i_row < #rows then 1.60 + slot.put(",") 1.61 + end 1.62 + slot.put("\n") 1.63 end 1.64 - slot.put("}\n") 1.65 + slot.put("]\n") 1.66 end 1.67 1.68 function util.autoapi(args) 1.69 + local relation_name = assert(args.relation_name) 1.70 local selector = assert(args.selector) 1.71 local fields = assert(args.fields) 1.72 local api_engine = assert(args.api_engine) 1.73 @@ -65,6 +74,7 @@ 1.74 1.75 if api_engine == "xml" then 1.76 util.autoapi_xml{ 1.77 + relation_name = relation_name, 1.78 selector = selector, 1.79 fields = fields 1.80 }