From ef5c58d12ff33e4f2b83b6dcd53bdb6c96a6150d Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 11 Apr 2011 08:18:22 -0400 Subject: [PATCH] Page log. --- src/com/gitblit/utils/JGitUtils.java | 44 ++++++++++++++---- src/com/gitblit/wicket/GitBlitWebApp.java | 18 ++++---- .../gitblit/wicket/GitBlitWebApp.properties | 5 +- src/com/gitblit/wicket/RepositoryPage.java | 14 +++--- src/com/gitblit/wicket/WicketUtils.java | 21 ++++++--- src/com/gitblit/wicket/pages/BlobPage.java | 4 +- src/com/gitblit/wicket/pages/DiffPage.java | 4 +- src/com/gitblit/wicket/pages/LogPage.html | 10 ++++ src/com/gitblit/wicket/pages/LogPage.java | 19 ++++++-- .../wicket/pages/RepositoriesPage.java | 5 +- src/com/gitblit/wicket/pages/SummaryPage.java | 27 ++++++----- src/com/gitblit/wicket/pages/TagPage.java | 2 +- src/com/gitblit/wicket/pages/TreePage.java | 6 +-- .../gitblit/wicket/panels/BranchesPanel.java | 6 +-- src/com/gitblit/wicket/panels/LogPanel.java | 46 +++++++++++-------- src/com/gitblit/wicket/panels/TagsPanel.java | 12 ++--- 16 files changed, 155 insertions(+), 88 deletions(-) diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 1b418b08..abecac41 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -16,7 +16,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.eclipse.jgit.api.Git; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.DiffFormatter; import org.eclipse.jgit.diff.RawTextComparator; @@ -286,7 +285,7 @@ public class JGitUtils { public static String getCommitDiff(Repository r, RevCommit commit, boolean outputHtml) { return getCommitDiff(r, commit, null, outputHtml); } - + public static String getCommitDiff(Repository r, RevCommit commit, String path, boolean outputHtml) { try { final RevWalk rw = new RevWalk(r); @@ -380,16 +379,39 @@ public class JGitUtils { } public static List getRevLog(Repository r, int maxCount) { + return getRevLog(r, Constants.HEAD, 0, maxCount); + } + + public static List getRevLog(Repository r, String objectId, int offset, int maxCount) { List list = new ArrayList(); try { - Git git = new Git(r); - Iterable revlog = git.log().call(); - for (RevCommit rev : revlog) { - list.add(rev); - if (maxCount > 0 && list.size() == maxCount) { - break; + if (objectId == null || objectId.trim().length() == 0) { + objectId = Constants.HEAD; + } + RevWalk walk = new RevWalk(r); + ObjectId object = r.resolve(objectId); + walk.markStart(walk.parseCommit(object)); + Iterable revlog = walk; + if (offset > 0) { + int count = 0; + for (RevCommit rev : revlog) { + count++; + if (count > offset) { + list.add(rev); + if (maxCount > 0 && list.size() == maxCount) { + break; + } + } + } + } else { + for (RevCommit rev : revlog) { + list.add(rev); + if (maxCount > 0 && list.size() == maxCount) { + break; + } } } + walk.dispose(); } catch (Throwable t) { LOGGER.error("Failed to determine last change", t); } @@ -504,8 +526,10 @@ public class JGitUtils { final Map map = new HashMap(); try { DateFormat df = new SimpleDateFormat("yyyy-MM"); - Git git = new Git(r); - Iterable revlog = git.log().call(); + RevWalk walk = new RevWalk(r); + ObjectId object = r.resolve(Constants.HEAD); + walk.markStart(walk.parseCommit(object)); + Iterable revlog = walk; for (RevCommit rev : revlog) { Date d = getCommitDate(rev); String p = df.format(d); diff --git a/src/com/gitblit/wicket/GitBlitWebApp.java b/src/com/gitblit/wicket/GitBlitWebApp.java index caaf221f..90a03715 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/com/gitblit/wicket/GitBlitWebApp.java @@ -62,15 +62,15 @@ public class GitBlitWebApp extends WebApplication { getRequestCycleSettings().setGatherExtendedBrowserInfo(true); // setup the standard gitweb-ish urls - mount(new MixedParamUrlCodingStrategy("/summary", SummaryPage.class, new String[] { "p" })); - mount(new MixedParamUrlCodingStrategy("/shortlog", LogPage.class, new String[] { "p", "h" })); - mount(new MixedParamUrlCodingStrategy("/tags", TagsPage.class, new String[] { "p" })); - mount(new MixedParamUrlCodingStrategy("/branches", BranchesPage.class, new String[] { "p" })); - mount(new MixedParamUrlCodingStrategy("/commit", CommitPage.class, new String[] { "p", "h" })); - mount(new MixedParamUrlCodingStrategy("/tag", TagPage.class, new String[] { "p", "h" })); - mount(new MixedParamUrlCodingStrategy("/tree", TreePage.class, new String[] { "p", "h", "f" })); - mount(new MixedParamUrlCodingStrategy("/blob", BlobPage.class, new String[] { "p", "h", "f" })); - mount(new MixedParamUrlCodingStrategy("/diff", DiffPage.class, new String[] { "p", "h", "f" })); + mount(new MixedParamUrlCodingStrategy("/summary", SummaryPage.class, new String[] { "r" })); + mount(new MixedParamUrlCodingStrategy("/log", LogPage.class, new String[] { "r", "h" })); + mount(new MixedParamUrlCodingStrategy("/tags", TagsPage.class, new String[] { "r" })); + mount(new MixedParamUrlCodingStrategy("/branches", BranchesPage.class, new String[] { "r" })); + mount(new MixedParamUrlCodingStrategy("/commit", CommitPage.class, new String[] { "r", "h" })); + mount(new MixedParamUrlCodingStrategy("/tag", TagPage.class, new String[] { "r", "h" })); + mount(new MixedParamUrlCodingStrategy("/tree", TreePage.class, new String[] { "r", "h", "f" })); + mount(new MixedParamUrlCodingStrategy("/blob", BlobPage.class, new String[] { "r", "h", "f" })); + mount(new MixedParamUrlCodingStrategy("/diff", DiffPage.class, new String[] { "r", "h", "f" })); // setup extended urls mount(new MixedParamUrlCodingStrategy("/ticgit", TicGitPage.class, new String[] { "p" })); diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 621cb718..a16ea74c 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -34,4 +34,7 @@ gb.ticket = ticket gb.newRepository = new repository gb.newUser = new user gb.commitdiff = commitdiff -gb.ticgit = ticgit \ No newline at end of file +gb.ticgit = ticgit +gb.pageFirst = first +gb.pagePrevious prev +gb.pageNext = next \ No newline at end of file diff --git a/src/com/gitblit/wicket/RepositoryPage.java b/src/com/gitblit/wicket/RepositoryPage.java index 0cbda3dd..4e849383 100644 --- a/src/com/gitblit/wicket/RepositoryPage.java +++ b/src/com/gitblit/wicket/RepositoryPage.java @@ -21,19 +21,19 @@ import com.gitblit.wicket.panels.RefsPanel; public abstract class RepositoryPage extends BasePage { protected final String repositoryName; - protected final String commitId; + protected final String objectId; protected String description; private transient Repository r = null; public RepositoryPage(PageParameters params) { super(params); - if (!params.containsKey("p")) { + if (!params.containsKey("r")) { error("Repository not specified!"); redirectToInterceptPage(new RepositoriesPage()); } - repositoryName = params.getString("p", ""); - commitId = params.getString("h", "HEAD"); + repositoryName = params.getString("r", ""); + objectId = params.getString("h", "HEAD"); Repository r = getRepository(); @@ -116,14 +116,14 @@ public abstract class RepositoryPage extends BasePage { } protected PageParameters newCommitParameter() { - return WicketUtils.newCommitParameter(repositoryName, commitId); + return WicketUtils.newObjectParameter(repositoryName, objectId); } protected PageParameters newCommitParameter(String commitId) { - return WicketUtils.newCommitParameter(repositoryName, commitId); + return WicketUtils.newObjectParameter(repositoryName, commitId); } protected PageParameters newPathParameter(String path) { - return WicketUtils.newPathParameter(repositoryName, commitId, path); + return WicketUtils.newPathParameter(repositoryName, objectId, path); } } diff --git a/src/com/gitblit/wicket/WicketUtils.java b/src/com/gitblit/wicket/WicketUtils.java index 63efd548..bc1f441e 100644 --- a/src/com/gitblit/wicket/WicketUtils.java +++ b/src/com/gitblit/wicket/WicketUtils.java @@ -79,21 +79,28 @@ public class WicketUtils { } public static PageParameters newRepositoryParameter(String repositoryName) { - return new PageParameters("p=" + repositoryName); + return new PageParameters("r=" + repositoryName); } - public static PageParameters newCommitParameter(String repositoryName, String commitId) { - if (commitId == null || commitId.trim().length() == 0) { + public static PageParameters newObjectParameter(String repositoryName, String objectId) { + if (objectId == null || objectId.trim().length() == 0) { return newRepositoryParameter(repositoryName); } - return new PageParameters("p=" + repositoryName + ",h=" + commitId); + return new PageParameters("r=" + repositoryName + ",h=" + objectId); } - public static PageParameters newPathParameter(String repositoryName, String commitId, String path) { + public static PageParameters newPathParameter(String repositoryName, String objectId, String path) { if (path == null || path.trim().length() == 0) { - return newCommitParameter(repositoryName, commitId); + return newObjectParameter(repositoryName, objectId); } - return new PageParameters("p=" + repositoryName + ",h=" + commitId + ",f=" + path); + return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",f=" + path); + } + + public static PageParameters newLogPageParameter(String repositoryName, String objectId, int pageNumber) { + if (pageNumber <= 1) { + return newObjectParameter(repositoryName, objectId); + } + return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",page=" + pageNumber); } public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone) { diff --git a/src/com/gitblit/wicket/pages/BlobPage.java b/src/com/gitblit/wicket/pages/BlobPage.java index 3ba2f840..78429362 100644 --- a/src/com/gitblit/wicket/pages/BlobPage.java +++ b/src/com/gitblit/wicket/pages/BlobPage.java @@ -25,7 +25,7 @@ public class BlobPage extends RepositoryPage { final String blobPath = params.getString("f", null); Repository r = getRepository(); - RevCommit commit = JGitUtils.getCommit(r, commitId); + RevCommit commit = JGitUtils.getCommit(r, objectId); // blob page links add(new Label("historyLink", getString("gb.history"))); @@ -34,7 +34,7 @@ public class BlobPage extends RepositoryPage { add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter())); - add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, commitId)); + add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId)); String extension = null; if (blobPath.lastIndexOf('.') > -1) { extension = blobPath.substring(blobPath.lastIndexOf('.') + 1); diff --git a/src/com/gitblit/wicket/pages/DiffPage.java b/src/com/gitblit/wicket/pages/DiffPage.java index 70c5c552..1e6065b3 100644 --- a/src/com/gitblit/wicket/pages/DiffPage.java +++ b/src/com/gitblit/wicket/pages/DiffPage.java @@ -18,7 +18,7 @@ public class DiffPage extends RepositoryPage { final String blobPath = params.getString("f", null); Repository r = getRepository(); - RevCommit commit = JGitUtils.getCommit(r, commitId); + RevCommit commit = JGitUtils.getCommit(r, objectId); String diff; if (blobPath != null && blobPath.length() > 0) { // blob diff @@ -35,7 +35,7 @@ public class DiffPage extends RepositoryPage { add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter())); - add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, commitId)); + add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId)); add(new Label("diffText", diff).setEscapeModelStrings(false)); } diff --git a/src/com/gitblit/wicket/pages/LogPage.html b/src/com/gitblit/wicket/pages/LogPage.html index 82abb1b1..325e751b 100644 --- a/src/com/gitblit/wicket/pages/LogPage.html +++ b/src/com/gitblit/wicket/pages/LogPage.html @@ -10,8 +10,18 @@
[page links]
+ +
+ | | +
+
[log panel]
+ + +
+ | | +
diff --git a/src/com/gitblit/wicket/pages/LogPage.java b/src/com/gitblit/wicket/pages/LogPage.java index 56ab07a8..f9449ad9 100644 --- a/src/com/gitblit/wicket/pages/LogPage.java +++ b/src/com/gitblit/wicket/pages/LogPage.java @@ -1,19 +1,32 @@ package com.gitblit.wicket.pages; import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.link.BookmarkablePageLink; import com.gitblit.wicket.RepositoryPage; +import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.LogPanel; - public class LogPage extends RepositoryPage { public LogPage(PageParameters params) { super(params); - add(new LogPanel("logPanel", repositoryName, getRepository(), 100, true)); + int pageNumber = params.getInt("page", 1); // index from 1 + int prevPage = Math.max(0, pageNumber - 1); + int nextPage = pageNumber + 1; + + add(new BookmarkablePageLink("firstPageTop", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId))); + add(new BookmarkablePageLink("prevPageTop", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, prevPage)).setEnabled(pageNumber > 1)); + add(new BookmarkablePageLink("nextPageTop", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage))); + + add(new LogPanel("logPanel", repositoryName, objectId, getRepository(), -1, pageNumber - 1)); + + add(new BookmarkablePageLink("firstPageBottom", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId))); + add(new BookmarkablePageLink("prevPageBottom", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, prevPage)).setEnabled(pageNumber > 1)); + add(new BookmarkablePageLink("nextPageBottom", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage))); } - + @Override protected String getPageName() { return getString("gb.log"); diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java index d1b9694e..83d67520 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.java +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java @@ -43,7 +43,7 @@ public class RepositoriesPage extends BasePage { public void populateItem(final Item item) { final RepositoryModel entry = item.getModelObject(); - PageParameters pp = new PageParameters("p=" + entry.name); + PageParameters pp = WicketUtils.newRepositoryParameter(entry.name); item.add(new LinkPanel("repositoryName", "list", entry.name, SummaryPage.class, pp)); item.add(new LinkPanel("repositoryDescription", "list", entry.description, SummaryPage.class, pp)); item.add(new Label("repositoryOwner", entry.owner)); @@ -53,8 +53,7 @@ public class RepositoriesPage extends BasePage { item.add(lastChangeLabel); WicketUtils.setCssClass(lastChangeLabel, Utils.timeAgoCss(entry.lastChange)); - String clazz = counter % 2 == 0 ? "dark" : "light"; - WicketUtils.setCssClass(item, clazz); + WicketUtils.setAlternatingBackground(item, counter); counter++; } }; diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 72643a76..273de57f 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -44,6 +44,12 @@ public class SummaryPage extends RepositoryPage { } Repository r = getRepository(); + List metrics = JGitUtils.getDateMetrics(r); + + long numberOfCommits = 0; + for (Metric m : metrics) { + numberOfCommits += m.count; + } String owner = JGitUtils.getRepositoryOwner(r); GitBlitWebSession session = GitBlitWebSession.get(); @@ -56,12 +62,12 @@ public class SummaryPage extends RepositoryPage { add(new Label("repositoryLastChange", lastchange)); add(new Label("repositoryCloneUrl", cloneurl)); - add(new LogPanel("commitsPanel", repositoryName, r, numberCommits, false)); + add(new LogPanel("commitsPanel", repositoryName, null, r, numberCommits, 0)); add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs)); add(new BranchesPanel("branchesPanel", repositoryName, r, numberRefs)); // Display an activity line graph - insertActivityGraph(r); + insertActivityGraph(metrics); } @Override @@ -69,18 +75,17 @@ public class SummaryPage extends RepositoryPage { return getString("gb.summary"); } - private void insertActivityGraph(Repository r) { - if (StoredSettings.getBoolean("generateActivityGraph", true)) { - List dates = JGitUtils.getDateMetrics(r); - IChartData data = getChartData(dates); + private void insertActivityGraph(List metrics) { + if (StoredSettings.getBoolean("generateActivityGraph", true)) { + IChartData data = getChartData(metrics); ChartProvider provider = new ChartProvider(new Dimension(400, 80), ChartType.LINE, data); ChartAxis dateAxis = new ChartAxis(ChartAxisType.BOTTOM); - dateAxis.setLabels(new String[] { dates.get(0).name, dates.get(dates.size() / 2).name, dates.get(dates.size() - 1).name }); + dateAxis.setLabels(new String[] { metrics.get(0).name, metrics.get(metrics.size() / 2).name, metrics.get(metrics.size() - 1).name }); provider.addAxis(dateAxis); ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT); - commitAxis.setLabels(new String[] { "", String.valueOf((int) maxValue(dates)) }); + commitAxis.setLabels(new String[] { "", String.valueOf((int) maxValue(metrics)) }); provider.addAxis(commitAxis); add(new Chart("commitsChart", provider)); @@ -89,11 +94,11 @@ public class SummaryPage extends RepositoryPage { } } - protected IChartData getChartData(List results) { - final double[] counts = new double[results.size()]; + protected IChartData getChartData(List metrics) { + final double[] counts = new double[metrics.size()]; int i = 0; double max = 0; - for (Metric m : results) { + for (Metric m : metrics) { counts[i++] = m.count; max = Math.max(max, m.count); } diff --git a/src/com/gitblit/wicket/pages/TagPage.java b/src/com/gitblit/wicket/pages/TagPage.java index d6b6c68c..0f0d1595 100644 --- a/src/com/gitblit/wicket/pages/TagPage.java +++ b/src/com/gitblit/wicket/pages/TagPage.java @@ -17,7 +17,7 @@ public class TagPage extends RepositoryPage { super(params); Repository r = getRepository(); - RevCommit c = JGitUtils.getCommit(r, commitId); + RevCommit c = JGitUtils.getCommit(r, objectId); add(new LinkPanel("commit", "title", c.getName(), CommitPage.class, newCommitParameter())); diff --git a/src/com/gitblit/wicket/pages/TreePage.java b/src/com/gitblit/wicket/pages/TreePage.java index 83b06e57..493313ee 100644 --- a/src/com/gitblit/wicket/pages/TreePage.java +++ b/src/com/gitblit/wicket/pages/TreePage.java @@ -29,7 +29,7 @@ public class TreePage extends RepositoryPage { final String basePath = params.getString("f", null); Repository r = getRepository(); - RevCommit commit = JGitUtils.getCommit(r, commitId); + RevCommit commit = JGitUtils.getCommit(r, objectId); List paths = JGitUtils.getFilesInPath(r, basePath, commit); // tree page links @@ -39,9 +39,9 @@ public class TreePage extends RepositoryPage { add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter())); // breadcrumbs - add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, basePath, commitId)); + add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, basePath, objectId)); if (basePath != null && basePath.trim().length() > 0) { - paths.add(0, PathModel.getParentPath(basePath, commitId)); + paths.add(0, PathModel.getParentPath(basePath, objectId)); } final ByteFormat byteFormat = new ByteFormat(); diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java index dd4596da..d060b147 100644 --- a/src/com/gitblit/wicket/panels/BranchesPanel.java +++ b/src/com/gitblit/wicket/panels/BranchesPanel.java @@ -61,14 +61,14 @@ public class BranchesPanel extends Panel { item.add(WicketUtils.createDateLabel("branchDate", entry.getDate(), GitBlitWebSession.get().getTimezone())); - item.add(new LinkPanel("branchName", "list name", WicketUtils.trimString(entry.getDisplayName(), 28), LogPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName()))); + item.add(new LinkPanel("branchName", "list name", WicketUtils.trimString(entry.getDisplayName(), 28), LogPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); // only show branch type on the branches page boolean remote = entry.getName().startsWith(Constants.R_REMOTES); item.add(new Label("branchType", remote ? getString("gb.remote"):getString("gb.local")).setVisible(maxCount <= 0)); - item.add(new BookmarkablePageLink("log", LogPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName()))); - item.add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName()))); + item.add(new BookmarkablePageLink("log", LogPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); + item.add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); WicketUtils.setAlternatingBackground(item, counter); counter++; diff --git a/src/com/gitblit/wicket/panels/LogPanel.java b/src/com/gitblit/wicket/panels/LogPanel.java index 630be610..077ebb91 100644 --- a/src/com/gitblit/wicket/panels/LogPanel.java +++ b/src/com/gitblit/wicket/panels/LogPanel.java @@ -4,9 +4,9 @@ import java.util.Date; import java.util.List; import java.util.Map; +import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import org.apache.wicket.markup.html.navigation.paging.PagingNavigator; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; @@ -31,17 +31,26 @@ public class LogPanel extends Panel { private static final long serialVersionUID = 1L; - public LogPanel(String wicketId, final String repositoryName, Repository r, int maxCount, boolean showPager) { + public LogPanel(String wicketId, final String repositoryName, String objectId, Repository r, int limit, int pageOffset) { super(wicketId); - + boolean pageResults = limit <= 0; + setOutputMarkupId(pageResults); + final Map> allRefs = JGitUtils.getAllRefs(r); - List commits = JGitUtils.getRevLog(r, maxCount); + List commits; + if (pageResults) { + // Paging result set + commits = JGitUtils.getRevLog(r, objectId, pageOffset*GitBlitWebApp.PAGING_ITEM_COUNT, GitBlitWebApp.PAGING_ITEM_COUNT); + } else { + // Fixed size result set + commits = JGitUtils.getRevLog(r, objectId, 0, limit); + } // header - if (showPager) { + if (pageResults) { // shortlog page // show repository summary page link - add(new LinkPanel("header", "title", repositoryName, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + add(new LinkPanel("header", "title", repositoryName, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName))); } else { // summary page // show shortlog page link @@ -64,7 +73,7 @@ public class LogPanel extends Panel { String shortMessage = entry.getShortMessage(); String trimmedMessage = WicketUtils.trimShortLog(shortMessage); - LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName())); + LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())); if (!shortMessage.equals(trimmedMessage)) { WicketUtils.setHtmlTitle(shortlog, shortMessage); } @@ -72,32 +81,29 @@ public class LogPanel extends Panel { item.add(new RefsPanel("commitRefs", entry, allRefs)); - item.add(new BookmarkablePageLink("view", CommitPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName()))); - item.add(new BookmarkablePageLink("diff", DiffPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName()))); - item.add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName()))); + item.add(new BookmarkablePageLink("view", CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); + item.add(new BookmarkablePageLink("diff", DiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); + item.add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); WicketUtils.setAlternatingBackground(item, counter); counter++; } }; - add(logView); + add(logView); // determine to show pager, more, or neither - if (maxCount <= 0) { + if (limit <= 0) { // no display limit add(new Label("moreLogs", "").setVisible(false)); add(new Label("pageLogs", "").setVisible(false)); - } else { - if (commits.size() == maxCount) { - - } - if (showPager) { + } else { + if (pageResults) { // paging add(new Label("moreLogs", "").setVisible(false)); - if (commits.size() == maxCount) { + if (commits.size() == limit) { // show pager logView.setItemsPerPage(GitBlitWebApp.PAGING_ITEM_COUNT); - add(new PagingNavigator("pageLogs", logView)); + add(new AjaxPagingNavigator("pageLogs", logView)); } else { // nothing to page add(new Label("pageLogs", "").setVisible(false)); @@ -105,7 +111,7 @@ public class LogPanel extends Panel { } else { // more add(new Label("pageLogs", "").setVisible(false)); - if (commits.size() == maxCount) { + if (commits.size() == limit) { // show more add(new LinkPanel("moreLogs", "link", new StringResourceModel("gb.moreLogs", this, null), LogPage.class, WicketUtils.newRepositoryParameter(repositoryName))); } else { diff --git a/src/com/gitblit/wicket/panels/TagsPanel.java b/src/com/gitblit/wicket/panels/TagsPanel.java index 92307b41..454f9b2a 100644 --- a/src/com/gitblit/wicket/panels/TagsPanel.java +++ b/src/com/gitblit/wicket/panels/TagsPanel.java @@ -51,7 +51,7 @@ public class TagsPanel extends Panel { item.add(WicketUtils.createDateLabel("tagDate", entry.getDate(), GitBlitWebSession.get().getTimezone())); - item.add(new LinkPanel("tagName", "list name", entry.getDisplayName(), CommitPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getCommitId().getName()))); + item.add(new LinkPanel("tagName", "list name", entry.getDisplayName(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getCommitId().getName()))); String message; if (maxCount > 0) { message = WicketUtils.trimString(entry.getShortLog(), 40); @@ -59,13 +59,13 @@ public class TagsPanel extends Panel { message = entry.getShortLog(); } if (entry.isAnnotatedTag()) { - item.add(new LinkPanel("tagDescription", "list subject", message, TagPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getObjectId().getName()))); + item.add(new LinkPanel("tagDescription", "list subject", message, TagPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getObjectId().getName()))); } else { - item.add(new LinkPanel("tagDescription", "list subject", message, CommitPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getObjectId().getName()))); + item.add(new LinkPanel("tagDescription", "list subject", message, CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getObjectId().getName()))); } - item.add(new BookmarkablePageLink("view", TagPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getObjectId().getName())).setEnabled(entry.isAnnotatedTag())); - item.add(new BookmarkablePageLink("commit", CommitPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getCommitId().getName()))); - item.add(new BookmarkablePageLink("log", LogPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName()))); + item.add(new BookmarkablePageLink("view", TagPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getObjectId().getName())).setEnabled(entry.isAnnotatedTag())); + item.add(new BookmarkablePageLink("commit", CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getCommitId().getName()))); + item.add(new BookmarkablePageLink("log", LogPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); WicketUtils.setAlternatingBackground(item, counter); counter++; -- 2.39.5