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@729
|
42 request.set_404_route{ module = 'index', view = '404' }
|
bsw@729
|
43
|
bsw@729
|
44 -- open and set default database handle
|
bsw@729
|
45 db = assert(mondelefant.connect{
|
bsw@729
|
46 engine='postgresql',
|
bsw@729
|
47 dbname='liquid_feedback'
|
bsw@729
|
48 })
|
bsw@729
|
49 at_exit(function()
|
bsw@729
|
50 db:close()
|
bsw@729
|
51 end)
|
bsw@729
|
52 function mondelefant.class_prototype:get_db_conn() return db end
|
bsw@729
|
53
|
bsw@729
|
54 -- enable output of SQL commands in trace system
|
bsw@729
|
55 function db:sql_tracer(command)
|
bsw@729
|
56 return function(error_info)
|
bsw@729
|
57 local error_info = error_info or {}
|
bsw@729
|
58 trace.sql{ command = command, error_position = error_info.position }
|
bsw@729
|
59 end
|
bsw@729
|
60 end
|
bsw@729
|
61
|
bsw@729
|
62 request.set_absolute_baseurl(config.absolute_base_url)
|
bsw@729
|
63
|
bsw@729
|
64
|
bsw@729
|
65
|
bsw@729
|
66 -- TODO abstraction
|
bsw@729
|
67 -- get record by id
|
bsw@729
|
68 function mondelefant.class_prototype:by_id(id)
|
bsw@729
|
69 local selector = self:new_selector()
|
bsw@729
|
70 selector:add_where{ 'id = ?', id }
|
bsw@729
|
71 selector:optional_object_mode()
|
bsw@729
|
72 return selector:exec()
|
bsw@729
|
73 end
|
bsw@729
|
74
|