From 716745e2dd9b3925b1229433e7072580206f731e Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 8 Jun 2011 17:38:11 -0400 Subject: Stubbed out Blame. Added Github banner to site. Documentation. --- src/com/gitblit/wicket/GitBlitWebApp.java | 4 +- src/com/gitblit/wicket/pages/BlamePage.html | 39 ++++++++++ src/com/gitblit/wicket/pages/BlamePage.java | 97 ++++++++++++++++++++++++ src/com/gitblit/wicket/pages/BlobDiffPage.html | 2 +- src/com/gitblit/wicket/pages/BlobDiffPage.java | 3 +- src/com/gitblit/wicket/pages/BlobPage.html | 2 +- src/com/gitblit/wicket/pages/BlobPage.java | 6 +- src/com/gitblit/wicket/pages/CommitDiffPage.java | 5 +- src/com/gitblit/wicket/pages/CommitPage.java | 22 +++--- src/com/gitblit/wicket/pages/SummaryPage.java | 3 +- src/com/gitblit/wicket/pages/TreePage.java | 5 +- src/com/gitblit/wicket/resources/gitblit.css | 2 +- 12 files changed, 168 insertions(+), 22 deletions(-) create mode 100644 src/com/gitblit/wicket/pages/BlamePage.html create mode 100644 src/com/gitblit/wicket/pages/BlamePage.java (limited to 'src') diff --git a/src/com/gitblit/wicket/GitBlitWebApp.java b/src/com/gitblit/wicket/GitBlitWebApp.java index 61b51e86..daf10845 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/com/gitblit/wicket/GitBlitWebApp.java @@ -26,6 +26,7 @@ import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy; import com.gitblit.GitBlit; import com.gitblit.Keys; +import com.gitblit.wicket.pages.BlamePage; import com.gitblit.wicket.pages.BlobDiffPage; import com.gitblit.wicket.pages.BlobPage; import com.gitblit.wicket.pages.BranchesPage; @@ -37,11 +38,11 @@ import com.gitblit.wicket.pages.LogPage; import com.gitblit.wicket.pages.LoginPage; import com.gitblit.wicket.pages.LogoutPage; import com.gitblit.wicket.pages.MarkdownPage; +import com.gitblit.wicket.pages.MetricsPage; import com.gitblit.wicket.pages.PatchPage; import com.gitblit.wicket.pages.RawPage; import com.gitblit.wicket.pages.RepositoriesPage; import com.gitblit.wicket.pages.SearchPage; -import com.gitblit.wicket.pages.MetricsPage; import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TagPage; import com.gitblit.wicket.pages.TagsPage; @@ -85,6 +86,7 @@ public class GitBlitWebApp extends WebApplication { mount("/history", HistoryPage.class, "r", "h", "f"); mount("/search", SearchPage.class); mount("/metrics", MetricsPage.class, "r"); + mount("/blame", BlamePage.class, "r", "h", "f"); // setup ticket urls mount("/tickets", TicketsPage.class, "r"); diff --git a/src/com/gitblit/wicket/pages/BlamePage.html b/src/com/gitblit/wicket/pages/BlamePage.html new file mode 100644 index 00000000..27ed7345 --- /dev/null +++ b/src/com/gitblit/wicket/pages/BlamePage.html @@ -0,0 +1,39 @@ + + + + + + + + + + +
[commit header]
+ + +
[breadcrumbs]
+ + + + + + + + + + + + + + + +
CommitLineData
+ +
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/BlamePage.java b/src/com/gitblit/wicket/pages/BlamePage.java new file mode 100644 index 00000000..dc6aa1f9 --- /dev/null +++ b/src/com/gitblit/wicket/pages/BlamePage.java @@ -0,0 +1,97 @@ +/* + * Copyright 2011 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.wicket.pages; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; + +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.markup.repeater.data.DataView; +import org.apache.wicket.markup.repeater.data.ListDataProvider; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.revwalk.RevCommit; + +import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.panels.CommitHeaderPanel; +import com.gitblit.wicket.panels.LinkPanel; +import com.gitblit.wicket.panels.PathBreadcrumbsPanel; + +public class BlamePage extends RepositoryPage { + + public BlamePage(PageParameters params) { + super(params); + + final String blobPath = WicketUtils.getPath(params); + + RevCommit commit = getCommit(); + + add(new BookmarkablePageLink("blobLink", BlobPage.class, + WicketUtils.newPathParameter(repositoryName, objectId, + blobPath))); + add(new BookmarkablePageLink("commitLink", CommitPage.class, + WicketUtils.newObjectParameter(repositoryName, objectId))); + add(new BookmarkablePageLink("commitDiffLink", CommitDiffPage.class, + WicketUtils.newObjectParameter(repositoryName, objectId))); + + // blame page links + add(new BookmarkablePageLink("headLink", BlamePage.class, + WicketUtils.newPathParameter(repositoryName, Constants.HEAD, blobPath))); + add(new BookmarkablePageLink("historyLink", HistoryPage.class, + WicketUtils.newPathParameter(repositoryName, objectId, blobPath))); + + add(new CommitHeaderPanel("commitHeader", repositoryName, commit)); + + add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId)); + + List blame = Arrays.asList(new BlameLine("HEAD", "1", "Under Construction")); + ListDataProvider blameDp = new ListDataProvider(blame); + DataView blameView = new DataView("annotation", blameDp) { + private static final long serialVersionUID = 1L; + + public void populateItem(final Item item) { + BlameLine entry = item.getModelObject(); + item.add(new LinkPanel("commit", "list", entry.objectId, CommitPage.class, + newCommitParameter(entry.objectId))); + item.add(new Label("line", entry.line)); + item.add(new Label("data", entry.data)); + } + }; + add(blameView); + } + + @Override + protected String getPageName() { + return getString("gb.blame"); + } + + private class BlameLine implements Serializable { + + private static final long serialVersionUID = 1L; + + final String objectId; + final String line; + final String data; + BlameLine(String objectId, String line, String data) { + this.objectId = objectId; + this.line = line; + this.data = data; + } + } +} diff --git a/src/com/gitblit/wicket/pages/BlobDiffPage.html b/src/com/gitblit/wicket/pages/BlobDiffPage.html index 4818aa8c..c6336429 100644 --- a/src/com/gitblit/wicket/pages/BlobDiffPage.html +++ b/src/com/gitblit/wicket/pages/BlobDiffPage.html @@ -9,7 +9,7 @@ diff --git a/src/com/gitblit/wicket/pages/BlobDiffPage.java b/src/com/gitblit/wicket/pages/BlobDiffPage.java index a8f8b3c1..d86d2e63 100644 --- a/src/com/gitblit/wicket/pages/BlobDiffPage.java +++ b/src/com/gitblit/wicket/pages/BlobDiffPage.java @@ -66,7 +66,8 @@ public class BlobDiffPage extends RepositoryPage { WicketUtils.newObjectParameter(repositoryName, objectId))); // diff page links - add(new Label("blameLink", getString("gb.blame"))); + add(new BookmarkablePageLink("blameLink", BlamePage.class, + WicketUtils.newPathParameter(repositoryName, objectId, blobPath))); add(new BookmarkablePageLink("historyLink", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, blobPath))); diff --git a/src/com/gitblit/wicket/pages/BlobPage.html b/src/com/gitblit/wicket/pages/BlobPage.html index 52374437..3c851419 100644 --- a/src/com/gitblit/wicket/pages/BlobPage.html +++ b/src/com/gitblit/wicket/pages/BlobPage.html @@ -18,7 +18,7 @@ diff --git a/src/com/gitblit/wicket/pages/BlobPage.java b/src/com/gitblit/wicket/pages/BlobPage.java index 3c5c8e04..47c8ca82 100644 --- a/src/com/gitblit/wicket/pages/BlobPage.java +++ b/src/com/gitblit/wicket/pages/BlobPage.java @@ -45,7 +45,8 @@ public class BlobPage extends RepositoryPage { if (StringUtils.isEmpty(blobPath)) { // blob by objectid - add(new Label("blameLink", getString("gb.blame")).setEnabled(false)); + add(new BookmarkablePageLink("blameLink", BlamePage.class, + WicketUtils.newPathParameter(repositoryName, objectId, blobPath)).setEnabled(false)); add(new BookmarkablePageLink("historyLink", HistoryPage.class).setEnabled(false)); add(new BookmarkablePageLink("rawLink", RawPage.class, WicketUtils.newPathParameter(repositoryName, objectId, blobPath))); @@ -74,7 +75,8 @@ public class BlobPage extends RepositoryPage { RevCommit commit = JGitUtils.getCommit(r, objectId); // blob page links - add(new Label("blameLink", getString("gb.blame"))); + add(new BookmarkablePageLink("blameLink", BlamePage.class, + WicketUtils.newPathParameter(repositoryName, objectId, blobPath))); add(new BookmarkablePageLink("historyLink", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, blobPath))); add(new BookmarkablePageLink("rawLink", RawPage.class, diff --git a/src/com/gitblit/wicket/pages/CommitDiffPage.java b/src/com/gitblit/wicket/pages/CommitDiffPage.java index 4815b2c7..3abcf131 100644 --- a/src/com/gitblit/wicket/pages/CommitDiffPage.java +++ b/src/com/gitblit/wicket/pages/CommitDiffPage.java @@ -98,9 +98,10 @@ public class CommitDiffPage extends RepositoryPage { newPathParameter(entry.path))); item.add(new BookmarkablePageLink("view", BlobPage.class, newPathParameter(entry.path))); - item.add(new BookmarkablePageLink("blame", BlobPage.class).setEnabled(false)); + item.add(new BookmarkablePageLink("blame", BlamePage.class, + newPathParameter(entry.path))); item.add(new BookmarkablePageLink("history", HistoryPage.class, - newPathParameter(entry.path)).setEnabled(!entry.changeType.equals(ChangeType.ADD) && !entry.changeType.equals(ChangeType.DELETE))); + newPathParameter(entry.path)).setEnabled(!entry.changeType.equals(ChangeType.ADD))); WicketUtils.setAlternatingBackground(item, counter); counter++; diff --git a/src/com/gitblit/wicket/pages/CommitPage.java b/src/com/gitblit/wicket/pages/CommitPage.java index 7b5fdbe0..d9ff1b78 100644 --- a/src/com/gitblit/wicket/pages/CommitPage.java +++ b/src/com/gitblit/wicket/pages/CommitPage.java @@ -125,15 +125,16 @@ public class CommitPage extends RepositoryPage { public void populateItem(final Item item) { GitNote entry = item.getModelObject(); item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef))); - item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(), SearchType.AUTHOR)); - item.add(WicketUtils.createTimestampLabel("authorDate", - entry.notesRef.getAuthorIdent().getWhen(), getTimeZone())); - item.add(new Label("noteContent", StringUtils.breakLinesForHtml(entry.content)).setEscapeModelStrings(false)); + item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(), + SearchType.AUTHOR)); + item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef + .getAuthorIdent().getWhen(), getTimeZone())); + item.add(new Label("noteContent", StringUtils.breakLinesForHtml(entry.content)) + .setEscapeModelStrings(false)); } }; add(notesView.setVisible(notes.size() > 0)); - - + // changed paths list List paths = JGitUtils.getFilesInCommit(r, c); add(new CommitLegendPanel("commitLegend", paths)); @@ -157,12 +158,15 @@ public class CommitPage extends RepositoryPage { } item.add(new BookmarkablePageLink("diff", BlobDiffPage.class, - newPathParameter(entry.path)).setEnabled(!entry.changeType.equals(ChangeType.ADD) && !entry.changeType.equals(ChangeType.DELETE))); + newPathParameter(entry.path)).setEnabled(!entry.changeType + .equals(ChangeType.ADD) && !entry.changeType.equals(ChangeType.DELETE))); item.add(new BookmarkablePageLink("view", BlobPage.class, newPathParameter(entry.path))); - item.add(new BookmarkablePageLink("blame", BlobPage.class).setEnabled(false)); + item.add(new BookmarkablePageLink("blame", BlamePage.class, + newPathParameter(entry.path))); item.add(new BookmarkablePageLink("history", HistoryPage.class, - newPathParameter(entry.path)).setEnabled(!entry.changeType.equals(ChangeType.ADD))); + newPathParameter(entry.path)).setEnabled(!entry.changeType + .equals(ChangeType.ADD))); WicketUtils.setAlternatingBackground(item, counter); counter++; diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 03b1b1c7..37b0bcff 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -203,11 +203,10 @@ public class SummaryPage extends RepositoryPage { metrics.get(metrics.size() / 2).name, metrics.get(metrics.size() - 1).name }); provider.addAxis(dateAxis); - ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT); + ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT); commitAxis.setLabels(new String[] { "", String.valueOf((int) WicketUtils.maxValue(metrics)) }); provider.addAxis(commitAxis); - provider.setLineStyles(new LineStyle[] { new LineStyle(2, 4, 0), new LineStyle(0, 4, 1) }); provider.addShapeMarker(new ShapeMarker(MarkerType.CIRCLE, Color.BLUE, 1, -1, 5)); diff --git a/src/com/gitblit/wicket/pages/TreePage.java b/src/com/gitblit/wicket/pages/TreePage.java index f7962664..68eecf0f 100644 --- a/src/com/gitblit/wicket/pages/TreePage.java +++ b/src/com/gitblit/wicket/pages/TreePage.java @@ -129,8 +129,9 @@ public class TreePage extends RepositoryPage { entry.path))); links.add(new BookmarkablePageLink("raw", RawPage.class, WicketUtils .newPathParameter(repositoryName, entry.commitId, entry.path))); - links.add(new BookmarkablePageLink("blame", BlobPage.class) - .setEnabled(false)); + links.add(new BookmarkablePageLink("blame", BlamePage.class, + WicketUtils.newPathParameter(repositoryName, entry.commitId, + entry.path))); links.add(new BookmarkablePageLink("history", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path))); diff --git a/src/com/gitblit/wicket/resources/gitblit.css b/src/com/gitblit/wicket/resources/gitblit.css index a0ab10ab..7c896dff 100644 --- a/src/com/gitblit/wicket/resources/gitblit.css +++ b/src/com/gitblit/wicket/resources/gitblit.css @@ -737,7 +737,7 @@ span .tagRef a:hover, span .headRef a:hover, span .localBranch a:hover, span .re } span .otherRef { - background-color: #80ccdd; + background-color: #b0e0f0; border-color: #80aaaa; } -- cgit v1.2.3