liquid_feedback_frontend
diff app/main/draft/diff.lua @ 1309:32cc544d5a5b
Cumulative patch for upcoming frontend version 4
author | bsw/jbe |
---|---|
date | Sun Jul 15 14:07:29 2018 +0200 (2018-07-15) |
parents | 02772bc49467 |
children | 3ab878ba277e |
line diff
1.1 --- a/app/main/draft/diff.lua Thu Jun 23 03:30:57 2016 +0200 1.2 +++ b/app/main/draft/diff.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -33,41 +33,8 @@ 1.4 end 1.5 1.6 1.7 -execute.view{ module = "issue", view = "_sidebar_state", params = { 1.8 - initiative = initiative 1.9 -} } 1.10 - 1.11 -execute.view { 1.12 - module = "issue", view = "_sidebar_issue", 1.13 - params = { 1.14 - issue = initiative.issue, 1.15 - highlight_initiative_id = initiative.id 1.16 - } 1.17 -} 1.18 - 1.19 -execute.view { 1.20 - module = "issue", view = "_sidebar_whatcanido", 1.21 - params = { initiative = initiative } 1.22 -} 1.23 - 1.24 -execute.view { 1.25 - module = "issue", view = "_sidebar_members", params = { 1.26 - issue = initiative.issue, initiative = initiative 1.27 - } 1.28 -} 1.29 - 1.30 - 1.31 - 1.32 -execute.view { 1.33 - module = "issue", view = "_head", params = { 1.34 - issue = initiative.issue 1.35 - } 1.36 -} 1.37 - 1.38 - 1.39 - 1.40 -local old_draft_content = string.gsub(string.gsub(old_draft.content, "\n", " ###ENTER###\n"), " ", "\n") 1.41 -local new_draft_content = string.gsub(string.gsub(new_draft.content, "\n", " ###ENTER###\n"), " ", "\n") 1.42 +local old_draft_content = string.gsub(string.gsub(util.html_to_text(old_draft.content), "\n", " ###ENTER###\n"), " ", "\n") 1.43 +local new_draft_content = string.gsub(string.gsub(util.html_to_text(new_draft.content), "\n", " ###ENTER###\n"), " ", "\n") 1.44 1.45 local key = multirand.string(24, "0123456789abcdefghijklmnopqrstuvwxyz") 1.46 1.47 @@ -84,7 +51,7 @@ 1.48 new_draft_file:write("\n") 1.49 new_draft_file:close() 1.50 1.51 -local output, err, status = extos.pfilter(nil, "sh", "-c", "diff -U 1000000000 '" .. old_draft_filename .. "' '" .. new_draft_filename .. "' | grep -v ^--- | grep -v ^+++ | grep -v ^@") 1.52 +local output, err, status = extos.pfilter(nil, "sh", "-c", "diff -a -U 1000000000 '" .. old_draft_filename .. "' '" .. new_draft_filename .. "' | grep --binary-files=text -v ^--- | grep --binary-files=text -v ^+++ | grep --binary-files=text -v ^@") 1.53 1.54 os.remove(old_draft_filename) 1.55 os.remove(new_draft_filename) 1.56 @@ -116,93 +83,133 @@ 1.57 if not state_changed then 1.58 slot.put(" ") 1.59 end 1.60 - slot.put(encode.html(line)) 1.61 + --slot.put(encode.html(line)) 1.62 + slot.put(line) 1.63 else 1.64 slot.put("<br />") 1.65 end 1.66 end 1.67 1.68 -ui.section( function() 1.69 - ui.sectionHead( function() 1.70 - ui.link{ 1.71 - module = "initiative", view = "show", id = initiative.id, 1.72 - content = function () 1.73 +execute.view{ module = "issue", view = "_head", params = { issue = initiative.issue } } 1.74 + 1.75 +ui.grid{ content = function() 1.76 + ui.cell_main{ content = function() 1.77 + ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() 1.78 + 1.79 + ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function () 1.80 ui.heading { 1.81 - level = 1, 1.82 - content = initiative.display_name 1.83 - } 1.84 - end 1.85 - } 1.86 - ui.heading{ level = 2, content = _("Comparision of revisions #{id1} and #{id2}", { 1.87 - id1 = old_draft.id, 1.88 - id2 = new_draft.id 1.89 - } ) } 1.90 - end ) 1.91 - 1.92 - if app.session.member_id and not new_draft.initiative.revoked then 1.93 - local supporter = app.session.member:get_reference_selector("supporters") 1.94 - :add_where{ "initiative_id = ?", new_draft.initiative_id } 1.95 - :optional_object_mode() 1.96 - :exec() 1.97 - if supporter and supporter.draft_id ~= new_draft.id then 1.98 - ui.sectionRow("draft_updated_info", function() 1.99 - ui.container{ 1.100 - attr = { class = "info" }, 1.101 - content = _"The draft of this initiative has been updated!" 1.102 + attr = { class = "mdl-card__title-text" }, 1.103 + content = function() 1.104 + ui.link{ 1.105 + module = "initiative", view = "show", id = initiative.id, 1.106 + content = initiative.display_name 1.107 + } 1.108 + end 1.109 } 1.110 - slot.put(" ") 1.111 - ui.link{ 1.112 - text = _"refresh my support", 1.113 - module = "initiative", 1.114 - action = "add_support", 1.115 - id = new_draft.initiative.id, 1.116 - params = { draft_id = new_draft.id }, 1.117 - routing = { 1.118 - default = { 1.119 - mode = "redirect", 1.120 - module = "initiative", 1.121 - view = "show", 1.122 - id = new_draft.initiative.id 1.123 - } 1.124 + ui.container{ content = _("Comparision of revisions #{id1} and #{id2}", { 1.125 + id1 = old_draft.id, 1.126 + id2 = new_draft.id 1.127 + } ) } 1.128 + end } 1.129 + 1.130 + if app.session.member_id and not new_draft.initiative.revoked then 1.131 + local supporter = app.session.member:get_reference_selector("supporters") 1.132 + :add_where{ "initiative_id = ?", new_draft.initiative_id } 1.133 + :optional_object_mode() 1.134 + :exec() 1.135 + if supporter and supporter.draft_id == old_draft.id and new_draft.id == initiative.current_draft.id then 1.136 + ui.container { 1.137 + attr = { class = "mdl-card__content mdl-card--no-bottom-pad mdl-card--notice" }, 1.138 + content = _"The draft of this initiative has been updated!" 1.139 } 1.140 - } 1.141 + ui.container { 1.142 + attr = { class = "mdl-card__actions mdl-card--action-border mdl-card--notice" }, 1.143 + content = function () 1.144 + ui.link{ 1.145 + attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, 1.146 + text = _"refresh my support", 1.147 + module = "initiative", 1.148 + action = "add_support", 1.149 + id = new_draft.initiative.id, 1.150 + params = { draft_id = new_draft.id }, 1.151 + routing = { 1.152 + default = { 1.153 + mode = "redirect", 1.154 + module = "initiative", 1.155 + view = "show", 1.156 + id = new_draft.initiative.id 1.157 + } 1.158 + } 1.159 + } 1.160 1.161 - slot.put(" · ") 1.162 - 1.163 - ui.link{ 1.164 - text = _"remove my support", 1.165 - module = "initiative", 1.166 - action = "remove_support", 1.167 - id = new_draft.initiative.id, 1.168 - routing = { 1.169 - default = { 1.170 - mode = "redirect", 1.171 - module = "initiative", 1.172 - view = "show", 1.173 - id = new_draft.initiative.id 1.174 - } 1.175 + slot.put(" ") 1.176 + 1.177 + ui.link{ 1.178 + attr = { class = "mdl-button mdl-js-button mdl-button--raised" }, 1.179 + text = _"remove my support", 1.180 + module = "initiative", 1.181 + action = "remove_support", 1.182 + id = new_draft.initiative.id, 1.183 + routing = { 1.184 + default = { 1.185 + mode = "redirect", 1.186 + module = "initiative", 1.187 + view = "show", 1.188 + id = new_draft.initiative.id 1.189 + } 1.190 + } 1.191 + } 1.192 + 1.193 + slot.put(" ") 1.194 + 1.195 + ui.link{ 1.196 + attr = { class = "mdl-button mdl-js-button" }, 1.197 + text = _"cancel", 1.198 + module = "initiative", 1.199 + view = "show", 1.200 + id = new_draft.initiative.id, 1.201 + } 1.202 + end 1.203 } 1.204 - } 1.205 - 1.206 - end ) 1.207 - end 1.208 - end 1.209 - 1.210 - ui.sectionRow( function() 1.211 + end 1.212 + end 1.213 1.214 - if not status then 1.215 - ui.field.text{ value = _"The drafts do not differ" } 1.216 - else 1.217 - ui.container{ 1.218 - tag = "div", 1.219 - attr = { class = "diff" }, 1.220 - content = function() 1.221 - output = output:gsub("[^\n\r]+", function(line) 1.222 - process_line(line) 1.223 - end) 1.224 + ui.container { 1.225 + attr = { class = "draft mdl-card__content mdl-card--border" }, 1.226 + content = function () 1.227 + if not status then 1.228 + ui.field.text{ value = _"The drafts do not differ" } 1.229 + else 1.230 + ui.container{ 1.231 + tag = "div", 1.232 + attr = { class = "diff" }, 1.233 + content = function() 1.234 + output = output:gsub("[^\n\r]+", function(line) 1.235 + process_line(line) 1.236 + end) 1.237 + end 1.238 + } 1.239 + end 1.240 end 1.241 } 1.242 - end 1.243 + end } 1.244 + end } 1.245 + ui.cell_sidebar{ content = function() 1.246 + 1.247 + execute.view{ module = "issue", view = "_sidebar", params = { 1.248 + initiative = initiative, 1.249 + issue = initiative.issue 1.250 + } } 1.251 1.252 - end ) 1.253 -end ) 1.254 + execute.view { 1.255 + module = "issue", view = "_sidebar_whatcanido", 1.256 + params = { initiative = initiative } 1.257 + } 1.258 + 1.259 + execute.view { 1.260 + module = "issue", view = "_sidebar_members", params = { 1.261 + issue = initiative.issue, initiative = initiative 1.262 + } 1.263 + } 1.264 + end } 1.265 +end }