liquid_feedback_frontend

changeset 1725:4a5a79a37db1

Render links in unit and area description, updated layout of unit and area box
author bsw
date Tue Sep 28 09:43:58 2021 +0200 (2021-09-28)
parents c33916811ca7
children 65b8703e2d8a
files app/main/index/_head.lua env/format/text_with_links.lua
line diff
     1.1 --- a/app/main/index/_head.lua	Tue Sep 28 09:29:34 2021 +0200
     1.2 +++ b/app/main/index/_head.lua	Tue Sep 28 09:43:58 2021 +0200
     1.3 @@ -28,13 +28,17 @@
     1.4    ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
     1.5      ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
     1.6        ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = unit.name }
     1.7 -      if unit.description and #(unit.description) > 0 then
     1.8 -        ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = unit.description }
     1.9 -      end
    1.10 -      if config.render_external_reference_unit then
    1.11 +    end }
    1.12 +    if unit.description and #(unit.description) > 0 then
    1.13 +      ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    1.14 +        slot.put(format.text_with_links(unit.description))
    1.15 +      end }
    1.16 +    end
    1.17 +    if config.render_external_reference_unit then
    1.18 +      ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    1.19          config.render_external_reference_unit(unit)
    1.20 -      end
    1.21 -    end }
    1.22 +      end }
    1.23 +    end
    1.24  
    1.25  
    1.26      if not (config.voting_only and config.disable_delegations) and app.session.member_id and (
    1.27 @@ -80,10 +84,12 @@
    1.28      if unit then
    1.29        ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    1.30          ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = area.name }
    1.31 -        if area.description and #(area.description) > 0 then
    1.32 -          ui.container{ attr = { class = "mdl-card__subtitle-text" }, content = area.description }
    1.33 -        end
    1.34        end }
    1.35 +      if area.description and #(area.description) > 0 then
    1.36 +        ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
    1.37 +          slot.put(format.text_with_links(area.description))
    1.38 +        end }
    1.39 +      end
    1.40      end
    1.41      if not (config.voting_only and config.disable_delegations) and app.session.member_id and (
    1.42        app.session.member:has_voting_right_for_unit_id(area.unit_id) 
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/env/format/text_with_links.lua	Tue Sep 28 09:43:58 2021 +0200
     2.3 @@ -0,0 +1,7 @@
     2.4 +function format.text_with_links(value)
     2.5 +  value = encode.html(value)
     2.6 +  value = string.gsub(value, "http[^%s:]*://[^%s]+", function(match)
     2.7 +    return "<a href=\"" .. match .. "\">" .. match .. "</a>"
     2.8 +  end)
     2.9 +  return value
    2.10 +end

Impressum / About Us