diff options
author | James Moger <james.moger@gitblit.com> | 2014-09-17 12:20:22 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-09-17 12:20:22 -0400 |
commit | 5d5e557f029aa9efe8e81cbc43e9e969fa750b80 (patch) | |
tree | 4a998b32429fb7191508ffec3c48a9e8aabd3f3b /src/main/java | |
parent | 113172aa6a857c8e42d6e88057379fcba4881fb8 (diff) | |
download | gitblit-5d5e557f029aa9efe8e81cbc43e9e969fa750b80.tar.gz gitblit-5d5e557f029aa9efe8e81cbc43e9e969fa750b80.zip |
Explicitly declare RepositoryPage subclasses that reference commits
Diffstat (limited to 'src/main/java')
15 files changed, 91 insertions, 17 deletions
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java index 0c978618..d19630c2 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java @@ -175,9 +175,9 @@ public class GitBlitWebApp extends WebApplication implements GitblitWicketApp { // setup the standard gitweb-ish urls mount("/repositories", RepositoriesPage.class); - mount("/overview", OverviewPage.class, "r", "h"); + mount("/overview", OverviewPage.class, "r"); mount("/summary", SummaryPage.class, "r"); - mount("/reflog", ReflogPage.class, "r", "h"); + mount("/reflog", ReflogPage.class, "r"); mount("/commits", LogPage.class, "r", "h"); mount("/log", LogPage.class, "r", "h"); mount("/tags", TagsPage.class, "r"); diff --git a/src/main/java/com/gitblit/wicket/pages/BlamePage.java b/src/main/java/com/gitblit/wicket/pages/BlamePage.java index c2280a2e..3c850f29 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlamePage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlamePage.java @@ -235,6 +235,11 @@ public class BlamePage extends RepositoryPage { }
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java b/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java index 27678ecd..9cc3eae1 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java @@ -82,6 +82,11 @@ public class BlobDiffPage extends RepositoryPage { }
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/BlobPage.java b/src/main/java/com/gitblit/wicket/pages/BlobPage.java index e84056b3..3c244f9a 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlobPage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlobPage.java @@ -224,6 +224,11 @@ public class BlobPage extends RepositoryPage { }
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java index 71a5ea67..d827c449 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java @@ -197,6 +197,11 @@ public class CommitDiffPage extends RepositoryPage { } @Override + protected boolean isCommitPage() { + return true; + } + + @Override protected Class<? extends BasePage> getRepoNavPageClass() { return LogPage.class; } diff --git a/src/main/java/com/gitblit/wicket/pages/CommitPage.java b/src/main/java/com/gitblit/wicket/pages/CommitPage.java index 6fadec5b..072bb200 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitPage.java @@ -248,6 +248,11 @@ public class CommitPage extends RepositoryPage { }
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return LogPage.class;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/DocPage.java b/src/main/java/com/gitblit/wicket/pages/DocPage.java index 567c6fbd..5ed9c400 100644 --- a/src/main/java/com/gitblit/wicket/pages/DocPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DocPage.java @@ -102,6 +102,11 @@ public class DocPage extends RepositoryPage { }
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return DocsPage.class;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/DocsPage.java b/src/main/java/com/gitblit/wicket/pages/DocsPage.java index 97b16049..8be9a573 100644 --- a/src/main/java/com/gitblit/wicket/pages/DocsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DocsPage.java @@ -167,4 +167,10 @@ public class DocsPage extends RepositoryPage { protected String getPageName() {
return getString("gb.docs");
}
+
+ @Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
}
diff --git a/src/main/java/com/gitblit/wicket/pages/HistoryPage.java b/src/main/java/com/gitblit/wicket/pages/HistoryPage.java index f7f188df..3021cb3c 100644 --- a/src/main/java/com/gitblit/wicket/pages/HistoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/HistoryPage.java @@ -67,6 +67,11 @@ public class HistoryPage extends RepositoryPage { }
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/LogPage.java b/src/main/java/com/gitblit/wicket/pages/LogPage.java index 092f719a..411d7edd 100644 --- a/src/main/java/com/gitblit/wicket/pages/LogPage.java +++ b/src/main/java/com/gitblit/wicket/pages/LogPage.java @@ -69,4 +69,10 @@ public class LogPage extends RepositoryPage { protected String getPageName() {
return getString("gb.log");
}
+
+ @Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
}
diff --git a/src/main/java/com/gitblit/wicket/pages/MetricsPage.java b/src/main/java/com/gitblit/wicket/pages/MetricsPage.java index 7ae4e4ed..96113b0f 100644 --- a/src/main/java/com/gitblit/wicket/pages/MetricsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/MetricsPage.java @@ -61,24 +61,24 @@ public class MetricsPage extends RepositoryPage { MessageFormat.format(getString("gb.branchStats"), metricsTotal.count,
metricsTotal.tag, getTimeUtils().duration(metricsTotal.duration))));
}
-
+
Charts charts = new Flotr2Charts();
-
+
add(WicketUtils.newBlankImage("commitsChart"));
add(WicketUtils.newBlankImage("dayOfWeekChart"));
add(WicketUtils.newBlankImage("authorsChart"));
-
+
createLineChart(charts, "commitsChart", metrics);
createBarChart(charts, "dayOfWeekChart", getDayOfWeekMetrics(r, objectId));
createPieChart(charts, "authorsChart", getAuthorMetrics(r, objectId));
-
+
add(new HeaderContributor(charts));
}
private void createLineChart(Charts charts, String id, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
-
+
Chart chart = charts.createLineChart(id, "", "day",
getString("gb.commits"));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
@@ -102,22 +102,22 @@ public class MetricsPage extends RepositoryPage { chart.addHighlight(date, (int)metric.count);
}
}
- charts.addChart(chart);
+ charts.addChart(chart);
}
}
-
+
private void createPieChart(Charts charts, String id, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
-
+
Chart chart = charts.createPieChart(id, "", "day",
getString("gb.commits"));
for (Metric metric : metrics) {
chart.addValue(metric.name, (int)metric.count);
}
- charts.addChart(chart);
+ charts.addChart(chart);
}
}
-
+
private void createBarChart(Charts charts, String id, List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)) {
Chart chart = charts.createBarChart(id, "", "day",
@@ -125,7 +125,7 @@ public class MetricsPage extends RepositoryPage { for (Metric metric : metrics) {
chart.addValue(metric.name, (int)metric.count);
}
- charts.addChart(chart);
+ charts.addChart(chart);
}
}
@@ -179,6 +179,11 @@ public class MetricsPage extends RepositoryPage { }
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return SummaryPage.class;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/NoDocsPage.java b/src/main/java/com/gitblit/wicket/pages/NoDocsPage.java index 868e5d02..7dcc0227 100644 --- a/src/main/java/com/gitblit/wicket/pages/NoDocsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/NoDocsPage.java @@ -33,6 +33,11 @@ public class NoDocsPage extends RepositoryPage { } @Override + protected boolean isCommitPage() { + return true; + } + + @Override protected Class<? extends BasePage> getRepoNavPageClass() { return DocsPage.class; } diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index b3250a6b..134ee044 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -201,11 +201,13 @@ public abstract class RepositoryPage extends RootPage { objectParams = params;
// preserve the objectid iff the objectid directly (or indirectly) refers to a ref
- if (!StringUtils.isEmpty(objectId)) {
+ if (isCommitPage() && !StringUtils.isEmpty(objectId)) {
RevCommit commit = JGitUtils.getCommit(r, objectId);
- String bestId = getBestCommitId(commit);
- if (!commit.getName().equals(bestId)) {
- objectParams = WicketUtils.newObjectParameter(getRepositoryName(), bestId);
+ if (commit != null) {
+ String bestId = getBestCommitId(commit);
+ if (!commit.getName().equals(bestId)) {
+ objectParams = WicketUtils.newObjectParameter(getRepositoryName(), bestId);
+ }
}
}
}
@@ -574,6 +576,10 @@ public abstract class RepositoryPage extends RootPage { protected abstract String getPageName();
+ protected boolean isCommitPage() {
+ return false;
+ }
+
protected Component createPersonPanel(String wicketId, PersonIdent identity,
Constants.SearchType searchType) {
String name = identity == null ? "" : identity.getName();
diff --git a/src/main/java/com/gitblit/wicket/pages/TagPage.java b/src/main/java/com/gitblit/wicket/pages/TagPage.java index afade81c..9eed2797 100644 --- a/src/main/java/com/gitblit/wicket/pages/TagPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TagPage.java @@ -101,6 +101,11 @@ public class TagPage extends RepositoryPage { }
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return LogPage.class;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/TreePage.java b/src/main/java/com/gitblit/wicket/pages/TreePage.java index 722b824f..9ddbecf6 100644 --- a/src/main/java/com/gitblit/wicket/pages/TreePage.java +++ b/src/main/java/com/gitblit/wicket/pages/TreePage.java @@ -186,4 +186,10 @@ public class TreePage extends RepositoryPage { protected String getPageName() {
return getString("gb.tree");
}
+
+ @Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
}
|