From 058ed1b58e54bf813754e72ca8c37296cf5f704d Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Tue, 04 Mar 2014 09:56:23 -0500 Subject: [PATCH] Update contributors list --- src/main/java/com/gitblit/wicket/WicketUtils.java | 74 ++++++++++++++++++------------------ 1 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java index aa86686..bba3f79 100644 --- a/src/main/java/com/gitblit/wicket/WicketUtils.java +++ b/src/main/java/com/gitblit/wicket/WicketUtils.java @@ -21,7 +21,6 @@ import java.util.Collection; import java.util.Date; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.TimeZone; @@ -45,7 +44,6 @@ import com.gitblit.Constants; import com.gitblit.Constants.AccessPermission; import com.gitblit.Constants.FederationPullStatus; -import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.FederationModel; import com.gitblit.models.Metric; @@ -95,22 +93,6 @@ } } - public static void setTicketCssClass(Component container, String state) { - String css = null; - if (state.equals("open")) { - css = "label label-important"; - } else if (state.equals("hold")) { - css = "label label-warning"; - } else if (state.equals("resolved")) { - css = "label label-success"; - } else if (state.equals("invalid")) { - css = "label"; - } - if (css != null) { - setCssClass(container, css); - } - } - public static void setPermissionClass(Component container, AccessPermission permission) { if (permission == null) { setCssClass(container, "badge"); @@ -131,7 +113,7 @@ default: setCssClass(container, "badge"); break; - } + } } public static void setAlternatingBackground(Component c, int i) { @@ -206,11 +188,10 @@ return newImage(wicketId, "file_settings_16x16.png"); } - List<String> mdExtensions = GitBlit.getStrings(Keys.web.markdownExtensions); - for (String ext : mdExtensions) { - if (filename.endsWith('.' + ext.toLowerCase())) { - return newImage(wicketId, "file_world_16x16.png"); - } + MarkupProcessor processor = new MarkupProcessor(GitBlitWebApp.get().settings()); + String ext = StringUtils.getFileExtension(filename).toLowerCase(); + if (processor.getMarkupExtensions().contains(ext)) { + return newImage(wicketId, "file_world_16x16.png"); } return newImage(wicketId, "file_16x16.png"); } @@ -248,17 +229,17 @@ public static Label newIcon(String wicketId, String css) { Label lbl = new Label(wicketId); - setCssClass(lbl, css); + setCssClass(lbl, css); return lbl; } - + public static Label newBlankIcon(String wicketId) { Label lbl = new Label(wicketId); setCssClass(lbl, ""); lbl.setRenderBodyOnly(true); return lbl; } - + public static ContextRelativeResource getResource(String file) { return new ContextRelativeResource(file); } @@ -273,6 +254,7 @@ return new HeaderContributor(new IHeaderContributor() { private static final long serialVersionUID = 1L; + @Override public void renderHead(IHeaderResponse response) { String contentType = "application/rss+xml"; @@ -453,6 +435,16 @@ return new PageParameters(parameterMap); } + public static PageParameters newBlameTypeParameter(String repositoryName, + String commitId, String path, String blameType) { + Map<String, String> parameterMap = new HashMap<String, String>(); + parameterMap.put("r", repositoryName); + parameterMap.put("h", commitId); + parameterMap.put("f", path); + parameterMap.put("blametype", blameType); + return new PageParameters(parameterMap); + } + public static String getProjectName(PageParameters params) { return params.getString("p", ""); } @@ -523,10 +515,14 @@ } public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) { - String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy"); + return createDateLabel(wicketId, date, timeZone, timeUtils, true); + } + + public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils, boolean setCss) { + String format = GitBlitWebApp.get().settings().getString(Keys.web.datestampShortFormat, "MM/dd/yy"); DateFormat df = new SimpleDateFormat(format); if (timeZone == null) { - timeZone = GitBlit.getTimezone(); + timeZone = GitBlitWebApp.get().getTimezone(); } df.setTimeZone(timeZone); String dateString; @@ -540,13 +536,15 @@ // past title = timeUtils.timeAgo(date); } - if ((System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000L) { + if (title != null && (System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000L) { String tmp = dateString; dateString = title; title = tmp; } Label label = new Label(wicketId, dateString); - WicketUtils.setCssClass(label, timeUtils.timeAgoCss(date)); + if (setCss) { + WicketUtils.setCssClass(label, timeUtils.timeAgoCss(date)); + } if (!StringUtils.isEmpty(title)) { WicketUtils.setHtmlTooltip(label, title); } @@ -554,10 +552,10 @@ } public static Label createTimeLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) { - String format = GitBlit.getString(Keys.web.timeFormat, "HH:mm"); + String format = GitBlitWebApp.get().settings().getString(Keys.web.timeFormat, "HH:mm"); DateFormat df = new SimpleDateFormat(format); if (timeZone == null) { - timeZone = GitBlit.getTimezone(); + timeZone = GitBlitWebApp.get().getTimezone(); } df.setTimeZone(timeZone); String timeString; @@ -575,10 +573,10 @@ } public static Label createDatestampLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) { - String format = GitBlit.getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy"); + String format = GitBlitWebApp.get().settings().getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy"); DateFormat df = new SimpleDateFormat(format); if (timeZone == null) { - timeZone = GitBlit.getTimezone(); + timeZone = GitBlitWebApp.get().getTimezone(); } df.setTimeZone(timeZone); String dateString; @@ -609,11 +607,11 @@ } public static Label createTimestampLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) { - String format = GitBlit.getString(Keys.web.datetimestampLongFormat, + String format = GitBlitWebApp.get().settings().getString(Keys.web.datetimestampLongFormat, "EEEE, MMMM d, yyyy HH:mm Z"); DateFormat df = new SimpleDateFormat(format); if (timeZone == null) { - timeZone = GitBlit.getTimezone(); + timeZone = GitBlitWebApp.get().getTimezone(); } df.setTimeZone(timeZone); String dateString; @@ -652,6 +650,7 @@ IChartData data = new AbstractChartData(max) { private static final long serialVersionUID = 1L; + @Override public double[][] getData() { return new double[][] { commits, tags }; } @@ -687,6 +686,7 @@ IChartData data = new AbstractChartData(max) { private static final long serialVersionUID = 1L; + @Override public double[][] getData() { return new double[][] { x, y }; } -- Gitblit v1.9.1