liquid_feedback_frontend

view config/example.lua @ 1220:af42478acf74

Avoid executing commands after error in lf4rcs.commit(...)
author jbe
date Tue Dec 01 02:10:04 2015 +0100 (2015-12-01)
parents 30523f31b186
children e80c8790a1ca
line source
1 -- ========================================================================
2 -- MANDATORY (MUST BE CAREFULLY CHECKED AND PROPERLY SET!)
3 -- ========================================================================
5 -- Name of this instance, defaults to name of config file
6 -- ------------------------------------------------------------------------
7 config.instance_name = "Instance name"
10 -- Information about service provider (HTML)
11 -- ------------------------------------------------------------------------
12 config.app_service_provider = "Snake Oil<br/>10000 Berlin<br/>Germany"
15 -- A HTML formatted text the user has to accept while registering
16 -- ------------------------------------------------------------------------
17 config.use_terms = "<h1>Terms of Use</h1><p>Insert terms here</p>"
20 -- Checkbox(es) the user has to accept while registering
21 -- ------------------------------------------------------------------------
22 config.use_terms_checkboxes = {
23 {
24 name = "terms_of_use_v1",
25 html = "I accept the terms of use.",
26 not_accepted_error = "You have to accept the terms of use to be able to register."
27 },
28 -- {
29 -- name = "extra_terms_of_use_v1",
30 -- html = "I accept the extra terms of use.",
31 -- not_accepted_error = "You have to accept the extra terms of use to be able to register."
32 -- }
33 }
36 -- Absolute base url of application
37 -- ------------------------------------------------------------------------
38 config.absolute_base_url = "http://example.com/"
41 -- Connection information for the LiquidFeedback database
42 -- ------------------------------------------------------------------------
43 config.database = { engine='postgresql', dbname='liquid_feedback' }
46 -- Location of the rocketwiki binaries
47 -- ------------------------------------------------------------------------
48 config.enforce_formatting_engine = "markdown2"
49 config.formatting_engines = {
50 { id = "markdown2",
51 name = "python-markdown2",
52 executable = "markdown2",
53 args = {'-s', 'escape', '-x', 'nofollow,wiki-tables'},
54 remove_images = true
55 },
56 -- { id = "markdown_py",
57 -- name = "Python Markdown",
58 -- executable = "markdown_py",
59 -- args = {'-s', 'escape', '-x', 'extra', '-x', 'nl2br', '-x', 'sane_lists'},
60 -- remove_images = true
61 -- },
62 -- { id = "rocketwiki",
63 -- name = "RocketWiki",
64 -- executable = "/opt/rocketwiki-lqfb/rocketwiki-lqfb"
65 -- },
66 -- { id = "compat",
67 -- name = "Traditional WIKI syntax",
68 -- executable = "/opt/rocketwiki-lqfb/rocketwiki-lqfb-compat"
69 -- },
70 }
73 -- Public access level
74 -- ------------------------------------------------------------------------
75 -- Available options:
76 -- "none"
77 -- -> Closed user group, no public access at all
78 -- (except login/registration/password reset)
79 -- "anonymous"
80 -- -> Shows only initiative/suggestions texts and aggregated
81 -- supporter/voter counts
82 -- "authors_pseudonymous"
83 -- -> Like anonymous, but shows screen names of authors
84 -- "all_pseudonymous"
85 -- -> Show everything a member can see, except profile pages
86 -- "everything"
87 -- -> Show everything a member can see, including profile pages
88 -- ------------------------------------------------------------------------
89 config.public_access = "none"
93 -- ========================================================================
94 -- OPTIONAL
95 -- Remove leading -- to use a option
96 -- ========================================================================
98 -- Disable registration
99 -- ------------------------------------------------------------------------
100 -- Available options:
101 -- false: registration is enabled (default)
102 -- true: registration is disabled
103 -- ------------------------------------------------------------------------
104 -- config.disable_registration = true
107 -- List of enabled languages, defaults to available languages
108 -- ------------------------------------------------------------------------
109 -- config.enabled_languages = { 'en', 'de', 'eo', 'el', 'hu', 'it', 'ka', 'nl', 'zh-Hans', 'zh-TW' }
112 -- Default language, defaults to "en"
113 -- ------------------------------------------------------------------------
114 -- config.default_lang = "en"
117 -- after how long is a user considered inactive and the trustee will see warning,
118 -- notation is according to postgresql intervals, default: no warning at all
119 -- ------------------------------------------------------------------------
120 -- config.delegation_warning_time = '6 months'
123 -- after which time a user is advised (_soft) or forced (_hard) to check
124 -- unit and area delegations. default: no check at all
125 -- ------------------------------------------------------------------------
126 -- config.check_delegations_interval_hard = "6 months"
127 -- config.check_delegations_interval_soft = "3 months"
130 -- default option when checking delegations
131 -- available options: "confirm", "revoke" and "none", default: "confirm"
132 -- ------------------------------------------------------------------------
133 -- config.check_delegations_default = "confirm"
136 -- Prefix of all automatic mails, defaults to "[Liquid Feedback] "
137 -- ------------------------------------------------------------------------
138 -- config.mail_subject_prefix = "[LiquidFeedback] "
141 -- Sender of all automatic mails, defaults to system defaults
142 -- ------------------------------------------------------------------------
143 -- config.mail_envelope_from = "liquidfeedback@example.com"
144 -- config.mail_from = { name = "LiquidFeedback", address = "liquidfeedback@example.com" }
145 -- config.mail_reply_to = { name = "Support", address = "support@example.com" }
148 -- Configuration of password hashing algorithm (defaults to "crypt_sha512")
149 -- ------------------------------------------------------------------------
150 -- config.password_hash_algorithm = "crypt_sha512"
151 -- config.password_hash_algorithm = "crypt_sha256"
152 -- config.password_hash_algorithm = "crypt_md5"
155 -- Number of rounds for crypt_sha* algorithms, minimum and maximum
156 -- (defaults to minimum 10000 and maximum 20000)
157 -- ------------------------------------------------------------------------
158 -- config.password_hash_min_rounds = 10000
159 -- config.password_hash_max_rounds = 20000
162 -- Supply custom url for avatar/photo delivery
163 -- ------------------------------------------------------------------------
164 -- config.fastpath_url_func = nil
167 -- Local directory for database dumps offered for download
168 -- ------------------------------------------------------------------------
169 -- config.download_dir = nil
172 -- Special use terms for database dump download
173 -- ------------------------------------------------------------------------
174 -- config.download_use_terms = "=== Download use terms ===\n"
177 -- Use custom image conversion, defaults to ImageMagick's convert
178 -- ------------------------------------------------------------------------
179 --config.member_image_content_type = "image/jpeg"
180 --config.member_image_convert_func = {
181 -- avatar = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "48x48", "jpeg:-") end,
182 -- photo = function(data) return extos.pfilter(data, "convert", "jpeg:-", "-thumbnail", "240x240", "jpeg:-") end
183 --}
186 -- Display a html formatted public message of the day
187 -- ------------------------------------------------------------------------
188 -- config.motd_public = "<h1>Message of the day (public)</h1><p>The MOTD is formatted with HTML</p>"
191 -- Display a html formatted internal message of the day
192 -- ------------------------------------------------------------------------
193 -- config.motd_intern = "<h1>Message of the day (intern)</h1><p>The MOTD is formatted with HTML</p>"
196 -- Automatic issue related discussion URL
197 -- ------------------------------------------------------------------------
198 -- config.issue_discussion_url_func = function(issue)
199 -- return "http://example.com/discussion/issue_" .. tostring(issue.id)
200 -- end
203 -- Integration of Etherpad, disabled by default
204 -- ------------------------------------------------------------------------
205 --config.etherpad = {
206 -- base_url = "http://example.com:9001/",
207 -- api_base = "http://localhost:9001/",
208 -- api_key = "mysecretapikey",
209 -- group_id = "mygroupname",
210 -- cookie_path = "/"
211 --}
214 -- Free timings
215 -- ------------------------------------------------------------------------
216 -- This example expects a date string entered in the free timing field
217 -- by the user creating a poll, interpreting it as target date for then
218 -- poll and splits the remaining time at the ratio of 4:1:2
219 -- Please note, polling policies never have an admission phase
220 -- The available_func is optional, if not set any target date is allowed
222 config.free_timing = {
223 calculate_func = function(policy, timing_string)
224 local function interval_by_seconds(secs)
225 local secs_per_day = 60 * 60 * 24
226 local days
227 days = math.floor(secs / secs_per_day)
228 secs = secs - days * secs_per_day
229 return days .. " days " .. secs .. " seconds"
230 end
231 local target_date = parse.date(timing_string, atom.date)
232 if not target_date then
233 return false
234 end
235 local target_timestamp = target_date.midday
236 local now = atom.timestamp:get_current()
237 trace.debug(target_timestamp, now)
238 local duration = target_timestamp - now
239 if duration < 0 then
240 return false
241 end
242 return {
243 discussion = interval_by_seconds(duration / 7 * 4),
244 verification = interval_by_seconds(duration / 7 * 1),
245 voting = interval_by_seconds(duration / 7 * 2)
246 }
247 end,
248 available_func = function(policy)
249 return {
250 { name = "End of 2013", id = '2013-12-31' },
251 { name = "End of 2014", id = '2014-12-31' },
252 { name = "End of 2015", id = '2015-12-31' }
253 }
254 end
255 }
258 -- Configuration of lf4rcs
259 -- ------------------------------------------------------------------------
260 config.lf4rc = {}
262 -- Example configuration for controlling a Git repository
263 config.lf4rcs.git = {
265 render_draft_reference = function(url, draft)
266 if not draft.external_reference then return end
267 ui.tag{ content = _"Changeset:" }
268 slot.put(" ")
269 ui.link{
270 text = draft.external_reference,
271 external = url .. ";a=commit;h=" .. draft.external_reference
272 }
273 end,
275 get_remote_user = function()
276 return os.getenv("REMOTE_USER")
277 end,
279 get_branches = function(path, exec)
280 local branches = {}
281 for line in io.lines() do
282 local oldrev, newrev, branch = string.match(line, "([^ ]+) ([^ ]+) refs/heads/(.+)")
283 if not branch then
284 return nil, "unexpected format from git hook environment"
285 end
286 branches[branch] = { newrev }
287 end
288 return branches
289 end,
291 commit = function(path, exec, branch, target_node_id, close_message, merge_message)
292 if merge_message then
293 -- TODO reset on error
294 exec("git", "-C", path, "checkout", "master")
295 exec("git", "-C", path, "merge", target_node_id, "-m", merge_message)
296 exec("git", "-C", path, "push", "origin", "master")
297 end
298 end
300 }
302 -- Example configuration for controlling a Mercurial repository
303 config.lf4rcs.hg = {
305 working_branch_name = "work",
307 render_draft_reference = function(url, draft)
308 if not draft.external_reference then return end
309 ui.tag{ content = _"Changeset graph:" }
310 slot.put(" ")
311 ui.link{
312 text = draft.external_reference,
313 external = url .. "/graph/" .. draft.external_reference
314 }
315 end,
317 get_remote_user = function()
318 return os.getenv("REMOTE_USER")
319 end,
321 get_branches = function(path, exec)
322 local first_node_id = os.getenv("HG_NODE")
323 if not first_node_id then
324 return nil, "internal error, no first node ID available"
325 end
326 local hg_log = exec(
327 "hg", "log", "-R", path, "-r", first_node_id .. ":", "--template", "{branches}\n"
328 )
329 local branches = {}
330 for branch in hg_log:gmatch("(.-)\n") do
331 if branch == "" then branch = "default" end
332 if not branches[branch] then
333 branches[branch] = {}
334 local head_lines = exec(
335 "hg", "heads", "-R", path, "--template", "{node}\n", branch
336 )
337 for node_id in string.gmatch(head_lines, "[^\n]+") do
338 table.insert(branches[branch], node_id)
339 end
340 end
341 end
342 return branches
343 end,
345 extra_checks = function(path, exec)
346 local result = exec("hg", "heads", "-t", "-c")
347 for branch in string.gmatch(result, "[^\n]+") do
348 if branch == lf4rcs.config.hg.working_branch_name then
349 return nil, "open head found for branch " .. lf4rcs.config.hg.working_branch_name
350 end
351 end
352 return true
353 end,
355 commit = function(path, exec, branch, target_node_id, close_message, merge_message)
356 exec("hg", "up", "-R", path, "-C", "-r", target_node_id)
357 exec("hg", "commit", "-R", path, "--close-branch", "-m", close_message)
358 if merge_message then
359 exec("hg", "up", "-R", path, "-C", "-r", "default")
360 exec("hg", "merge", "-R", path, "-r", "tip")
361 exec("hg", "commit", "-R", path, "-m", merge_message)
362 end
363 end
365 }
367 lf4rcs.init()
370 -- External references
371 -- ------------------------------------------------------------------------
372 -- Rendering of external references
374 --[[
375 config.render_external_reference = {
376 draft = function(draft, wrapper)
377 wrapper(function()
378 ui.tag{ content = draft.external_reference)
379 end)
380 end,
381 initiative = function(initiative, wrapper)
382 wrapper(function()
383 ui.tag{ content = initiative.external_reference)
384 end)
385 end
386 end
387 --]]
389 -- Admin logger
390 -- ------------------------------------------------------------------------
391 -- Logging administrative activities
392 -- disabled by default
394 --[[
395 config.admin_logger = function(params)
397 local adminid = app.session.member_id
398 local adminname = app.session.member.name
399 local url = params._webmcp_path
401 -- do something (e.g. calling 'logger' via extos.pfilter)
403 end
404 --]]
407 -- Network interface to bind to
408 -- ------------------------------------------------------------------------
409 -- Available options:
410 -- true: bind to localhost (default)
411 -- false: bind to all interface
412 -- ------------------------------------------------------------------------
413 -- config.localhost = true
416 -- Network port to bind to
417 -- ------------------------------------------------------------------------
418 -- config.port = 8080
421 -- Serving content via IPV6
422 -- ------------------------------------------------------------------------
423 -- Available options:
424 -- nil or false: do not serve via IPv6 (default)
425 -- true: serve via IPv6
426 -- ------------------------------------------------------------------------
427 -- config.ipv6 = false
430 -- Application server fork configuration
431 -- ------------------------------------------------------------------------
432 -- config.fork = {
433 -- pre = 2, -- desired number of spare (idle) processes
434 -- min = 4, -- minimum number of processes
435 -- max = 128, -- maximum number of processes (hard limit)
436 -- delay = 0.125, -- delay (seconds) between creation of spare processes
437 -- error_delay = 2, -- delay (seconds) before retry of failed process creation
438 -- exit_delay = 2, -- delay (seconds) between destruction of excessive spare processes
439 -- idle_timeout = 900, -- idle time (seconds) after a fork gets terminated (0 for no timeout)
440 -- memory_limit = 0, -- maximum memory consumption (bytes) before process gets terminated
441 -- min_requests = 50, -- minimum count of requests handled before fork is terminated
442 -- max_requests = 100 -- maximum count of requests handled before fork is terminated
443 -- }
446 -- HTTP server options
447 -- ------------------------------------------------------------------------
448 -- http_options = {
449 -- static_headers = {} -- string or table of static headers to be returned with every request
450 -- request_header_size_limit = 1024*1024, -- maximum size of request body sent by client
451 -- request_body_size_limit = 64*1024*1024, -- maximum size of request body sent by client
452 -- idle_timeout = 65, -- maximum time until receiving the first byte of the request headera
453 -- stall_timeout = 60, -- maximum time a client connection may be stalled
454 -- request_header_timeout = 120, -- maximum time until receiving the remaining bytes of the request header
455 -- response_timeout = 3600, -- time in which request body and response must be sent
456 -- maximum_input_chunk_size = 16384 -- tweaks behavior of request-body parser
457 -- minimum_output_chunk_size = 1024 -- chunk size for chunked-transfer-encoding
458 -- }
461 -- WebMCP accelerator
462 -- uncomment the following two lines to use C implementations of chosen
463 -- functions and to disable garbage collection during the request, to
464 -- increase speed:
465 -- ------------------------------------------------------------------------
466 -- require 'webmcp_accelerator'
467 -- if cgi then collectgarbage("stop") end
469 -- Trace debug
470 -- uncomment the following line to enable debug trace
471 -- config.enable_debug_trace = true
473 -- ========================================================================
474 -- Do main initialisation (DO NOT REMOVE FOLLOWING SECTION)
475 -- ========================================================================
477 execute.config("init")

Impressum / About Us