liquid_feedback_frontend

changeset 1145:904f6807f7fa

Added support for upcoming moonbridge bases WebMCP
author bsw
date Sat Mar 21 15:26:39 2015 +0100 (2015-03-21)
parents c02aea493bc1
children ce9daada32dd
files app/main/_filter/20_session.lua app/main/_filter_view/30_navigation.lua app/main/_postfork/10_database.lua app/main/area/show.lua app/main/contact/list.lua app/main/delegation/show.lua app/main/draft/new.lua app/main/index/_action/login.lua app/main/index/_member_home.lua app/main/index/_sidebar_notifications.lua app/main/index/index.lua app/main/index/login.lua app/main/initiative/_list_element.lua app/main/initiative/show.lua app/main/issue/_filters.lua app/main/issue/_list2.lua app/main/issue/_sidebar_whatcanido.lua app/main/member/_list.lua app/main/member/_sidebar_whatcanido.lua app/main/member_image/show.lua app/main/vote/list.lua config/init.lua env/ui/filters.lua env/ui/tabs.lua env/util/micro_avatar.lua model/unit.lua
line diff
     1.1 --- a/app/main/_filter/20_session.lua	Sat Mar 21 15:03:39 2015 +0100
     1.2 +++ b/app/main/_filter/20_session.lua	Sat Mar 21 15:26:39 2015 +0100
     1.3 @@ -1,5 +1,7 @@
     1.4 -if cgi.cookies.liquid_feedback_session then
     1.5 -  app.session = Session:by_ident(cgi.cookies.liquid_feedback_session)
     1.6 +local cookie = request.get_cookie{ name = "liquid_feedback_session" }
     1.7 +
     1.8 +if cookie then
     1.9 +  app.session = Session:by_ident(cookie)
    1.10  end
    1.11  if not app.session then
    1.12    app.session = Session:new()
     2.1 --- a/app/main/_filter_view/30_navigation.lua	Sat Mar 21 15:03:39 2015 +0100
     2.2 +++ b/app/main/_filter_view/30_navigation.lua	Sat Mar 21 15:26:39 2015 +0100
     2.3 @@ -109,4 +109,11 @@
     2.4    }
     2.5  end)
     2.6  
     2.7 +if not config.enable_debug_trace then
     2.8 +  trace.disable()
     2.9 +else
    2.10 +  slot.put_into('trace_button', '<div id="trace_show" onclick="document.getElementById(\'trace_content\').style.display=\'block\';this.style.display=\'none\';">TRACE</div>')
    2.11 +end
    2.12 +
    2.13 +
    2.14  execute.inner()
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/app/main/_postfork/10_database.lua	Sat Mar 21 15:26:39 2015 +0100
     3.3 @@ -0,0 +1,17 @@
     3.4 +-- open and set default database handle
     3.5 +_G.db = assert(mondelefant.connect(config.database))
     3.6 +
     3.7 +function mondelefant.class_prototype:get_db_conn() return db end
     3.8 +
     3.9 +-- enable output of SQL commands in trace system
    3.10 +function db:sql_tracer(command)
    3.11 +  return function(error_info)
    3.12 +    local error_info = error_info or {}
    3.13 +    trace.sql{ command = command, error_position = error_info.position }
    3.14 +  end
    3.15 +end
    3.16 +
    3.17 +execute.inner()
    3.18 +
    3.19 +-- close the database
    3.20 +db:close()
     4.1 --- a/app/main/area/show.lua	Sat Mar 21 15:03:39 2015 +0100
     4.2 +++ b/app/main/area/show.lua	Sat Mar 21 15:26:39 2015 +0100
     4.3 @@ -29,7 +29,7 @@
     4.4    }
     4.5  }
     4.6  
     4.7 -function getOpenIssuesSelector()
     4.8 +local function getOpenIssuesSelector()
     4.9    return area:get_reference_selector("issues")
    4.10      :add_order_by("coalesce(issue.fully_frozen + issue.voting_time, issue.half_frozen + issue.verification_time, issue.accepted + issue.discussion_time, issue.created + issue.admission_time) - now()")
    4.11  end
     5.1 --- a/app/main/contact/list.lua	Sat Mar 21 15:03:39 2015 +0100
     5.2 +++ b/app/main/contact/list.lua	Sat Mar 21 15:26:39 2015 +0100
     5.3 @@ -48,8 +48,8 @@
     5.4                        mode = "redirect",
     5.5                        module = request.get_module(),
     5.6                        view = request.get_view(),
     5.7 -                      id = param.get_id_cgi(),
     5.8 -                      params = param.get_all_cgi()
     5.9 +                      id = request.get_id_string(),
    5.10 +                      params = request.get_param_strings()
    5.11                      }
    5.12                    }
    5.13                  }
    5.14 @@ -66,8 +66,8 @@
    5.15                        mode = "redirect",
    5.16                        module = request.get_module(),
    5.17                        view = request.get_view(),
    5.18 -                      id = param.get_id_cgi(),
    5.19 -                      params = param.get_all_cgi()
    5.20 +                      id = request.get_id_string(),
    5.21 +                      params = request.get_param_strings()
    5.22                      }
    5.23                    }
    5.24                  }
    5.25 @@ -87,8 +87,8 @@
    5.26                      mode = "redirect",
    5.27                      module = request.get_module(),
    5.28                      view = request.get_view(),
    5.29 -                    id = param.get_id_cgi(),
    5.30 -                    params = param.get_all_cgi()
    5.31 +                    id = request.get_id_string(),
    5.32 +                    params = request.get_param_strings()
    5.33                    }
    5.34                  }
    5.35                }
     6.1 --- a/app/main/delegation/show.lua	Sat Mar 21 15:03:39 2015 +0100
     6.2 +++ b/app/main/delegation/show.lua	Sat Mar 21 15:26:39 2015 +0100
     6.3 @@ -46,12 +46,6 @@
     6.4    head_text = _"Set issue delegation"
     6.5  end
     6.6  
     6.7 -if param.get("initiative_id", atom.integer) then
     6.8 -  issue_id = initiative.issue_id
     6.9 -  scope = "issue"
    6.10 -end
    6.11 -
    6.12 -
    6.13  local delegation
    6.14  local unit_id
    6.15  local area_id
    6.16 @@ -146,7 +140,7 @@
    6.17        }
    6.18      },
    6.19      content = function()
    6.20 -      local record
    6.21 +      local records
    6.22        if issue then
    6.23          local delegate_name = ""
    6.24          local scope = _"no delegation set"
    6.25 @@ -232,7 +226,7 @@
    6.26          end
    6.27        end
    6.28  
    6.29 -      disabled_records = {}
    6.30 +      local disabled_records = {}
    6.31        disabled_records["_"] = true
    6.32        disabled_records[app.session.member_id] = true
    6.33  
     7.1 --- a/app/main/draft/new.lua	Sat Mar 21 15:03:39 2015 +0100
     7.2 +++ b/app/main/draft/new.lua	Sat Mar 21 15:26:39 2015 +0100
     7.3 @@ -54,6 +54,7 @@
     7.4        ui.sectionRow( function()
     7.5          ui.field.hidden{ name = "formatting_engine", value = param.get("formatting_engine") }
     7.6          ui.field.hidden{ name = "content", value = param.get("content") }
     7.7 +        local formatting_engine
     7.8          if config.enforce_formatting_engine then
     7.9            formatting_engine = config.enforce_formatting_engine
    7.10          else
     8.1 --- a/app/main/index/_action/login.lua	Sat Mar 21 15:03:39 2015 +0100
     8.2 +++ b/app/main/index/_action/login.lua	Sat Mar 21 15:26:39 2015 +0100
     8.3 @@ -16,7 +16,7 @@
     8.4    return
     8.5  end
     8.6  
     8.7 -function do_etherpad_auth(member)
     8.8 +local function do_etherpad_auth(member)
     8.9    local result = net.curl(
    8.10      config.etherpad.api_base
    8.11      .. "api/1/createAuthorIfNotExistsFor?apikey=" .. config.etherpad.api_key
     9.1 --- a/app/main/index/_member_home.lua	Sat Mar 21 15:03:39 2015 +0100
     9.2 +++ b/app/main/index/_member_home.lua	Sat Mar 21 15:26:39 2015 +0100
     9.3 @@ -1,6 +1,6 @@
     9.4  local member = param.get("member", "table")
     9.5  local for_member = param.get("for_member", atom.boolean)
     9.6 -local filter_unit = param.get_all_cgi()["filter_unit"] or "my_areas"
     9.7 +local filter_unit = request.get_param_strings()["filter_unit"] or "my_areas"
     9.8  
     9.9  if not for_member then
    9.10  
    10.1 --- a/app/main/index/_sidebar_notifications.lua	Sat Mar 21 15:03:39 2015 +0100
    10.2 +++ b/app/main/index/_sidebar_notifications.lua	Sat Mar 21 15:26:39 2015 +0100
    10.3 @@ -96,7 +96,7 @@
    10.4    }
    10.5  end
    10.6  
    10.7 -updated_drafts = Initiative:selector_for_updated_drafts(app.session.member_id):exec()
    10.8 +local updated_drafts = Initiative:selector_for_updated_drafts(app.session.member_id):exec()
    10.9  
   10.10  for i, initiative in ipairs(updated_drafts) do
   10.11    notification_links[#notification_links+1] = {
    11.1 --- a/app/main/index/index.lua	Sat Mar 21 15:03:39 2015 +0100
    11.2 +++ b/app/main/index/index.lua	Sat Mar 21 15:26:39 2015 +0100
    11.3 @@ -1,4 +1,4 @@
    11.4 -function getIssuesSelector()
    11.5 +local function getIssuesSelector()
    11.6    return Issue:new_selector()
    11.7      :add_order_by([[
    11.8        coalesce(
    12.1 --- a/app/main/index/login.lua	Sat Mar 21 15:03:39 2015 +0100
    12.2 +++ b/app/main/index/login.lua	Sat Mar 21 15:26:39 2015 +0100
    12.3 @@ -16,7 +16,7 @@
    12.4    ui.heading{ level = 1, content = _"Login" }
    12.5    ui.container { attr = { class = "right" }, content = function()
    12.6      for i, lang in ipairs(config.enabled_languages) do
    12.7 -
    12.8 +      local langcode
    12.9        locale.do_with({ lang = lang }, function()
   12.10          langcode = _("[Name of Language]")
   12.11        end)
   12.12 @@ -37,8 +37,8 @@
   12.13              mode = "redirect",
   12.14              module = request.get_module(),
   12.15              view = request.get_view(),
   12.16 -            id = param.get_id_cgi(),
   12.17 -            params = param.get_all_cgi()
   12.18 +            id = request.get_id_string(),
   12.19 +            params = request.get_param_strings()
   12.20            }
   12.21          }
   12.22        }
    13.1 --- a/app/main/initiative/_list_element.lua	Sat Mar 21 15:03:39 2015 +0100
    13.2 +++ b/app/main/initiative/_list_element.lua	Sat Mar 21 15:26:39 2015 +0100
    13.3 @@ -65,7 +65,7 @@
    13.4    and initiative.negative_votes ~= nil 
    13.5    and not for_event
    13.6  then
    13.7 -  function percent(p, q)
    13.8 +  local function percent(p, q)
    13.9      if q > 0 then
   13.10        return math.floor(p / q * 100) .. "%"
   13.11      else
    14.1 --- a/app/main/initiative/show.lua	Sat Mar 21 15:03:39 2015 +0100
    14.2 +++ b/app/main/initiative/show.lua	Sat Mar 21 15:26:39 2015 +0100
    14.3 @@ -24,6 +24,8 @@
    14.4    }
    14.5  }
    14.6  
    14.7 +local direct_supporter
    14.8 +
    14.9  if app.session.member_id then
   14.10    direct_supporter = initiative.issue.member_info.own_participation and initiative.member_info.supported
   14.11  end
    15.1 --- a/app/main/issue/_filters.lua	Sat Mar 21 15:03:39 2015 +0100
    15.2 +++ b/app/main/issue/_filters.lua	Sat Mar 21 15:26:39 2015 +0100
    15.3 @@ -1,4 +1,4 @@
    15.4 -local params = param.get_all_cgi()
    15.5 +local params = request.get_param_strings() -- TODO replace with request.get_param() calls?
    15.6  
    15.7  local for_unit = param.get("for_unit", atom.boolean)
    15.8  local for_area = param.get("for_area", atom.boolean)
    16.1 --- a/app/main/issue/_list2.lua	Sat Mar 21 15:03:39 2015 +0100
    16.2 +++ b/app/main/issue/_list2.lua	Sat Mar 21 15:26:39 2015 +0100
    16.3 @@ -9,7 +9,7 @@
    16.4  
    16.5  local limit = 25
    16.6  
    16.7 -local mode = param.get_all_cgi()["mode"] or "issue"
    16.8 +local mode = request.get_param{ name = "mode" } or "issue"
    16.9  
   16.10  if for_initiative or for_issue or for_member then
   16.11    mode = "timeline"
   16.12 @@ -24,7 +24,7 @@
   16.13    
   16.14  elseif mode == "timeline" then
   16.15  
   16.16 -  local event_max_id = param.get_all_cgi()["event_max_id"]
   16.17 +  local event_max_id = request.get_param_strings()["event_max_id"]
   16.18  
   16.19    selector = Event:new_selector()
   16.20      :add_order_by("event.id DESC")
   16.21 @@ -76,7 +76,7 @@
   16.22      :add_field("array_length(_delegating_interest.delegate_member_ids, 1)", "delegation_chain_length")
   16.23  end
   16.24  
   16.25 -function doit()
   16.26 +local function doit()
   16.27  
   16.28    local last_event_id
   16.29  
   16.30 @@ -316,6 +316,7 @@
   16.31          end }
   16.32        elseif #items > limit then
   16.33          ui.container { attr = { class = row_class }, content = function ()
   16.34 +          local params = request.get_param_strings()
   16.35            ui.link{
   16.36              attr = { class = "moreLink" },
   16.37              text = _"Show older events",
   16.38 @@ -325,9 +326,9 @@
   16.39              params = {
   16.40                mode = "timeline",
   16.41                event_max_id = last_event_id,
   16.42 -              tab = param.get_all_cgi()["tab"],
   16.43 -              phase = param.get_all_cgi()["phase"],
   16.44 -              closed = param.get_all_cgi()["closed"]
   16.45 +              tab = params["tab"],
   16.46 +              phase = params["phase"],
   16.47 +              closed = params["closed"]
   16.48              }
   16.49            }
   16.50          end }
   16.51 @@ -370,4 +371,4 @@
   16.52  end
   16.53  
   16.54  ui.filters(filters)
   16.55 -      
   16.56 \ No newline at end of file
   16.57 +      
    17.1 --- a/app/main/issue/_sidebar_whatcanido.lua	Sat Mar 21 15:03:39 2015 +0100
    17.2 +++ b/app/main/issue/_sidebar_whatcanido.lua	Sat Mar 21 15:26:39 2015 +0100
    17.3 @@ -132,8 +132,8 @@
    17.4                  mode = "redirect",
    17.5                  module = request.get_module(),
    17.6                  view = request.get_view(),
    17.7 -                id = param.get_id_cgi(),
    17.8 -                params = param.get_all_cgi()
    17.9 +                id = request.get_id_string(),
   17.10 +                params = request.get_param_strings()
   17.11                }
   17.12              }
   17.13            }
   17.14 @@ -153,8 +153,8 @@
   17.15                  mode = "redirect",
   17.16                  module = request.get_module(),
   17.17                  view = request.get_view(),
   17.18 -                id = param.get_id_cgi(),
   17.19 -                params = param.get_all_cgi()
   17.20 +                id = request.get_id_string(),
   17.21 +                params = request.get_param_strings()
   17.22                }
   17.23              }
   17.24            }
   17.25 @@ -532,8 +532,8 @@
   17.26                        mode = "redirect",
   17.27                        module = request.get_module(),
   17.28                        view = request.get_view(),
   17.29 -                      id = param.get_id_cgi(),
   17.30 -                      params = param.get_all_cgi()
   17.31 +                      id = request.get_id_string(),
   17.32 +                      params = request.get_param_strings()
   17.33                      }
   17.34                    }
   17.35                  }
   17.36 @@ -554,8 +554,8 @@
   17.37                        mode = "redirect",
   17.38                        module = request.get_module(),
   17.39                        view = request.get_view(),
   17.40 -                      id = param.get_id_cgi(),
   17.41 -                      params = param.get_all_cgi()
   17.42 +                      id = request.get_id_string(),
   17.43 +                      params = request.get_param_strings()
   17.44                      }
   17.45                    }
   17.46                  }
    18.1 --- a/app/main/member/_list.lua	Sat Mar 21 15:03:39 2015 +0100
    18.2 +++ b/app/main/member/_list.lua	Sat Mar 21 15:26:39 2015 +0100
    18.3 @@ -23,8 +23,6 @@
    18.4    end
    18.5  end
    18.6  
    18.7 -ui.add_partial_param_names{ "member_list" }
    18.8 -
    18.9  local filter = { name = "member_filter" }
   18.10  
   18.11  if issue or initiative then
   18.12 @@ -73,7 +71,7 @@
   18.13  }
   18.14  
   18.15  
   18.16 -function list_members()
   18.17 +local function list_members()
   18.18    local ui_paginate = ui.paginate
   18.19    if no_paginate then
   18.20      ui_paginate = function (args) args.content() end
    19.1 --- a/app/main/member/_sidebar_whatcanido.lua	Sat Mar 21 15:03:39 2015 +0100
    19.2 +++ b/app/main/member/_sidebar_whatcanido.lua	Sat Mar 21 15:26:39 2015 +0100
    19.3 @@ -142,8 +142,8 @@
    19.4                    mode = "redirect",
    19.5                    module = request.get_module(),
    19.6                    view = request.get_view(),
    19.7 -                  id = param.get_id_cgi(),
    19.8 -                  params = param.get_all_cgi()
    19.9 +                  id = request.get_id_string(),
   19.10 +                  params = request.get_param_strings()
   19.11                  }
   19.12                }
   19.13              }
   19.14 @@ -171,8 +171,8 @@
   19.15                    mode = "redirect",
   19.16                    module = request.get_module(),
   19.17                    view = request.get_view(),
   19.18 -                  id = param.get_id_cgi(),
   19.19 -                  params = param.get_all_cgi()
   19.20 +                  id = request.get_id_string(),
   19.21 +                  params = request.get_param_strings()
   19.22                  }
   19.23                }
   19.24              }
   19.25 @@ -188,8 +188,8 @@
   19.26                    mode = "redirect",
   19.27                    module = request.get_module(),
   19.28                    view = request.get_view(),
   19.29 -                  id = param.get_id_cgi(),
   19.30 -                  params = param.get_all_cgi()
   19.31 +                  id = request.get_id_string(),
   19.32 +                  params = request.get_param_strings()
   19.33                  }
   19.34                }
   19.35              }
   19.36 @@ -210,8 +210,8 @@
   19.37                    mode = "redirect",
   19.38                    module = request.get_module(),
   19.39                    view = request.get_view(),
   19.40 -                  id = param.get_id_cgi(),
   19.41 -                  params = param.get_all_cgi()
   19.42 +                  id = request.get_id_string(),
   19.43 +                  params = request.get_param_strings()
   19.44                  }
   19.45                }
   19.46              }
   19.47 @@ -227,8 +227,8 @@
   19.48                    mode = "redirect",
   19.49                    module = request.get_module(),
   19.50                    view = request.get_view(),
   19.51 -                  id = param.get_id_cgi(),
   19.52 -                  params = param.get_all_cgi()
   19.53 +                  id = request.get_id_string(),
   19.54 +                  params = request.get_param_strings()
   19.55                  }
   19.56                }
   19.57              }
   19.58 @@ -249,8 +249,8 @@
   19.59                    mode = "redirect",
   19.60                    module = request.get_module(),
   19.61                    view = request.get_view(),
   19.62 -                  id = param.get_id_cgi(),
   19.63 -                  params = param.get_all_cgi()
   19.64 +                  id = request.get_id_string(),
   19.65 +                  params = request.get_param_strings()
   19.66                  }
   19.67                }
   19.68              }
   19.69 @@ -266,8 +266,8 @@
   19.70                    mode = "redirect",
   19.71                    module = request.get_module(),
   19.72                    view = request.get_view(),
   19.73 -                  id = param.get_id_cgi(),
   19.74 -                  params = param.get_all_cgi()
   19.75 +                  id = request.get_id_string(),
   19.76 +                  params = request.get_param_strings()
   19.77                  }
   19.78                }
   19.79              }
   19.80 @@ -293,8 +293,8 @@
   19.81                    mode = "redirect",
   19.82                    module = request.get_module(),
   19.83                    view = request.get_view(),
   19.84 -                  id = param.get_id_cgi(),
   19.85 -                  params = param.get_all_cgi()
   19.86 +                  id = request.get_id_string(),
   19.87 +                  params = request.get_param_strings()
   19.88                  }
   19.89                }
   19.90              }
   19.91 @@ -315,8 +315,8 @@
   19.92                    mode = "redirect",
   19.93                    module = request.get_module(),
   19.94                    view = request.get_view(),
   19.95 -                  id = param.get_id_cgi(),
   19.96 -                  params = param.get_all_cgi()
   19.97 +                  id = request.get_id_string(),
   19.98 +                  params = request.get_param_strings()
   19.99                  }
  19.100                }
  19.101              }
    20.1 --- a/app/main/member_image/show.lua	Sat Mar 21 15:03:39 2015 +0100
    20.2 +++ b/app/main/member_image/show.lua	Sat Mar 21 15:26:39 2015 +0100
    20.3 @@ -1,16 +1,10 @@
    20.4  local image_type = param.get("image_type")
    20.5  local record = MemberImage:by_pk(param.get_id(), image_type, true)
    20.6  
    20.7 -print('Cache-Control: max-age=300'); -- let the client cache the image for 5 minutes
    20.8 -
    20.9  if record == nil then
   20.10 -  local default_file = ({ avatar = "avatar.jpg", photo = nil })[image_type]
   20.11 -  if default_file then
   20.12 -    print('Location: ' .. encode.url{ static = default_file } .. '\n\n')
   20.13 -  else
   20.14 -    print('Location: ' .. encode.url{ static = 'icons/16/lightning.png' } .. '\n\n')
   20.15 -  end
   20.16 -  exit()
   20.17 +  local default_file = ({ avatar = "avatar.jpg", photo = nil })[image_type] or 'icons/16/lightning.png'
   20.18 +  request.redirect{ static = default_file }
   20.19 +  return
   20.20  end
   20.21  
   20.22  assert(record.content_type, "No content-type set for image.")
   20.23 @@ -18,5 +12,6 @@
   20.24  slot.set_layout(nil, record.content_type)
   20.25  
   20.26  if record then
   20.27 +  request.add_header("Cache-Control", "max-age=300"); -- let the client cache the image for 5 minutes
   20.28    slot.put_into("data", record.data)
   20.29  end
    21.1 --- a/app/main/vote/list.lua	Sat Mar 21 15:03:39 2015 +0100
    21.2 +++ b/app/main/vote/list.lua	Sat Mar 21 15:26:39 2015 +0100
    21.3 @@ -234,6 +234,7 @@
    21.4            attr = { id = "voting" },
    21.5            content = function()
    21.6              local approval_index, disapproval_index = 0, 0
    21.7 +            local approval_used, disapproval_used
    21.8              for grade = max_grade, min_grade, -1 do 
    21.9                local entries = sections[grade]
   21.10                local class
    22.1 --- a/config/init.lua	Sat Mar 21 15:03:39 2015 +0100
    22.2 +++ b/config/init.lua	Sat Mar 21 15:26:39 2015 +0100
    22.3 @@ -56,33 +56,10 @@
    22.4    config.database = { engine='postgresql', dbname='liquid_feedback' }
    22.5  end
    22.6  
    22.7 -if not config.enable_debug_trace then
    22.8 -  trace.disable()
    22.9 -else
   22.10 -  slot.put_into('trace_button', '<div id="trace_show" onclick="document.getElementById(\'trace_content\').style.display=\'block\';this.style.display=\'none\';">TRACE</div>')
   22.11 -end
   22.12 -
   22.13 -
   22.14  request.set_404_route{ module = 'index', view = '404' }
   22.15  
   22.16 --- open and set default database handle
   22.17 -db = assert(mondelefant.connect(config.database))
   22.18 -at_exit(function() 
   22.19 -  db:close()
   22.20 -end)
   22.21 -function mondelefant.class_prototype:get_db_conn() return db end
   22.22 -
   22.23 --- enable output of SQL commands in trace system
   22.24 -function db:sql_tracer(command)
   22.25 -  return function(error_info)
   22.26 -    local error_info = error_info or {}
   22.27 -    trace.sql{ command = command, error_position = error_info.position }
   22.28 -  end
   22.29 -end
   22.30 -
   22.31  request.set_absolute_baseurl(config.absolute_base_url)
   22.32  
   22.33 -
   22.34  -- TODO abstraction
   22.35  -- get record by id
   22.36  function mondelefant.class_prototype:by_id(id)
   22.37 @@ -92,3 +69,76 @@
   22.38    return selector:exec()
   22.39  end
   22.40  
   22.41 +-- compatibility for WebMCP 1.2.6
   22.42 +if not listen then
   22.43 +  
   22.44 +  -- open and set default database handle
   22.45 +  _G.db = assert(mondelefant.connect(config.database))
   22.46 +
   22.47 +  function mondelefant.class_prototype:get_db_conn() return db end
   22.48 +
   22.49 +  -- enable output of SQL commands in trace system
   22.50 +  function db:sql_tracer(command)
   22.51 +    return function(error_info)
   22.52 +      local error_info = error_info or {}
   22.53 +      trace.sql{ command = command, error_position = error_info.position }
   22.54 +    end
   22.55 +  end
   22.56 +
   22.57 +  -- close the database at exit
   22.58 +  at_exit(function() 
   22.59 +    db:close()
   22.60 +  end)
   22.61 +  
   22.62 +  function request.get_cookie(args)
   22.63 +    return cgi.cookies[args.name]
   22.64 +  end
   22.65 +  
   22.66 +  function request.get_param(args)
   22.67 +    return request.get_param_strings()[args.name]
   22.68 +  end
   22.69 +  
   22.70 +  function request.add_header(key, value)
   22.71 +    print(key .. ": " .. value)
   22.72 +  end
   22.73 +  
   22.74 +  local request_redirect = request.redirect
   22.75 +  function request.redirect(args)
   22.76 +    if args.static then
   22.77 +      print('Location: ' .. encode.url{ static = args.static } .. '\n\n')
   22.78 +      exit()
   22.79 +    else
   22.80 +      request_redirect(args)
   22.81 +    end
   22.82 +  end
   22.83 +
   22.84 +  
   22.85 +  return
   22.86 +end
   22.87 +
   22.88 +if not config.fork then
   22.89 +  config.fork = {}
   22.90 +end
   22.91 +
   22.92 +if not config.fork.pre then
   22.93 +  config.fork.pre = 4
   22.94 +end
   22.95 +
   22.96 +if not config.fork.max then
   22.97 +  config.fork.max = 8
   22.98 +end
   22.99 +
  22.100 +if not config.fork.delay then
  22.101 +  config.fork.delay = 1
  22.102 +end
  22.103 +
  22.104 +if not config.port then
  22.105 +  config.port = 8080
  22.106 +end
  22.107 +
  22.108 +listen{
  22.109 +  { proto = "tcp4", port = config.port, localhost = true },
  22.110 +  pre_fork = config.fork.pre,
  22.111 +  max_fork = config.fork.max,
  22.112 +  fork_delay = config.fork.delay
  22.113 +}
    23.1 --- a/env/ui/filters.lua	Sat Mar 21 15:03:39 2015 +0100
    23.2 +++ b/env/ui/filters.lua	Sat Mar 21 15:26:39 2015 +0100
    23.3 @@ -5,7 +5,7 @@
    23.4      content = function()
    23.5        for idx, filter in ipairs(args) do
    23.6          local filter_name = filter.name or "filter"
    23.7 -        local current_option = atom.string:load(cgi.params[filter_name])
    23.8 +        local current_option = atom.string:load(request.get_param{ name = filter_name })
    23.9          if not current_option then
   23.10            current_option = param.get(filter_name)
   23.11          end
   23.12 @@ -18,8 +18,8 @@
   23.13          if not current_option or #current_option == 0 or not current_option_valid then
   23.14            current_option = filter[1].name
   23.15          end
   23.16 -        local id     = param.get_id_cgi()
   23.17 -        local params = param.get_all_cgi()
   23.18 +        local id     = request.get_id_string()
   23.19 +        local params = request.get_param_strings()
   23.20          local class = "ui_filter_head"
   23.21          if filter.class then
   23.22            class = class .. " " .. filter.class
    24.1 --- a/env/ui/tabs.lua	Sat Mar 21 15:03:39 2015 +0100
    24.2 +++ b/env/ui/tabs.lua	Sat Mar 21 15:26:39 2015 +0100
    24.3 @@ -4,13 +4,13 @@
    24.4    ui.container{
    24.5      attr = attr,
    24.6      content = function()
    24.7 -      local params = param.get_all_cgi()
    24.8 +      local params = request.get_param_strings()
    24.9        local current_tab = params["tab"]
   24.10        ui.container{
   24.11          attr = { class = "ui_tabs_links" },
   24.12          content = function()
   24.13            for i, tab in ipairs(tabs) do
   24.14 -            local params = param.get_all_cgi()
   24.15 +            local params = request.get_param_strings()
   24.16              if tab.link_params then
   24.17                for key, value in pairs(tab.link_params) do
   24.18                  params[key] = value
   24.19 @@ -27,7 +27,7 @@
   24.20                },
   24.21                module  = request.get_module(),
   24.22                view    = request.get_view(),
   24.23 -              id      = param.get_id_cgi(),
   24.24 +              id      = request.get_id_string(),
   24.25                content = tab.label,
   24.26                params  = params
   24.27              }
    25.1 --- a/env/util/micro_avatar.lua	Sat Mar 21 15:03:39 2015 +0100
    25.2 +++ b/env/util/micro_avatar.lua	Sat Mar 21 15:26:39 2015 +0100
    25.3 @@ -6,7 +6,7 @@
    25.4      }
    25.5    end
    25.6    
    25.7 -  function doit()
    25.8 +  local function doit()
    25.9      if config.fastpath_url_func then
   25.10        ui.image{
   25.11          attr = {
    26.1 --- a/model/unit.lua	Sat Mar 21 15:03:39 2015 +0100
    26.2 +++ b/model/unit.lua	Sat Mar 21 15:26:39 2015 +0100
    26.3 @@ -76,7 +76,7 @@
    26.4  
    26.5  
    26.6  
    26.7 -function recursive_add_child_units(units, parent_unit)
    26.8 +local function recursive_add_child_units(units, parent_unit)
    26.9    parent_unit.childs = {}
   26.10    for i, unit in ipairs(units) do
   26.11      if unit.parent_id == parent_unit.id then
   26.12 @@ -86,7 +86,7 @@
   26.13    end
   26.14  end  
   26.15  
   26.16 -function recursive_get_child_units(units, parent_unit, depth)
   26.17 +local function recursive_get_child_units(units, parent_unit, depth)
   26.18    for i, unit in ipairs(parent_unit.childs) do
   26.19      unit.depth = depth
   26.20      units[#units+1] = unit

Impressum / About Us