liquid_feedback_frontend
view app/main/index/index.lua @ 1600:d47d2b0cd7c2
Removed debug code
| author | bsw | 
|---|---|
| date | Sun Jan 31 22:12:27 2021 +0100 (2021-01-31) | 
| parents | 6b203b43bef3 | 
| children | a3a7120a67be | 
 line source
     1 if not app.session:has_access("anonymous") then
     2   slot.put("<br />      Closed user group, please login.<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />")
     3   return
     4 end
     6 local unit_id = request.get_param{ name = "unit" }
     7 local area_id = request.get_param{ name = "area" }
     9 if unit_id == "all" then
    10   unit_id = nil
    11   area_id = nil
    12 end
    14 if area_id == "all" then
    15   area_id = nil
    16 end
    18 local unit
    19 local area
    21 if unit_id then
    22   unit = Unit:by_id(unit_id)
    23   if not unit or unit.attr.hidden then
    24     execute.view { module = "index", view = "404" }
    25     request.set_status("404 Not Found")
    26     return
    27   end
    28 end
    31 if area_id then
    32   area = Area:by_id(area_id)
    33   if not area or area.unit_id ~= unit.id then
    34     execute.view { module = "index", view = "404" }
    35     request.set_status("404 Not Found")
    36     return
    37   end
    38 end
    40 ui.grid{ content = function()
    41   ui.cell_main{ content = function()
    43     execute.view{ module = "index", view = "_sidebar_motd_public" }
    45     execute.view{ module = "issue", view = "_list" }
    46   end }
    48   ui.cell_sidebar{ content = function()
    49     execute.view{ module = "index", view = "_sidebar_motd" }
    50     if app.session.member then
    51       execute.view{ module = "index", view = "_sidebar_notifications" }
    52     end
    53     if config.firstlife then
    54       ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
    55         ui.tag{ tag = "iframe", attr = { src = config.firstlife.areaviewer_url .. "?" .. config.firstlife.coordinates .. "&domain=" .. request.get_absolute_baseurl(), class = "map" }, content = "" }
    56       end }
    57     end
    58     if config.map then
    59       local initiatives = Initiative:new_selector():exec()
    60       local geo_objects = {}
    61       for i, initiative in ipairs(initiatives) do
    62         if initiative.location and initiative.location.coordinates then
    63           local geo_object = {
    64             lon = initiative.location.coordinates[1],
    65             lat = initiative.location.coordinates[2],
    66             label = "i" .. initiative.id,
    67             description = slot.use_temporary(function()
    68               ui.link{ module = "initiative", view = "show", id = initiative.id, text = initiative.display_name }
    69             end),
    70             type = "initiative"
    71           }
    72           table.insert(geo_objects, geo_object)
    73         end
    74       end
    75       if ontomap_get_instances then
    76         local instances = ontomap_get_instances()
    77         for i, instance in ipairs(instances) do
    78           table.insert(geo_objects, instance)
    79         end
    80       end
    81       ui.container{ attr = { class = "map mdl-special-card mdl-shadow--2dp pos-before-main" }, content = function()
    82         ui.map(geo_objects)  
    83       end }
    84     end
    85     if config.logo then
    86       config.logo()
    87     end
    88     if area then
    89       execute.view{ module = "area", view = "_sidebar_whatcanido", params = { area = area } }
    90     elseif unit then
    91       execute.view{ module = "unit", view = "_sidebar_whatcanido", params = { unit = unit } }
    92     else
    93       execute.view{ module = "index", view = "_sidebar_whatcanido" }
    94     end
    96     execute.view { module = "index", view = "_sidebar_members" }
    98   end }
    99 end }
