# HG changeset patch # User bsw # Date 1340896020 -7200 # Node ID f52f918b38b881e54db487cc408106c61c5d52d2 # Parent f49cdfb725670864a4101840ec10b2d1a7293a56 Cleanup of config and orphaned code diff -r f49cdfb72567 -r f52f918b38b8 app/main/_filter/21_auth.lua --- a/app/main/_filter/21_auth.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/_filter/21_auth.lua Thu Jun 28 17:07:00 2012 +0200 @@ -18,7 +18,6 @@ or view == "menu" or action == "set_lang" ) - or module == "openid" ) if config.public_access then diff -r f49cdfb72567 -r f52f918b38b8 app/main/_filter_view/30_navigation.lua --- a/app/main/_filter_view/30_navigation.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/_filter_view/30_navigation.lua Thu Jun 28 17:07:00 2012 +0200 @@ -1,5 +1,3 @@ -slot.put_into("app_name", config.app_title) - slot.select('navigation', function() ui.link{ @@ -112,11 +110,4 @@ } end) - -if config.app_logo then - slot.select("logo", function() - ui.image{ static = config.app_logo } - end) -end - execute.inner() diff -r f49cdfb72567 -r f52f918b38b8 app/main/_filter_view/35_openid.lua --- a/app/main/_filter_view/35_openid.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -auth.openid.xrds_header{ - module = "openid", - view = "announce.xrds" -} - -execute.inner() \ No newline at end of file diff -r f49cdfb72567 -r f52f918b38b8 app/main/_filter_view/36_html_title.lua --- a/app/main/_filter_view/36_html_title.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/_filter_view/36_html_title.lua Thu Jun 28 17:07:00 2012 +0200 @@ -30,6 +30,6 @@ .. ( app.html_title.subtitle or "" ) .. - config.app_title + _"LiquidFeedback" .. " - " .. config.instance_name ) diff -r f49cdfb72567 -r f52f918b38b8 app/main/_layout/report.html --- a/app/main/_layout/report.html Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ - - - - <!-- WEBMCP SLOTNODIV app_name --> - - - - - -
- -
- - - - diff -r f49cdfb72567 -r f52f918b38b8 app/main/_layout/rss.html --- a/app/main/_layout/rss.html Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r f49cdfb72567 -r f52f918b38b8 app/main/_layout/xml.html --- a/app/main/_layout/xml.html Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ - - diff -r f49cdfb72567 -r f52f918b38b8 app/main/area/show.lua --- a/app/main/area/show.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/area/show.lua Thu Jun 28 17:07:00 2012 +0200 @@ -6,13 +6,6 @@ util.help("area.show") - -if config.feature_rss_enabled then - util.html_rss_head{ title = _"Initiatives in this area (last created first)", module = "initiative", view = "list_rss", params = { area_id = area.id } } - util.html_rss_head{ title = _"Initiatives in this area (last updated first)", module = "initiative", view = "list_rss", params = { area_id = area.id } } -end - - slot.select("head", function() execute.view{ module = "area", view = "_head", params = { area = area, show_content = true } } end) diff -r f49cdfb72567 -r f52f918b38b8 app/main/index/_action/set_lang.lua --- a/app/main/index/_action/set_lang.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/index/_action/set_lang.lua Thu Jun 28 17:07:00 2012 +0200 @@ -1,6 +1,6 @@ local lang = param.get("lang") local valid_lang = false -for i, tmp_lang in ipairs(config.available_languages) do +for i, tmp_lang in ipairs(config.enabled_languages) do if lang == tmp_lang then valid_lang = true end diff -r f49cdfb72567 -r f52f918b38b8 app/main/index/_menu.lua --- a/app/main/index/_menu.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/index/_menu.lua Thu Jun 28 17:07:00 2012 +0200 @@ -73,7 +73,7 @@ end } end - for i, lang in ipairs(config.available_languages) do + for i, lang in ipairs(config.enabled_languages) do local langcode diff -r f49cdfb72567 -r f52f918b38b8 app/main/index/login.lua --- a/app/main/index/login.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/index/login.lua Thu Jun 28 17:07:00 2012 +0200 @@ -7,10 +7,9 @@ execute.view{ module = "index", view = "_lang_chooser" } -slot.put_into("title", encode.html(config.app_title)) +ui.title(_"Login") app.html_title.title = _"Login" - if config.motd_public then local help_text = config.motd_public ui.container{ @@ -65,28 +64,3 @@ } end } - -if config.auth_openid_enabled then - ui.form{ - attr = { class = "login" }, - module = 'openid', - action = 'initiate', - routing = { - default = { - mode = 'forward', - module = 'index', - view = 'login', - } - }, - content = function() - ui.field.text{ - label = _'OpenID', - html_name = 'openid_identifier', - value = '' - } - ui.submit{ - text = _'OpenID Login' - } - end - } -end diff -r f49cdfb72567 -r f52f918b38b8 app/main/member_image/show.lua --- a/app/main/member_image/show.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/member_image/show.lua Thu Jun 28 17:07:00 2012 +0200 @@ -4,7 +4,7 @@ print('Cache-Control: max-age=300'); -- let the client cache the image for 5 minutes if record == nil then - local default_file = config.member_image_default_file[image_type] + local default_file = ({ avatar = "avatar.jpg", photo = nil })[image_type] if default_file then print('Location: ' .. encode.url{ static = default_file } .. '\n\n') else diff -r f49cdfb72567 -r f52f918b38b8 app/main/openid/_action/initiate.lua --- a/app/main/openid/_action/initiate.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -local user_supplied_identifier = param.get("openid_identifier") - -if not config.auth_openid_identifier_check_func(user_supplied_identifier) then - slot.put_into("error", _"This identifier is not allowed for this instance.") - return -end - -local success,errmsg = auth.openid.initiate{ - user_supplied_identifier = user_supplied_identifier, - https_as_default = config.auth_openid_https_as_default, - curl_options = config.auth_openid_curl_options, - realm = request.get_absolute_baseurl(), - return_to_module = "openid", - return_to_view = "verify" -} - -if not success then - slot.put_into("error", encode.html(_("Error while resolving openid. Internal message: '#{errmsg}'", { errmsg = errmsg }))) - return false -end \ No newline at end of file diff -r f49cdfb72567 -r f52f918b38b8 app/main/openid/_filter/00_openid.lua --- a/app/main/openid/_filter/00_openid.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -if not config.auth_openid_enabled then - error("OpenID is not enabled.") -end - -execute.inner() diff -r f49cdfb72567 -r f52f918b38b8 app/main/openid/announce.xrds.lua --- a/app/main/openid/announce.xrds.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -auth.openid.xrds_document{ - return_to_module = "openid", - return_to_view = "verify" -} diff -r f49cdfb72567 -r f52f918b38b8 app/main/openid/verify.lua --- a/app/main/openid/verify.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -local claimed_identifier, errmsg = auth.openid.verify{ - force_https = config.auth_openid_force_https, - curl_options = config.auth_openid_curl_options -} - -if not claimed_identifier then - slot.put_into("error", _"Sorry, it was not possible to verify your OpenID.") - return -end - -if not config.auth_openid_identifier_check_func(claimed_identifier) then - slot.put_into("error", _"This identifier is not allowed for this instance.") - return -end - -slot.put("validated as: ", encode.html(claimed_identifier), "
") - diff -r f49cdfb72567 -r f52f918b38b8 app/main/unit/_head.lua --- a/app/main/unit/_head.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/app/main/unit/_head.lua Thu Jun 28 17:07:00 2012 +0200 @@ -17,7 +17,7 @@ else ui.link{ module = "unit", view = "show", id = unit.id, - attr = { class = "unit_name" }, content = config.app_title + attr = { class = "unit_name" }, content = _"LiquidFeedback" .. " · " .. config.instance_name } end end } diff -r f49cdfb72567 -r f52f918b38b8 config/default.lua --- a/config/default.lua Thu Jun 28 16:31:02 2012 +0200 +++ b/config/default.lua Thu Jun 28 17:07:00 2012 +0200 @@ -1,20 +1,25 @@ - -config.app_name = "LiquidFeedback" -config.app_version = "2.beta12" +--------------------------------------------------------------------------- +-- Include defaults (DO NOT REMOVE THIS SECTION) +--------------------------------------------------------------------------- +execute.config("defaults") -config.instance_name = request.get_config_name() +--------------------------------------------------------------------------- +-- MANDATORY CONFIG OPTIONS +--------------------------------------------------------------------------- -config.app_title = config.app_name .. " " .. config.instance_name +-- Name of this instance, defaults to name of config file +-- config.instance_name = "Instance name" -config.app_logo = nil - +-- Information about service provider +--------------------------------------------------------------------------- config.app_service_provider = "Snake Oil
10000 Berlin
Germany" ---config.footer_html = 'some link' +-- A rocketwiki formatted text the user has to accept while registering +--------------------------------------------------------------------------- +config.use_terms = "=== Terms of Use ===" -config.use_terms = "=== Terms of Use ===\nNothing is allowed." ---config.use_terms_html = "" - +-- Checkbox(es) the user has to accept while registering +--------------------------------------------------------------------------- config.use_terms_checkboxes = { { name = "terms_of_use_v1", @@ -23,93 +28,76 @@ } } -config.locked_profile_fields = { - field_name = true, -} +--------------------------------------------------------------------------- +-- Optional config options +--------------------------------------------------------------------------- -config.member_image_content_type = "image/jpeg" -config.member_image_convert_func = { - avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end, - photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end -} +-- List of enabled languages, defaults to available languages +--------------------------------------------------------------------------- +-- config.enabled_languages = { 'en', 'de', 'eo', 'el', 'hu' } -config.member_image_default_file = { - avatar = "avatar.jpg", - photo = nil -} - -config.available_languages = { 'en', 'de', 'eo', 'el', 'hu' } - -config.default_lang = "de" +-- Default language, defaults to "en" +--------------------------------------------------------------------------- +-- config.default_lang = "en" -- after how long is a user considered inactive and the trustee will see warning -- notation is according to postgresql intervals -config.delegation_warning_time = '6 months' - -config.mail_subject_prefix = "[LiquidFeedback] " +--------------------------------------------------------------------------- +-- config.delegation_warning_time = '6 months' -config.fastpath_url_func = nil - -config.download_dir = nil +-- Sender and prefix of all automatic mails, default to "[Liquid Feedback] " +--------------------------------------------------------------------------- +-- config.mail_subject_prefix = "[LiquidFeedback] " +-- config.mail_envelope_from = "liquid-support@example.com" +-- config.mail_from = "LiquidFeedback" +-- config.mail_reply_to = "liquid-support@example.com" -config.download_use_terms = "=== Nutzungsbedingungen ===\nAlles ist verboten" - -config.public_access = false -- Available options: "anonymous", "pseudonym" +-- Supply custom url for avatar/photo delivery +--------------------------------------------------------------------------- +-- config.fastpath_url_func = nil -config.api_enabled = true +-- Local directory for database dumps offered for download +--------------------------------------------------------------------------- +-- config.download_dir = nil -config.feature_rss_enabled = false -- feature is broken +-- Special use terms for database dump download +--------------------------------------------------------------------------- +-- config.download_use_terms = "=== Download use terms ===\n" -config.single_unit_id = false +-- Set public access level +-- Available options: false, "anonymous", "pseudonym", "full" +--------------------------------------------------------------------------- +-- config.public_access = "full" --- OpenID authentication is not fully implemented yet, DO NOT USE BEFORE THIS NOTICE HAS BEEN REMOVED! -config.auth_openid_enabled = false -config.auth_openid_https_as_default = true -config.auth_openid_identifier_check_func = function(uri) return false end +-- Use custom image conversion +--------------------------------------------------------------------------- +--config.member_image_content_type = "image/jpeg" +--config.member_image_convert_func = { +-- avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end, +-- photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end +--} -request.set_allowed_json_request_slots{ "title", "actions", "support", "default", "trace", "system_error" } - +-- Integration of Etherpad +--------------------------------------------------------------------------- +--config.etherpad = { +-- base_url = "http://example.com:9001/", +-- api_base = "http://localhost:9001/", +-- api_key = "mysecretapikey", +-- group_id = "mygroupname", +-- cookie_path = "/" +--} -if request.get_json_request_slots() then - request.force_absolute_baseurl() -end - -request.set_404_route{ module = 'index', view = '404' } - +-- WebMCP accelerator +--------------------------------------------------------------------------- -- uncomment the following two lines to use C implementations of chosen -- functions and to disable garbage collection during the request, to -- increase speed: -- -require 'webmcp_accelerator' -collectgarbage("stop") - --- open and set default database handle -db = assert(mondelefant.connect{ - engine='postgresql', - dbname='liquid_feedback' -}) -at_exit(function() - db:close() -end) -function mondelefant.class_prototype:get_db_conn() return db end - --- enable output of SQL commands in trace system -function db:sql_tracer(command) - return function(error_info) - local error_info = error_info or {} - trace.sql{ command = command, error_position = error_info.position } - end -end - -request.set_absolute_baseurl(config.absolute_base_url) +-- require 'webmcp_accelerator' +-- collectgarbage("stop") - --- TODO abstraction --- get record by id -function mondelefant.class_prototype:by_id(id) - local selector = self:new_selector() - selector:add_where{ 'id = ?', id } - selector:optional_object_mode() - return selector:exec() -end +--------------------------------------------------------------------------- +-- Do main initialisation (DO NOT REMOVE THIS SECTION) +--------------------------------------------------------------------------- +execute.config("init") diff -r f49cdfb72567 -r f52f918b38b8 config/defaults.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/defaults.lua Thu Jun 28 17:07:00 2012 +0200 @@ -0,0 +1,39 @@ +config.app_version = "2.beta12" + +config.instance_name = request.get_config_name() + +config.app_service_provider = "Snake Oil
10000 Berlin
Germany" + +config.use_terms = "=== Terms of Use ===" + +config.use_terms_checkboxes = { + { + name = "terms_of_use_v1", + html = "I accept the terms of use.", + not_accepted_error = "You have to accept the terms of use to be able to register." + } +} + +config.enabled_languages = { 'en', 'de', 'eo', 'el', 'hu' } + +config.default_lang = "en" + +config.delegation_warning_time = '6 months' + +config.mail_subject_prefix = "[LiquidFeedback] " + +config.fastpath_url_func = nil + +config.download_dir = nil + +config.download_use_terms = "=== Nutzungsbedingungen ===\nAlles ist verboten" + +config.public_access = false + +config.member_image_content_type = "image/jpeg" + +config.member_image_convert_func = { + avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end, + photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end +} + diff -r f49cdfb72567 -r f52f918b38b8 config/development.lua --- a/config/development.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -config.absolute_base_url = "http://10.8.33.34/lf/" - -execute.config("default") - -config.formatting_engine_executeables = { - rocketwiki= "/opt/rocketwiki/rocketwiki-lqfb", - compat = "/opt/rocketwiki/rocketwiki-lqfb-compat" -} - -config.mail_from = "LiquidFeedback" -config.mail_reply_to = "liquid-support@localhost" - -config.issue_discussion_url_func = function(issue) return "http://example.com/issue_" .. tostring(issue.id) end - -config.auth_openid_enabled = false -config.auth_openid_https_as_default = true - -config.api_enabled = true - -config.auth_openid_identifier_check_func = function(uri) - local uri = uri:lower() - if uri:find("^https://") then - uri = uri:match("^https://(.*)") - end - if uri:find("^[0-9A-Za-z_-]+%.example%.com/?$") then - return true - else - return false - end -end - -config.motd_public = "==Public motd==" - ---config.motd_intern = "==Internal motd==" - -config.public_access = "anonym" - --- you can put some js code to the bottom on the page --- here it opens the trace window - ---slot.put_into( --- "custom_script", --- "document.getElementById('trace_show').onclick();" ---) - -config.etherpad = { - base_url = "http://10.8.33.34:9001/", - api_base = "http://10.8.33.34:9001/", - api_key = "g5XAVrRb5EgPuEqIdVrRNt2Juipx3PoH", - group_id = "g.7WDKN3StkEyuWkyN", - cookie_path = "/" -} - -config.document_dir = "/home/dark/tmp" diff -r f49cdfb72567 -r f52f918b38b8 config/example.lua --- a/config/example.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -request.set_absolute_baseurl(request.get_relative_baseurl()) --- request.set_absolute_baseurl("http://www.example.com/lf/") - -config.app_name = "LiquidFeedback" -config.app_version = "2.beta6" - -config.instance_name = request.get_config_name() - -config.app_title = config.app_name .. " (" .. request.get_config_name() .. " environment)" - -config.app_logo = nil - -config.app_service_provider = "Snake Oil
10000 Berlin
Germany" - ---config.footer_html = 'some link' - -config.use_terms = "=== Terms of Use ===\nNothing is allowed." ---config.use_terms_html = "" - -config.use_terms_checkboxes = { - { - name = "terms_of_use_v1", - html = "I accept the terms of use.", - not_accepted_error = "You have to accept the terms of use to be able to register." - } -} - -config.locked_profile_fields = { - login = false, - notify_email = false, - name = false, - organizational_unit = false, - internal_posts = false, - realname = false, - birthday = false, - address = false, - email = false -} - -config.member_image_content_type = "image/jpeg" -config.member_image_convert_func = { - avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end, - photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end -} - -config.member_image_default_file = { - avatar = "avatar.jpg", - photo = nil -} - -config.default_lang = "en" - --- after how long is a user considered inactive and the trustee will see warning --- notation is according to postgresql intervals -config.delegation_warning_time = '6 months' - -config.mail_subject_prefix = "[LiquidFeedback] " - -config.fastpath_url_func = nil - -config.download_dir = nil - -config.download_use_terms = "=== Nutzungsbedingungen ===\nAlles ist verboten" - -config.public_access = false -- Available options: "anonymous", "pseudonym" - -config.api_enabled = true - -config.feature_rss_enabled = false -- feature is broken - -config.single_unit_id = false - --- OpenID authentication is not fully implemented yet, DO NOT USE BEFORE THIS NOTICE HAS BEEN REMOVED! -config.auth_openid_enabled = false -config.auth_openid_https_as_default = true -config.auth_openid_identifier_check_func = function(uri) return false end - -request.set_allowed_json_request_slots{ "title", "actions", "support", "default", "trace", "system_error" } - -if request.get_json_request_slots() then - request.force_absolute_baseurl() -end - -request.set_404_route{ module = 'index', view = '404' } - --- uncomment the following two lines to use C implementations of chosen --- functions and to disable garbage collection during the request, to --- increase speed: --- --- require 'webmcp_accelerator' --- collectgarbage("stop") - --- open and set default database handle -db = assert(mondelefant.connect{ - engine='postgresql', - dbname='liquid_feedback_p' -}) -at_exit(function() - db:close() -end) -function mondelefant.class_prototype:get_db_conn() return db end - --- enable output of SQL commands in trace system -function db:sql_tracer(command) - return function(error_info) - local error_info = error_info or {} - trace.sql{ command = command, error_position = error_info.position } - end -end - - --- TODO abstraction --- get record by id -function mondelefant.class_prototype:by_id(id) - local selector = self:new_selector() - selector:add_where{ 'id = ?', id } - selector:optional_object_mode() - return selector:exec() -end - -config.formatting_engine_executeables = { - rocketwiki= "/opt/rocketwiki-lqfb/rocketwiki-lqfb", - compat = "/opt/rocketwiki-lqfb/rocketwiki-lqfb-compat" -} - -config.fastpath_url_func = function(member_id, image_type) - return request.get_absolute_baseurl() .. "fastpath/getpic?" .. tostring(member_id) .. "+" .. tostring(image_type) -end - diff -r f49cdfb72567 -r f52f918b38b8 config/init.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/init.lua Thu Jun 28 17:07:00 2012 +0200 @@ -0,0 +1,33 @@ +request.set_404_route{ module = 'index', view = '404' } + +-- open and set default database handle +db = assert(mondelefant.connect{ + engine='postgresql', + dbname='liquid_feedback' +}) +at_exit(function() + db:close() +end) +function mondelefant.class_prototype:get_db_conn() return db end + +-- enable output of SQL commands in trace system +function db:sql_tracer(command) + return function(error_info) + local error_info = error_info or {} + trace.sql{ command = command, error_position = error_info.position } + end +end + +request.set_absolute_baseurl(config.absolute_base_url) + + + +-- TODO abstraction +-- get record by id +function mondelefant.class_prototype:by_id(id) + local selector = self:new_selector() + selector:add_where{ 'id = ?', id } + selector:optional_object_mode() + return selector:exec() +end + diff -r f49cdfb72567 -r f52f918b38b8 config/testing.lua --- a/config/testing.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -config.absolute_base_url = "http://www.public-software-group.org/liquid_feedback_testing/" - -execute.config("default") - -config.formatting_engine_executeables = { - rocketwiki= "/opt/liquid_feedback_testing/rocketwiki/rocketwiki-lqfb", - compat = "/opt/liquid_feedback_testing/rocketwiki/rocketwiki-lqfb-compat" -} - -config.fastpath_url_func = function(member_id, image_type) - return "http://www.public-software-group.org/liquid_feedback_testing/fastpath/getpic?" .. tostring(member_id) .. "+" .. tostring(image_type) -end \ No newline at end of file diff -r f49cdfb72567 -r f52f918b38b8 env/util/autoapi.lua --- a/env/util/autoapi.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -function util.autoapi_xml(args) - local relation_name = assert(args.relation_name) - local selector = assert(args.selector) - local fields = assert(args.fields) - local rows = selector:exec() - slot.set_layout("xml", "application/xml") - slot.put("<", relation_name, "_list>\n") - for i_row, row in ipairs(rows) do - slot.put(" <", relation_name, ">\n") - for i_field, field in ipairs(fields) do - slot.put(" <", field.name, ">") - local value - if field.func then - value = field.func(row) - elseif field.field then - value = row[field.name] - end - if value ~= nil then - slot.put(encode.html(tostring(value))) - else - slot.put("NULL") - end - slot.put("\n") - end - slot.put(" \n") - end - slot.put("\n") -end - -function util.autoapi_json(args) - slot.set_layout("blank", "application/json") - local selector = assert(args.selector) - local fields = assert(args.fields) - local rows = selector:exec() - slot.put("[\n") - for i_row, row in ipairs(rows) do - slot.put(" {\n") - for i_field, field in ipairs(fields) do - slot.put(" \"", field.name, "\": ") - local value - if field.func then - value = field.func(row) - elseif field.field then - value = row[field.name] - end - slot.put(encode.json(value)) - if i_field < #fields then - slot.put(",") - end - slot.put("\n") - end - slot.put(" }") - if i_row < #rows then - slot.put(",") - end - slot.put("\n") - end - slot.put("]\n") -end - -function util.autoapi(args) - local relation_name = assert(args.relation_name) - local selector = assert(args.selector) - local fields = assert(args.fields) - local api_engine = assert(args.api_engine) - - selector:reset_fields() - - for i_field, field in ipairs(fields) do - if field.field then - selector:add_field(field.field, field.name) - end - end - - if api_engine == "xml" then - util.autoapi_xml{ - relation_name = relation_name, - selector = selector, - fields = fields - } - elseif api_engine == "json" then - util.autoapi_json{ - selector = selector, - fields = fields - } - end - -end \ No newline at end of file diff -r f49cdfb72567 -r f52f918b38b8 env/util/html_rss_head.lua --- a/env/util/html_rss_head.lua Thu Jun 28 16:31:02 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -function util.html_rss_head(args) - slot.put_into("html_head", '') -end