liquid_feedback_frontend
view app/main/_prefork/10_init.lua @ 1281:5b97578192bc
Hide not needed parts of notification configuration view
| author | bsw | 
|---|---|
| date | Mon Apr 18 09:38:27 2016 +0200 (2016-04-18) | 
| parents | 235a36a08da1 | 
| children | 32d5195a7152 | 
 line source
     1 config.app_version = "3.1.0"
     3 -- TODO abstraction
     4 -- get record by id
     5 function mondelefant.class_prototype:by_id(id)
     6   local selector = self:new_selector()
     7   selector:add_where{ 'id = ?', id }
     8   selector:optional_object_mode()
     9   return selector:exec()
    10 end
    12 if not config.password_hash_algorithm then
    13   config.password_hash_algorithm = "crypt_sha512"
    14 end
    16 if not config.password_hash_min_rounds then
    17  config.password_hash_min_rounds = 10000
    18 end
    20 if not config.password_hash_max_rounds then
    21   config.password_hash_max_rounds = 20000
    22 end
    24 if config.use_terms_checkboxes == nil then
    25   config.use_terms_checkboxes = {}
    26 end
    28 if config.enabled_languages == nil then
    29   config.enabled_languages = { 'en', 'de', 'ka' } --, 'eo', 'el', 'hu', 'it', 'nl', 'zh-Hans', 'zh-TW' }
    30 end
    32 if config.default_lang == nil then
    33   config.default_lang = "en"
    34 end
    36 if config.mail_subject_prefix == nil then
    37   config.mail_subject_prefix = "[LiquidFeedback] "
    38 end
    40 if config.notification_digest_template == nil then
    41   config.notification_digest_template = "Hello #{name},\n\nthis is your personal digest.\n\n#{digest}\n"
    42 end
    44 if config.member_image_content_type == nil then
    45   config.member_image_content_type = "image/jpeg"
    46 end
    48 if config.member_image_convert_func == nil then
    49   config.member_image_convert_func = {
    50     avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail",   "48x48", "jpeg:-") end,
    51     photo =  function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
    52   }
    53 end
    55 if config.locked_profile_fields == nil then
    56   config.locked_profile_fields = {}
    57 end
    59 if config.check_delegations_default == nil then
    60   config.check_delegations_default = "confirm"
    61 end
    63 if config.ldap == nil then
    64   config.ldap = {}
    65 end
    67 if not config.database then
    68   config.database = { engine='postgresql', dbname='liquid_feedback' }
    69 end
    71 if config.fork == nil then
    72   config.fork = {}
    73 end
    75 if config.fork.pre == nil then
    76   config.fork.pre = 2
    77 end
    79 if config.fork.min == nil then
    80   config.fork.min = 4
    81 end
    83 if config.fork.max == nil then
    84   config.fork.max = 128
    85 end
    87 if config.fork.delay == nil then
    88   config.fork.delay = 0.125
    89 end
    91 if config.fork.error_delay == nil then
    92   config.fork.error_delay = 2
    93 end
    95 if config.fork.exit_delay == nil then
    96   config.fork.exit_delay = 2
    97 end
    99 if config.fork.idle_timeout == nil then
   100   config.fork.idle_timeout = 900
   101 end
   103 if config.port == nil then
   104   config.port = 8080
   105 end
   107 if config.localhost == nil then
   108   config.localhost = true
   109 end
   111 local listen_options = {
   112   pre_fork              = config.fork.pre,
   113   min_fork              = config.fork.min,
   114   max_fork              = config.fork.max,
   115   fork_delay            = config.fork.delay,
   116   fork_error_delay      = config.fork.error_delay,
   117   exit_delay            = config.fork.exit_delay,
   118   idle_timeout          = config.fork.idle_timeout,
   119   memory_limit          = config.fork.memory_limit,
   120   min_requests_per_fork = config.fork.min_requests,
   121   max_requests_per_fork = config.fork.max_requests,
   122   http_options          = config.http_options
   123 }
   125 if config.ipv6 then
   126   local host = config.localhost and "::1" or "::"
   127   listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
   128 end
   129 if config.ipv6 ~= "only" then
   130   local host = config.localhost and "127.0.0.1" or "0.0.0.0"
   131   listen_options[#listen_options+1] = { proto = "tcp", host = host, port = config.port }
   132 end
   134 request.set_404_route{ module = 'index', view = '404' }
   136 request.set_absolute_baseurl(config.absolute_base_url)
   138 listen(listen_options)
   140 listen{
   141   {
   142     proto = "interval",
   143     name  = "send_pending_notifications",
   144     delay = 5,
   145     handler = function()
   146       while true do
   147         if not Newsletter:send_next_newsletter() then
   148           break
   149         end
   150       end
   151       while true do
   152         if not Event:send_next_notification() then
   153           break
   154         end
   155       end
   156       while true do
   157         if not InitiativeForNotification:notify_next_member() then
   158           break
   159         end
   160       end
   161     end
   162   },
   163   min_fork = 1,
   164   max_fork = 1
   165 }
   167 execute.inner()
