index.jsView |
---|
119 | 119 | '<input type="hidden" name="action" value="' + action + '">' + |
120 | 120 | '<input type="hidden" name="id" value="' + |
121 | 121 | escapeHTML(id) + '">' + |
122 | 122 | '<label class="name-toggle" for="' + inputId + '" ' + |
123 | | - 'title="' + title + '"><i>✍</i></label>' + |
124 | | - '<input class="name-btn" type="submit" value="Rename">' + |
| 123 | + 'title="' + title + '"><i>✍</i></label> ' + |
| 124 | + '<input class="btn name-btn" type="submit" value="Rename">' + |
125 | 125 | header : |
126 | 126 | header + '<br clear="all"/>' |
127 | 127 | ) + |
128 | 128 | '</form>' |
334 | 334 | if (err) return cb(null, serveError(err)) |
335 | 335 | cb(null, serveRedirect(req.url)) |
336 | 336 | }) |
337 | 337 | |
| 338 | + case 'comment': |
| 339 | + if (!data.id) |
| 340 | + return cb(null, serveError(new Error('Missing id'), 400)) |
| 341 | + |
| 342 | + var msg = schemas.post(data.text, data.id, data.branch || data.id) |
| 343 | + if (data.open != null) |
| 344 | + Issues.schemas.opens(msg, data.id) |
| 345 | + if (data.close != null) |
| 346 | + Issues.schemas.closes(msg, data.id) |
| 347 | + return ssb.publish(msg, function (err) { |
| 348 | + if (err) return cb(null, serveError(err)) |
| 349 | + cb(null, serveRedirect(req.url)) |
| 350 | + }) |
| 351 | + |
338 | 352 | default: |
339 | 353 | if (path == 'issues,new') { |
340 | 354 | issues.new({ |
341 | 355 | project: repo.id, |
663 | 677 | cb(null, serveTemplate(repo.id)(cat([ |
664 | 678 | pull.once( |
665 | 679 | '<div class="repo-title">' + |
666 | 680 | '<form class="right-bar" action="" method="post">' + |
667 | | - (isPublic |
668 | | - ? '<button disabled="disabled"><i>✌</i> Dig</button> ' |
669 | | - : '<input type="hidden" name="vote" value="' + |
| 681 | + '<button class="btn" ' + |
| 682 | + (isPublic ? 'disabled="disabled"' : ' type="submit"') + '>' + |
| 683 | + '<i>✌</i> ' + (!isPublic && upvoted ? 'Undig' : 'Dig') + |
| 684 | + '</button>' + |
| 685 | + (isPublic ? '<input type="hidden" name="vote" value="' + |
670 | 686 | (upvoted ? '0' : '1') + '">' + |
671 | 687 | '<input type="hidden" name="action" value="vote">' + |
672 | 688 | '<input type="hidden" name="id" value="' + |
673 | | - escapeHTML(repo.id) + '">' + |
674 | | - '<button type="submit"><i>✌</i> ' + |
675 | | - (upvoted ? 'Undig' : 'Dig') + |
676 | | - '</button>') + ' ' + |
| 689 | + escapeHTML(repo.id) + '">' : '') + ' ' + |
677 | 690 | '<strong>' + link(digsPath, votes.upvotes) + '</strong>' + |
678 | 691 | '</form>' + |
679 | 692 | renderNameForm(!isPublic, repo.id, repoName, 'repo-name', null, |
680 | 693 | 'Rename the repo', |
1137 | 1150 | |
1138 | 1151 | |
1139 | 1152 | |
1140 | 1153 | function serveRepoIssue(req, repo, issue, path) { |
| 1154 | + var isAuthor = (myId == issue.author) || (myId == repo.feed) |
1141 | 1155 | return renderRepoPage(repo, null, cat([ |
1142 | 1156 | pull.once( |
1143 | 1157 | renderNameForm(!isPublic, issue.id, issue.title, 'issue-title', null, |
1144 | 1158 | 'Rename the issue', |
1172 | 1186 | new Date(msg.value.timestamp).toLocaleString()) |
1173 | 1187 | var c = msg.value.content |
1174 | 1188 | switch (c.type) { |
1175 | 1189 | case 'post': |
1176 | | - if (c.root == issue.id) |
| 1190 | + if (c.root == issue.id) { |
| 1191 | + var changed = issues.isStatusChanged(msg, issue) |
1177 | 1192 | return '<section class="collapse">' + |
1178 | | - authorLink + ' · ' + |
1179 | | - msgTimeLink + |
| 1193 | + authorLink + |
| 1194 | + (changed == null ? '' : ' ' + ( |
| 1195 | + changed ? 'reopened this issue' : 'closed this issue')) + |
| 1196 | + ' · ' + msgTimeLink + |
1180 | 1197 | marked(c.text) + |
1181 | 1198 | '</section>' |
1182 | | - else |
| 1199 | + } else { |
| 1200 | + var text = c.text || (c.type + ' ' + msg.key) |
1183 | 1201 | return '<section class="collapse mention-preview">' + |
1184 | 1202 | authorLink + ' mentioned this issue in ' + |
1185 | | - link([msg.key], c.text || c.type) + |
| 1203 | + link([msg.key], String(text).substr(0, 140)) + |
1186 | 1204 | '</section>' |
| 1205 | + } |
1187 | 1206 | case 'issue-edit': |
1188 | 1207 | return '<section class="collapse">' + |
1189 | 1208 | (c.title == null ? '' : |
1190 | 1209 | authorLink + ' renamed this issue to <q>' + |
1191 | 1210 | escapeHTML(c.title) + '</q>') + |
| 1211 | + ' · ' + msgTimeLink + |
1192 | 1212 | '</section>' |
1193 | 1213 | default: |
1194 | 1214 | return '<section class="collapse">' + |
1195 | | - authorLink + ' · ' + |
1196 | | - msgTimeLink + |
| 1215 | + authorLink + |
| 1216 | + ' · ' + msgTimeLink + |
1197 | 1217 | json(c) + |
1198 | 1218 | '</section>' |
1199 | 1219 | } |
1200 | 1220 | }) |
1201 | | - ) |
| 1221 | + ), |
| 1222 | + pull.once(isPublic ? '' : '<section><form action="" method="post">' + |
| 1223 | + '<input type="hidden" name="action" value="comment">' + |
| 1224 | + '<input type="hidden" name="id" value="' + issue.id + '">' + |
| 1225 | + '<textarea name="text" class="wide-input" rows="6" cols="69"></textarea>' + |
| 1226 | + (isAuthor ? |
| 1227 | + '<input type="submit" class="btn"' + |
| 1228 | + ' name="' + (issue.open ? 'close' : 'open') + '"' + |
| 1229 | + ' value="' + (issue.open ? 'Close issue' : 'Reopen issue') + '"' + |
| 1230 | + '/>' : '') + |
| 1231 | + '<input type="submit" class="btn open" value="Comment" />' + |
| 1232 | + '</form></section>') |
1202 | 1233 | ])) |
1203 | 1234 | } |
1204 | 1235 | |
1205 | 1236 | } |