commit | author | age
|
232890
|
1 |
package com.gitblit.wicket.pages;
|
JM |
2 |
|
|
3 |
import org.apache.wicket.PageParameters;
|
|
4 |
import org.apache.wicket.markup.html.basic.Label;
|
|
5 |
import org.apache.wicket.markup.repeater.Item;
|
|
6 |
import org.apache.wicket.markup.repeater.data.DataView;
|
|
7 |
import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
|
8 |
import org.eclipse.jgit.lib.Repository;
|
|
9 |
|
|
10 |
import com.gitblit.utils.JGitUtils;
|
87cc1e
|
11 |
import com.gitblit.utils.StringUtils;
|
232890
|
12 |
import com.gitblit.wicket.GitBlitWebSession;
|
JM |
13 |
import com.gitblit.wicket.RepositoryPage;
|
|
14 |
import com.gitblit.wicket.WicketUtils;
|
9802a7
|
15 |
import com.gitblit.wicket.models.TicketModel;
|
JM |
16 |
import com.gitblit.wicket.models.TicketModel.Comment;
|
232890
|
17 |
|
9802a7
|
18 |
public class TicketPage extends RepositoryPage {
|
232890
|
19 |
|
9802a7
|
20 |
public TicketPage(PageParameters params) {
|
cebf45
|
21 |
super(params);
|
232890
|
22 |
|
7d35e2
|
23 |
final String ticketFolder = WicketUtils.getPath(params);
|
232890
|
24 |
|
JM |
25 |
Repository r = getRepository();
|
9802a7
|
26 |
TicketModel t = JGitUtils.getTicket(r, ticketFolder);
|
232890
|
27 |
|
JM |
28 |
add(new Label("ticketTitle", t.title));
|
|
29 |
add(new Label("ticketId", t.id));
|
61b094
|
30 |
add(new Label("ticketHandler", t.handler.toLowerCase()));
|
JM |
31 |
add(WicketUtils.createTimestampLabel("ticketOpenDate", t.date, getTimeZone()));
|
7ba0ec
|
32 |
Label stateLabel = new Label("ticketState", t.state);
|
1e47ab
|
33 |
WicketUtils.setTicketCssClass(stateLabel, t.state);
|
7ba0ec
|
34 |
add(stateLabel);
|
87cc1e
|
35 |
add(new Label("ticketTags", StringUtils.flattenStrings(t.tags)));
|
232890
|
36 |
|
JM |
37 |
ListDataProvider<Comment> commentsDp = new ListDataProvider<Comment>(t.comments);
|
|
38 |
DataView<Comment> commentsView = new DataView<Comment>("comment", commentsDp) {
|
|
39 |
private static final long serialVersionUID = 1L;
|
|
40 |
int counter = 0;
|
|
41 |
|
|
42 |
public void populateItem(final Item<Comment> item) {
|
|
43 |
final Comment entry = item.getModelObject();
|
698678
|
44 |
item.add(WicketUtils.createDateLabel("commentDate", entry.date, GitBlitWebSession.get().getTimezone()));
|
61b094
|
45 |
item.add(new Label("commentAuthor", entry.author.toLowerCase()));
|
232890
|
46 |
item.add(new Label("commentText", prepareComment(entry.text)).setEscapeModelStrings(false));
|
698678
|
47 |
WicketUtils.setAlternatingBackground(item, counter);
|
232890
|
48 |
counter++;
|
JM |
49 |
}
|
|
50 |
};
|
|
51 |
add(commentsView);
|
|
52 |
}
|
155bf7
|
53 |
|
cebf45
|
54 |
@Override
|
JM |
55 |
protected String getPageName() {
|
1e47ab
|
56 |
return getString("gb.ticket");
|
cebf45
|
57 |
}
|
232890
|
58 |
|
JM |
59 |
private String prepareComment(String comment) {
|
87cc1e
|
60 |
String html = StringUtils.escapeForHtml(comment, false);
|
JM |
61 |
html = StringUtils.breakLinesForHtml(comment).trim();
|
232890
|
62 |
return html.replaceAll("\\bcommit\\s*([A-Za-z0-9]*)\\b", "<a href=\"/commit/" + repositoryName + "/$1\">commit $1</a>");
|
JM |
63 |
}
|
|
64 |
}
|