liquid_feedback_frontend

annotate config/init.lua @ 732:3a61d21618f6

Made database configurable
author bsw
date Thu Jun 28 17:23:38 2012 +0200 (2012-06-28)
parents 0015fa6eb637
children 9d104952554a
rev   line source
bsw@731 1 config.app_version = "2.beta12"
bsw@731 2
bsw@731 3 if not config.instance_name then
bsw@731 4 config.instance_name = request.get_config_name()
bsw@731 5 end
bsw@731 6
bsw@731 7 if
bsw@731 8 not config.app_service_provider or
bsw@731 9 not config.use_terms or
bsw@731 10 not config.use_terms_checkboxes
bsw@731 11 then
bsw@731 12 error("Missing mandatory config option")
bsw@731 13 end
bsw@731 14
bsw@731 15 if config.enabled_languages == nil then
bsw@731 16 config.enabled_languages = { 'en', 'de', 'eo', 'el', 'hu' }
bsw@731 17 end
bsw@731 18
bsw@731 19 if config.default_lang == nil then
bsw@731 20 config.default_lang = "en"
bsw@731 21 end
bsw@731 22
bsw@731 23 if config.mail_subject_prefix == nil then
bsw@731 24 config.mail_subject_prefix = "[LiquidFeedback] "
bsw@731 25 end
bsw@731 26
bsw@731 27 if config.absolute_base_url == nil then
bsw@731 28 config.absolute_base_url = request.get_relative_baseurl()
bsw@731 29 end
bsw@731 30
bsw@731 31 if config.member_image_content_type == nil then
bsw@731 32 config.member_image_content_type = "image/jpeg"
bsw@731 33 end
bsw@731 34
bsw@731 35 if config.member_image_convert_func == nil then
bsw@731 36 config.member_image_convert_func = {
bsw@731 37 avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end,
bsw@731 38 photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
bsw@731 39 }
bsw@731 40 end
bsw@731 41
bsw@732 42 if not config.database then
bsw@732 43 config.database = { engine='postgresql', dbname='liquid_feedback' }
bsw@732 44 end
bsw@732 45
bsw@729 46 request.set_404_route{ module = 'index', view = '404' }
bsw@729 47
bsw@729 48 -- open and set default database handle
bsw@732 49 db = assert(mondelefant.connect(config.database)
bsw@729 50 at_exit(function()
bsw@729 51 db:close()
bsw@729 52 end)
bsw@729 53 function mondelefant.class_prototype:get_db_conn() return db end
bsw@729 54
bsw@729 55 -- enable output of SQL commands in trace system
bsw@729 56 function db:sql_tracer(command)
bsw@729 57 return function(error_info)
bsw@729 58 local error_info = error_info or {}
bsw@729 59 trace.sql{ command = command, error_position = error_info.position }
bsw@729 60 end
bsw@729 61 end
bsw@729 62
bsw@729 63 request.set_absolute_baseurl(config.absolute_base_url)
bsw@729 64
bsw@729 65
bsw@729 66
bsw@729 67 -- TODO abstraction
bsw@729 68 -- get record by id
bsw@729 69 function mondelefant.class_prototype:by_id(id)
bsw@729 70 local selector = self:new_selector()
bsw@729 71 selector:add_where{ 'id = ?', id }
bsw@729 72 selector:optional_object_mode()
bsw@729 73 return selector:exec()
bsw@729 74 end
bsw@729 75

Impressum / About Us