| rev | 
   line source | 
| 
bsw@734
 | 
     1 -- ========================================================================
 | 
| 
bsw@734
 | 
     2 -- DO NOT CHANGE ANYTHING IN THIS FILE
 | 
| 
bsw@734
 | 
     3 -- (except when you really know what you are doing!)
 | 
| 
bsw@734
 | 
     4 -- ========================================================================
 | 
| 
bsw@734
 | 
     5 
 | 
| 
bsw@1130
 | 
     6 config.app_version = "3.0.4"
 | 
| 
bsw@731
 | 
     7 
 | 
| 
bsw@905
 | 
     8 if not config.password_hash_algorithm then
 | 
| 
bsw@905
 | 
     9   config.password_hash_algorithm = "crypt_sha512"
 | 
| 
bsw@905
 | 
    10 end
 | 
| 
bsw@905
 | 
    11 
 | 
| 
bsw@905
 | 
    12 if not config.password_hash_min_rounds then
 | 
| 
bsw@905
 | 
    13  config.password_hash_min_rounds = 10000
 | 
| 
bsw@905
 | 
    14 end
 | 
| 
bsw@905
 | 
    15 
 | 
| 
bsw@905
 | 
    16 if not config.password_hash_max_rounds then
 | 
| 
bsw@905
 | 
    17   config.password_hash_max_rounds = 20000
 | 
| 
bsw@905
 | 
    18 end
 | 
| 
bsw@905
 | 
    19 
 | 
| 
bsw@731
 | 
    20 if config.enabled_languages == nil then
 | 
| 
bsw@1128
 | 
    21   config.enabled_languages = { 'en', 'de', 'ka' } --, 'eo', 'el', 'hu', 'it', 'nl', 'zh-Hans', 'zh-TW' }
 | 
| 
bsw@731
 | 
    22 end
 | 
| 
bsw@731
 | 
    23 
 | 
| 
bsw@731
 | 
    24 if config.default_lang == nil then
 | 
| 
bsw@731
 | 
    25   config.default_lang = "en"
 | 
| 
bsw@731
 | 
    26 end
 | 
| 
bsw@731
 | 
    27 
 | 
| 
bsw@731
 | 
    28 if config.mail_subject_prefix == nil then
 | 
| 
bsw@731
 | 
    29   config.mail_subject_prefix = "[LiquidFeedback] "
 | 
| 
bsw@731
 | 
    30 end
 | 
| 
bsw@731
 | 
    31 
 | 
| 
bsw@731
 | 
    32 if config.member_image_content_type == nil then
 | 
| 
bsw@731
 | 
    33   config.member_image_content_type = "image/jpeg"
 | 
| 
bsw@731
 | 
    34 end
 | 
| 
bsw@731
 | 
    35 
 | 
| 
bsw@731
 | 
    36 if config.member_image_convert_func == nil then
 | 
| 
bsw@731
 | 
    37   config.member_image_convert_func = {
 | 
| 
bsw@731
 | 
    38     avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail",   "48x48", "jpeg:-") end,
 | 
| 
bsw@731
 | 
    39     photo =  function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
 | 
| 
bsw@731
 | 
    40   }
 | 
| 
bsw@731
 | 
    41 end
 | 
| 
bsw@731
 | 
    42 
 | 
| 
bsw@736
 | 
    43 if config.locked_profile_fields == nil then
 | 
| 
bsw@736
 | 
    44   config.locked_profile_fields = {}
 | 
| 
bsw@736
 | 
    45 end
 | 
| 
bsw@736
 | 
    46 
 | 
| 
bsw@988
 | 
    47 if config.check_delegations_default == nil then
 | 
| 
bsw@988
 | 
    48   config.check_delegations_default = "confirm"
 | 
| 
bsw@988
 | 
    49 end
 | 
| 
bsw@988
 | 
    50 
 | 
| 
bsw@1071
 | 
    51 if config.ldap == nil then
 | 
| 
bsw@1071
 | 
    52   config.ldap = {}
 | 
| 
bsw@1071
 | 
    53 end
 | 
| 
bsw@1071
 | 
    54 
 | 
| 
bsw@732
 | 
    55 if not config.database then
 | 
| 
bsw@732
 | 
    56   config.database = { engine='postgresql', dbname='liquid_feedback' }
 | 
| 
bsw@732
 | 
    57 end
 | 
| 
bsw@732
 | 
    58 
 | 
| 
bsw@729
 | 
    59 request.set_404_route{ module = 'index', view = '404' }
 | 
| 
bsw@729
 | 
    60 
 | 
| 
bsw@729
 | 
    61 request.set_absolute_baseurl(config.absolute_base_url)
 | 
| 
bsw@729
 | 
    62 
 | 
| 
bsw@729
 | 
    63 -- TODO abstraction
 | 
| 
bsw@729
 | 
    64 -- get record by id
 | 
| 
bsw@729
 | 
    65 function mondelefant.class_prototype:by_id(id)
 | 
| 
bsw@729
 | 
    66   local selector = self:new_selector()
 | 
| 
bsw@729
 | 
    67   selector:add_where{ 'id = ?', id }
 | 
| 
bsw@729
 | 
    68   selector:optional_object_mode()
 | 
| 
bsw@729
 | 
    69   return selector:exec()
 | 
| 
bsw@729
 | 
    70 end
 | 
| 
bsw@729
 | 
    71 
 | 
| 
bsw@1145
 | 
    72 -- compatibility for WebMCP 1.2.6
 | 
| 
bsw@1145
 | 
    73 if not listen then
 | 
| 
bsw@1145
 | 
    74   
 | 
| 
bsw@1145
 | 
    75   -- open and set default database handle
 | 
| 
bsw@1145
 | 
    76   _G.db = assert(mondelefant.connect(config.database))
 | 
| 
bsw@1145
 | 
    77 
 | 
| 
bsw@1145
 | 
    78   function mondelefant.class_prototype:get_db_conn() return db end
 | 
| 
bsw@1145
 | 
    79 
 | 
| 
bsw@1145
 | 
    80   -- enable output of SQL commands in trace system
 | 
| 
bsw@1145
 | 
    81   function db:sql_tracer(command)
 | 
| 
bsw@1145
 | 
    82     return function(error_info)
 | 
| 
bsw@1145
 | 
    83       local error_info = error_info or {}
 | 
| 
bsw@1145
 | 
    84       trace.sql{ command = command, error_position = error_info.position }
 | 
| 
bsw@1145
 | 
    85     end
 | 
| 
bsw@1145
 | 
    86   end
 | 
| 
bsw@1145
 | 
    87 
 | 
| 
bsw@1145
 | 
    88   -- close the database at exit
 | 
| 
bsw@1145
 | 
    89   at_exit(function() 
 | 
| 
bsw@1145
 | 
    90     db:close()
 | 
| 
bsw@1145
 | 
    91   end)
 | 
| 
bsw@1145
 | 
    92   
 | 
| 
bsw@1145
 | 
    93   function request.get_cookie(args)
 | 
| 
bsw@1145
 | 
    94     return cgi.cookies[args.name]
 | 
| 
bsw@1145
 | 
    95   end
 | 
| 
bsw@1145
 | 
    96   
 | 
| 
bsw@1145
 | 
    97   function request.get_param(args)
 | 
| 
bsw@1145
 | 
    98     return request.get_param_strings()[args.name]
 | 
| 
bsw@1145
 | 
    99   end
 | 
| 
bsw@1145
 | 
   100   
 | 
| 
bsw@1145
 | 
   101   function request.add_header(key, value)
 | 
| 
bsw@1145
 | 
   102     print(key .. ": " .. value)
 | 
| 
bsw@1145
 | 
   103   end
 | 
| 
bsw@1145
 | 
   104   
 | 
| 
bsw@1145
 | 
   105   local request_redirect = request.redirect
 | 
| 
bsw@1145
 | 
   106   function request.redirect(args)
 | 
| 
bsw@1145
 | 
   107     if args.static then
 | 
| 
bsw@1145
 | 
   108       print('Location: ' .. encode.url{ static = args.static } .. '\n\n')
 | 
| 
bsw@1145
 | 
   109       exit()
 | 
| 
bsw@1145
 | 
   110     else
 | 
| 
bsw@1145
 | 
   111       request_redirect(args)
 | 
| 
bsw@1145
 | 
   112     end
 | 
| 
bsw@1145
 | 
   113   end
 | 
| 
bsw@1145
 | 
   114 
 | 
| 
bsw@1145
 | 
   115   
 | 
| 
bsw@1145
 | 
   116   return
 | 
| 
bsw@1145
 | 
   117 end
 | 
| 
bsw@1145
 | 
   118 
 | 
| 
bsw@1145
 | 
   119 if not config.fork then
 | 
| 
bsw@1145
 | 
   120   config.fork = {}
 | 
| 
bsw@1145
 | 
   121 end
 | 
| 
bsw@1145
 | 
   122 
 | 
| 
bsw@1145
 | 
   123 if not config.fork.pre then
 | 
| 
bsw@1145
 | 
   124   config.fork.pre = 4
 | 
| 
bsw@1145
 | 
   125 end
 | 
| 
bsw@1145
 | 
   126 
 | 
| 
bsw@1145
 | 
   127 if not config.fork.max then
 | 
| 
bsw@1145
 | 
   128   config.fork.max = 8
 | 
| 
bsw@1145
 | 
   129 end
 | 
| 
bsw@1145
 | 
   130 
 | 
| 
bsw@1145
 | 
   131 if not config.fork.delay then
 | 
| 
bsw@1145
 | 
   132   config.fork.delay = 1
 | 
| 
bsw@1145
 | 
   133 end
 | 
| 
bsw@1145
 | 
   134 
 | 
| 
bsw@1145
 | 
   135 if not config.port then
 | 
| 
bsw@1145
 | 
   136   config.port = 8080
 | 
| 
bsw@1145
 | 
   137 end
 | 
| 
bsw@1145
 | 
   138 
 | 
| 
bsw@1145
 | 
   139 listen{
 | 
| 
bsw@1145
 | 
   140   { proto = "tcp4", port = config.port, localhost = true },
 | 
| 
bsw@1145
 | 
   141   pre_fork = config.fork.pre,
 | 
| 
bsw@1145
 | 
   142   max_fork = config.fork.max,
 | 
| 
bsw@1145
 | 
   143   fork_delay = config.fork.delay
 | 
| 
bsw@1145
 | 
   144 }
 |