1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package com.gitblit.wicket;
import java.util.Date;
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gitblit.utils.Utils;
public abstract class BasePage extends WebPage {
Logger logger = LoggerFactory.getLogger(BasePage.class);
public BasePage() {
super();
}
public BasePage(PageParameters params) {
super(params);
}
protected Label createAuthorLabel(String wicketId, String author) {
Label label = new Label(wicketId, author);
WicketUtils.setHtmlTitle(label, author);
return label;
}
protected Label createDateLabel(String wicketId, Date date) {
Label label = new Label(wicketId, GitBlitWebSession.get().formatDate(date));
WicketUtils.setCssClass(label, Utils.timeAgoCss(date));
WicketUtils.setHtmlTitle(label, Utils.timeAgo(date));
return label;
}
protected Label createShortlogDateLabel(String wicketId, Date date) {
String dateString = GitBlitWebSession.get().formatDate(date);
String title = Utils.timeAgo(date);
if ((System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000l) {
dateString = title;
title = GitBlitWebSession.get().formatDate(date);
}
Label label = new Label(wicketId, dateString);
WicketUtils.setCssClass(label, Utils.timeAgoCss(date));
WicketUtils.setHtmlTitle(label, title);
return label;
}
protected void setAlternatingBackground(Component c, int i) {
String clazz = i % 2 == 0 ? "dark" : "light";
WicketUtils.setCssClass(c, clazz);
}
protected String trimShortLog(String string) {
return trimString(string, 60);
}
protected String trimString(String value, int max) {
if (value.length() <= max) {
return value;
}
return value.substring(0, max - 3) + "...";
}
public void error(String message, Throwable t) {
super.error(message);
logger.error(message, t);
}
}
|