liquid_feedback_frontend
annotate app/main/index/index.lua @ 11:77d58efe99fd
Version beta7
Important security fixes:
- Added missing HTML encoding to postal address of member
- Link to discussion URL only if it starts with http(s)://
Other bugfixes:
- Fixed wrong display of 2nd level delegating voters for an initiative
- Do not display invited initiators as initiators while voting
- Added missing translation
New features:
- Public message of the day
- Both direct and indirect supporter count is shown in tab heads
- Support shown in initiative lists
Language chooser at the login page has been added (again)
Important security fixes:
- Added missing HTML encoding to postal address of member
- Link to discussion URL only if it starts with http(s)://
Other bugfixes:
- Fixed wrong display of 2nd level delegating voters for an initiative
- Do not display invited initiators as initiators while voting
- Added missing translation
New features:
- Public message of the day
- Both direct and indirect supporter count is shown in tab heads
- Support shown in initiative lists
Language chooser at the login page has been added (again)
| author | bsw |
|---|---|
| date | Fri Jan 22 12:00:00 2010 +0100 (2010-01-22) |
| parents | 72c5e0ee7c98 |
| children | a3ac899559de |
| rev | line source |
|---|---|
| bsw/jbe@0 | 1 slot.select("title", function() |
| bsw@10 | 2 if app.session.member then |
| bsw@10 | 3 execute.view{ |
| bsw@10 | 4 module = "member_image", |
| bsw@10 | 5 view = "_show", |
| bsw@10 | 6 params = { |
| bsw@10 | 7 member = app.session.member, |
| bsw@10 | 8 image_type = "avatar" |
| bsw@10 | 9 } |
| bsw/jbe@4 | 10 } |
| bsw@10 | 11 end |
| bsw/jbe@0 | 12 end) |
| bsw/jbe@0 | 13 |
| bsw/jbe@0 | 14 slot.select("title", function() |
| bsw/jbe@0 | 15 ui.container{ |
| bsw/jbe@0 | 16 attr = { class = "lang_chooser" }, |
| bsw/jbe@0 | 17 content = function() |
| bsw/jbe@0 | 18 for i, lang in ipairs{"en", "de"} do |
| bsw/jbe@0 | 19 ui.link{ |
| bsw/jbe@0 | 20 content = function() |
| bsw/jbe@0 | 21 ui.image{ |
| bsw/jbe@0 | 22 static = "lang/" .. lang .. ".png", |
| bsw/jbe@0 | 23 attr = { style = "margin-left: 0.5em;", alt = lang } |
| bsw/jbe@0 | 24 } |
| bsw/jbe@0 | 25 end, |
| bsw/jbe@0 | 26 module = "index", |
| bsw/jbe@0 | 27 action = "set_lang", |
| bsw/jbe@0 | 28 params = { lang = lang }, |
| bsw/jbe@0 | 29 routing = { |
| bsw/jbe@0 | 30 default = { |
| bsw/jbe@0 | 31 mode = "redirect", |
| bsw/jbe@0 | 32 module = request.get_module(), |
| bsw/jbe@0 | 33 view = request.get_view(), |
| bsw/jbe@0 | 34 id = param.get_id_cgi(), |
| bsw/jbe@0 | 35 params = param.get_all_cgi() |
| bsw/jbe@0 | 36 } |
| bsw/jbe@0 | 37 } |
| bsw/jbe@0 | 38 } |
| bsw/jbe@0 | 39 end |
| bsw/jbe@0 | 40 end |
| bsw/jbe@0 | 41 } |
| bsw/jbe@0 | 42 end) |
| bsw/jbe@0 | 43 |
| bsw/jbe@0 | 44 slot.put_into("title", encode.html(config.app_title)) |
| bsw/jbe@0 | 45 |
| bsw/jbe@0 | 46 slot.select("actions", function() |
| bsw/jbe@4 | 47 |
| bsw@10 | 48 if app.session.member then |
| bsw@10 | 49 ui.link{ |
| bsw@10 | 50 content = function() |
| bsw@10 | 51 ui.image{ static = "icons/16/application_form.png" } |
| bsw@10 | 52 slot.put(_"Edit my profile") |
| bsw@10 | 53 end, |
| bsw@10 | 54 module = "member", |
| bsw@10 | 55 view = "edit" |
| bsw@10 | 56 } |
| bsw@10 | 57 |
| bsw/jbe@6 | 58 ui.link{ |
| bsw/jbe@6 | 59 content = function() |
| bsw@10 | 60 ui.image{ static = "icons/16/user_gray.png" } |
| bsw@10 | 61 slot.put(_"Upload images") |
| bsw/jbe@6 | 62 end, |
| bsw@10 | 63 module = "member", |
| bsw@10 | 64 view = "edit_images" |
| bsw@10 | 65 } |
| bsw@10 | 66 |
| bsw@10 | 67 execute.view{ |
| bsw@10 | 68 module = "delegation", |
| bsw@10 | 69 view = "_show_box" |
| bsw/jbe@6 | 70 } |
| bsw@10 | 71 |
| bsw@10 | 72 ui.link{ |
| bsw@10 | 73 content = function() |
| bsw@10 | 74 ui.image{ static = "icons/16/wrench.png" } |
| bsw@10 | 75 slot.put(_"Settings") |
| bsw@10 | 76 end, |
| bsw@10 | 77 module = "member", |
| bsw@10 | 78 view = "settings" |
| bsw@10 | 79 } |
| bsw@10 | 80 |
| bsw@10 | 81 if config.download_dir then |
| bsw@10 | 82 ui.link{ |
| bsw@10 | 83 content = function() |
| bsw@10 | 84 ui.image{ static = "icons/16/database_save.png" } |
| bsw@10 | 85 slot.put(_"Download") |
| bsw@10 | 86 end, |
| bsw@10 | 87 module = "index", |
| bsw@10 | 88 view = "download" |
| bsw@10 | 89 } |
| bsw@10 | 90 end |
| bsw@10 | 91 end |
| bsw/jbe@0 | 92 end) |
| bsw/jbe@0 | 93 |
| bsw/jbe@4 | 94 local lang = locale.get("lang") |
| bsw/jbe@4 | 95 local basepath = request.get_app_basepath() |
| bsw/jbe@4 | 96 local file_name = basepath .. "/locale/motd/" .. lang .. ".txt" |
| bsw/jbe@4 | 97 local file = io.open(file_name) |
| bsw/jbe@4 | 98 if file ~= nil then |
| bsw/jbe@4 | 99 local help_text = file:read("*a") |
| bsw/jbe@4 | 100 if #help_text > 0 then |
| bsw/jbe@4 | 101 ui.container{ |
| bsw/jbe@4 | 102 attr = { class = "motd wiki" }, |
| bsw/jbe@4 | 103 content = function() |
| bsw/jbe@4 | 104 slot.put(format.wiki_text(help_text)) |
| bsw/jbe@4 | 105 end |
| bsw/jbe@4 | 106 } |
| bsw/jbe@4 | 107 end |
| bsw/jbe@4 | 108 end |
| bsw/jbe@4 | 109 |
| bsw/jbe@4 | 110 |
| bsw/jbe@4 | 111 util.help("index.index", _"Home") |
| bsw/jbe@4 | 112 |
| bsw/jbe@5 | 113 local areas = {} |
| bsw@10 | 114 if app.session.member then |
| bsw@10 | 115 local selector = Area:new_selector() |
| bsw@10 | 116 :reset_fields() |
| bsw@10 | 117 :add_field("area.id", nil, { "grouped" }) |
| bsw@10 | 118 :add_field("area.name", nil, { "grouped" }) |
| bsw@10 | 119 :add_field("membership.member_id NOTNULL", "is_member", { "grouped" }) |
| bsw@10 | 120 :add_field("count(issue.id)", "issues_to_vote_count") |
| bsw@10 | 121 :add_field("count(interest.member_id)", "interested_issues_to_vote_count") |
| bsw@10 | 122 :join("issue", nil, "issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL") |
| bsw@10 | 123 :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id }) |
| bsw@10 | 124 :add_where{ "direct_voter.member_id ISNULL" } |
| bsw@10 | 125 :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id }) |
| bsw@10 | 126 :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ? ", app.session.member.id }) |
| bsw@10 | 127 |
| bsw@10 | 128 for i, area in ipairs(selector:exec()) do |
| bsw@10 | 129 if area.is_member or area.interested_issues_to_vote_count > 0 then |
| bsw@10 | 130 areas[#areas+1] = area |
| bsw@10 | 131 end |
| bsw/jbe@5 | 132 end |
| bsw/jbe@5 | 133 end |
| bsw/jbe@5 | 134 |
| bsw/jbe@5 | 135 if #areas > 0 then |
| bsw/jbe@5 | 136 ui.container{ |
| bsw/jbe@5 | 137 attr = { style = "font-weight: bold;" }, |
| bsw/jbe@5 | 138 content = _"Current votings in areas you are member of and issues you are interested in:" |
| bsw/jbe@5 | 139 } |
| bsw/jbe@5 | 140 |
| bsw/jbe@5 | 141 ui.list{ |
| bsw/jbe@5 | 142 records = areas, |
| bsw/jbe@5 | 143 columns = { |
| bsw/jbe@5 | 144 { |
| bsw/jbe@5 | 145 name = "name" |
| bsw/jbe@5 | 146 }, |
| bsw/jbe@5 | 147 { |
| bsw/jbe@5 | 148 content = function(record) |
| bsw/jbe@5 | 149 if record.is_member and record.issues_to_vote_count > 0 then |
| bsw/jbe@5 | 150 ui.link{ |
| bsw/jbe@5 | 151 content = function() |
| bsw/jbe@5 | 152 if record.issues_to_vote_count > 1 then |
| bsw/jbe@5 | 153 slot.put(_("#{issues_to_vote_count} issue(s)", { issues_to_vote_count = record.issues_to_vote_count })) |
| bsw/jbe@5 | 154 else |
| bsw/jbe@5 | 155 slot.put(_("One issue")) |
| bsw/jbe@5 | 156 end |
| bsw/jbe@5 | 157 end, |
| bsw/jbe@5 | 158 module = "area", |
| bsw/jbe@5 | 159 view = "show", |
| bsw/jbe@5 | 160 id = record.id, |
| bsw/jbe@5 | 161 params = { |
| bsw/jbe@5 | 162 filter = "frozen", |
| bsw/jbe@5 | 163 filter_voting = "not_voted" |
| bsw/jbe@5 | 164 } |
| bsw/jbe@5 | 165 } |
| bsw/jbe@5 | 166 else |
| bsw/jbe@5 | 167 slot.put(_"Not a member") |
| bsw/jbe@5 | 168 end |
| bsw/jbe@5 | 169 end |
| bsw/jbe@5 | 170 }, |
| bsw/jbe@5 | 171 { |
| bsw/jbe@5 | 172 content = function(record) |
| bsw/jbe@5 | 173 if record.interested_issues_to_vote_count > 0 then |
| bsw/jbe@5 | 174 ui.link{ |
| bsw/jbe@5 | 175 content = function() |
| bsw/jbe@5 | 176 if record.interested_issues_to_vote_count > 1 then |
| bsw/jbe@5 | 177 slot.put(_("#{interested_issues_to_vote_count} issue(s) you are interested in", { interested_issues_to_vote_count = record.interested_issues_to_vote_count })) |
| bsw/jbe@5 | 178 else |
| bsw/jbe@5 | 179 slot.put(_"One issue you are interested in") |
| bsw/jbe@5 | 180 end |
| bsw/jbe@5 | 181 end, |
| bsw/jbe@5 | 182 module = "area", |
| bsw/jbe@5 | 183 view = "show", |
| bsw/jbe@5 | 184 id = record.id, |
| bsw/jbe@5 | 185 params = { |
| bsw/jbe@5 | 186 filter = "frozen", |
| bsw/jbe@5 | 187 filter_interest = "my", |
| bsw/jbe@5 | 188 filter_voting = "not_voted" |
| bsw/jbe@5 | 189 } |
| bsw/jbe@5 | 190 } |
| bsw/jbe@5 | 191 end |
| bsw/jbe@5 | 192 end |
| bsw/jbe@5 | 193 }, |
| bsw/jbe@5 | 194 } |
| bsw/jbe@5 | 195 } |
| bsw/jbe@5 | 196 end |
| bsw/jbe@5 | 197 |
| bsw@10 | 198 local initiatives_selector = Initiative:new_selector() |
| bsw@10 | 199 :join("initiator", nil, { "initiator.initiative_id = initiative.id AND initiator.member_id = ? AND initiator.accepted ISNULL", app.session.member.id }) |
| bsw@10 | 200 |
| bsw@10 | 201 if initiatives_selector:count() > 0 then |
| bsw@10 | 202 ui.container{ |
| bsw@10 | 203 attr = { style = "font-weight: bold;" }, |
| bsw@10 | 204 content = _"Initiatives that invited you to become initiator:" |
| bsw@10 | 205 } |
| bsw/jbe@0 | 206 |
| bsw@10 | 207 execute.view{ |
| bsw@10 | 208 module = "initiative", |
| bsw@10 | 209 view = "_list", |
| bsw@10 | 210 params = { initiatives_selector = initiatives_selector } |
| bsw@10 | 211 } |
| bsw@10 | 212 end |
| bsw@10 | 213 |
| bsw@10 | 214 |
| bsw@10 | 215 if app.session.member then |
| bsw@10 | 216 execute.view{ |
| bsw@10 | 217 module = "member", |
| bsw@10 | 218 view = "_show", |
| bsw@10 | 219 params = { member = app.session.member } |
| bsw@10 | 220 } |
| bsw@10 | 221 end |