]> source.dussan.org Git - gitblit.git/commitdiff
Working history feature. Tweak to paging.
authorJames Moger <james.moger@gitblit.com>
Sat, 16 Apr 2011 20:28:19 +0000 (16:28 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 16 Apr 2011 20:28:19 +0000 (16:28 -0400)
14 files changed:
.classpath
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/wicket/GitBlitWebApp.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/WicketUtils.java
src/com/gitblit/wicket/pages/CommitDiffPage.java
src/com/gitblit/wicket/pages/CommitPage.java
src/com/gitblit/wicket/pages/HistoryPage.html [new file with mode: 0644]
src/com/gitblit/wicket/pages/HistoryPage.java [new file with mode: 0644]
src/com/gitblit/wicket/pages/LogPage.java
src/com/gitblit/wicket/pages/TreePage.java
src/com/gitblit/wicket/panels/HistoryPanel.html [new file with mode: 0644]
src/com/gitblit/wicket/panels/HistoryPanel.java [new file with mode: 0644]
src/com/gitblit/wicket/panels/LogPanel.java

index 4f9e926b966f97fd9bef13c1ca2f96e17367c0db..f4a6cb60fe4824236c8ef7775a8051c662ccb32f 100644 (file)
@@ -3,8 +3,6 @@
        <classpathentry kind="src" path="src"/>\r
        <classpathentry kind="src" path="contrib"/>\r
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
-       <classpathentry kind="lib" path="lib/jgit-0.11.3.jar" sourcepath="/org.eclipse.jgit"/>\r
-       <classpathentry kind="lib" path="lib/jgit-http-0.11.3.jar" sourcepath="/org.eclipse.jgit.http.server"/>\r
        <classpathentry kind="lib" path="ext/log4j-1.2.16.jar"/>\r
        <classpathentry kind="lib" path="ext/servlet-api-2.5.jar"/>\r
        <classpathentry kind="lib" path="ext/slf4j-api-1.6.1.jar"/>\r
@@ -15,5 +13,7 @@
        <classpathentry kind="lib" path="ext/wicket-1.4.17.jar"/>\r
        <classpathentry kind="lib" path="ext/wicket-auth-roles-1.4.17.jar"/>\r
        <classpathentry kind="lib" path="ext/wicket-extensions-1.4.17.jar"/>\r
+       <classpathentry kind="lib" path="lib/jgit-0.11.3.jar"/>\r
+       <classpathentry kind="lib" path="lib/jgit-http-0.11.3.jar"/>\r
        <classpathentry kind="output" path="bin"/>\r
 </classpath>\r
index fa313911129cae84384a2133bdb3ee3a21952f4e..7128f722257837264088aeb101220e17e333a685 100644 (file)
@@ -35,6 +35,7 @@ import org.eclipse.jgit.revwalk.RevObject;
 import org.eclipse.jgit.revwalk.RevTree;\r
 import org.eclipse.jgit.revwalk.RevWalk;\r
 import org.eclipse.jgit.treewalk.TreeWalk;\r
+import org.eclipse.jgit.treewalk.filter.AndTreeFilter;\r
 import org.eclipse.jgit.treewalk.filter.PathFilter;\r
 import org.eclipse.jgit.treewalk.filter.PathFilterGroup;\r
 import org.eclipse.jgit.treewalk.filter.TreeFilter;\r
@@ -436,6 +437,10 @@ public class JGitUtils {
        }\r
 \r
        public static List<RevCommit> getRevLog(Repository r, String objectId, int offset, int maxCount) {\r
+               return getRevLog(r, objectId, null, offset, maxCount);\r
+       }\r
+       \r
+       public static List<RevCommit> getRevLog(Repository r, String objectId, String path, int offset, int maxCount) {\r
                List<RevCommit> list = new ArrayList<RevCommit>();\r
                try {\r
                        if (objectId == null || objectId.trim().length() == 0) {\r
@@ -444,6 +449,12 @@ public class JGitUtils {
                        RevWalk walk = new RevWalk(r);\r
                        ObjectId object = r.resolve(objectId);\r
                        walk.markStart(walk.parseCommit(object));\r
+                       if (!StringUtils.isEmpty(path)) {\r
+                               TreeFilter filter = AndTreeFilter.create(PathFilterGroup\r
+                                               .createFromStrings(Collections.singleton(path)),\r
+                                               TreeFilter.ANY_DIFF);\r
+                               walk.setTreeFilter(filter);\r
+                       }\r
                        Iterable<RevCommit> revlog = walk;\r
                        if (offset > 0) {\r
                                int count = 0;\r
index 29d6b515eb992b307d282ef0bfcd6fbba5cfee67..28f62625f258a4918aa97bd2566a8388efc8e99e 100644 (file)
@@ -17,6 +17,7 @@ import com.gitblit.wicket.pages.BlobPage;
 import com.gitblit.wicket.pages.BranchesPage;\r
 import com.gitblit.wicket.pages.CommitDiffPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
+import com.gitblit.wicket.pages.HistoryPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
 import com.gitblit.wicket.pages.PatchPage;\r
 import com.gitblit.wicket.pages.RawPage;\r
@@ -60,6 +61,7 @@ public class GitBlitWebApp extends WebApplication {
                mount(new MixedParamUrlCodingStrategy("/blobdiff", BlobDiffPage.class, new String[] { "r", "h", "f" }));\r
                mount(new MixedParamUrlCodingStrategy("/commitdiff", CommitDiffPage.class, new String[] { "r", "h" }));\r
                mount(new MixedParamUrlCodingStrategy("/patch", PatchPage.class, new String[] { "r", "h", "f" }));\r
+               mount(new MixedParamUrlCodingStrategy("/history", HistoryPage.class, new String[] { "r", "h", "f" }));\r
 \r
                // setup ticgit urls\r
                mount(new MixedParamUrlCodingStrategy("/ticgit", TicGitPage.class, new String[] { "r" }));\r
index a5583c7a2f8fb4a5e51fa49c47142911943388f9..033742ebeec56668728111585c7269cf95c43917 100644 (file)
@@ -45,4 +45,6 @@ gb.login = Login
 gb.logout = Logout\r
 gb.username = Username\r
 gb.password = Password\r
-gb.tagger = tagger
\ No newline at end of file
+gb.tagger = tagger\r
+gb.moreHistory = more history...\r
+gb.difftocurrent = diff to current
\ No newline at end of file
index 3288498f11e6652f5f4e59f81b0c97ed355e947a..3bc55f1b33ace4f8edd497d13f5ce2b78d72e492 100644 (file)
@@ -80,6 +80,13 @@ public class WicketUtils {
                }\r
                return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",page=" + pageNumber);\r
        }\r
+       \r
+       public static PageParameters newHistoryPageParameter(String repositoryName, String objectId, String path, int pageNumber) {\r
+               if (pageNumber <= 1) {\r
+                       return newObjectParameter(repositoryName, objectId);\r
+               }\r
+               return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",f=" + path + ",page=" + pageNumber);\r
+       }\r
 \r
        public static String getRepositoryName(PageParameters params) {\r
                return params.getString("r", "");\r
index 7218cf8104be82a9a56be92cec0e8bcc669b5d40..87e81102779ab76917523aa711eb636e67862801 100644 (file)
@@ -63,7 +63,7 @@ public class CommitDiffPage extends RepositoryPage {
                                item.add(new BookmarkablePageLink<Void>("patch", PatchPage.class, newPathParameter(entry.path)));\r
                                item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, newPathParameter(entry.path)));\r
                                item.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));\r
-                               item.add(new BookmarkablePageLink<Void>("history", BlobPage.class).setEnabled(false));\r
+                               item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, newPathParameter(entry.path)));\r
 \r
                                WicketUtils.setAlternatingBackground(item, counter);\r
                                counter++;\r
index 9cc6df8558d31babca06a539fee3a296a694581f..63817ca39d29acbad7a42c42b7695d63f61c335d 100644 (file)
@@ -92,7 +92,7 @@ public class CommitPage extends RepositoryPage {
                                item.add(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, newPathParameter(entry.path)));\r
                                item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, newPathParameter(entry.path)));\r
                                item.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));\r
-                               item.add(new BookmarkablePageLink<Void>("history", BlobPage.class).setEnabled(false));\r
+                               item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, newPathParameter(entry.path)));\r
 \r
                                WicketUtils.setAlternatingBackground(item, counter);\r
                                counter++;\r
diff --git a/src/com/gitblit/wicket/pages/HistoryPage.html b/src/com/gitblit/wicket/pages/HistoryPage.html
new file mode 100644 (file)
index 0000000..a77933e
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml"  \r
+      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"  \r
+      xml:lang="en"  \r
+      lang="en"> \r
+\r
+<body>\r
+<wicket:extend>\r
+\r
+       <!-- page nav links --> \r
+       <div wicket:id="pageLinks">[page links]</div>\r
+\r
+       <!-- pager links -->\r
+       <div style="padding-top:5px;padding-bottom:5px;">\r
+               <a wicket:id="firstPageTop"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPageTop"><wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPageTop"><wicket:message key="gb.pageNext"></wicket:message></a> \r
+       </div>\r
+       \r
+       <!-- history -->\r
+       <div style="margin-top:5px;" wicket:id="historyPanel">[history panel]</div>\r
+\r
+       <!-- pager links -->\r
+       <div style="padding-bottom:5px;">\r
+               <a wicket:id="firstPageBottom"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPageBottom"><wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPageBottom"><wicket:message key="gb.pageNext"></wicket:message></a> \r
+       </div>\r
+\r
+</wicket:extend>\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/HistoryPage.java b/src/com/gitblit/wicket/pages/HistoryPage.java
new file mode 100644 (file)
index 0000000..8b7075a
--- /dev/null
@@ -0,0 +1,38 @@
+package com.gitblit.wicket.pages;\r
+\r
+import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+\r
+import com.gitblit.wicket.RepositoryPage;\r
+import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.panels.HistoryPanel;\r
+\r
+public class HistoryPage extends RepositoryPage {\r
+\r
+       public HistoryPage(PageParameters params) {\r
+               super(params);\r
+\r
+               String path = WicketUtils.getPath(params);\r
+               int pageNumber = WicketUtils.getPage(params);\r
+               int prevPage = Math.max(0, pageNumber - 1);\r
+               int nextPage = pageNumber + 1;\r
+\r
+               HistoryPanel history = new HistoryPanel("historyPanel", repositoryName, objectId, path, getRepository(), -1, pageNumber - 1);\r
+               boolean hasMore = history.hasMore();\r
+               add(history);\r
+\r
+               add(new BookmarkablePageLink<Void>("firstPageTop", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, path)).setEnabled(pageNumber > 1));\r
+               add(new BookmarkablePageLink<Void>("prevPageTop", HistoryPage.class, WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, prevPage)).setEnabled(pageNumber > 1));\r
+               add(new BookmarkablePageLink<Void>("nextPageTop", HistoryPage.class, WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, nextPage)).setEnabled(hasMore));\r
+\r
+               add(new BookmarkablePageLink<Void>("firstPageBottom", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, path)).setEnabled(pageNumber > 1));\r
+               add(new BookmarkablePageLink<Void>("prevPageBottom", HistoryPage.class, WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, prevPage)).setEnabled(pageNumber > 1));\r
+               add(new BookmarkablePageLink<Void>("nextPageBottom", HistoryPage.class, WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, nextPage)).setEnabled(hasMore));\r
+\r
+       }\r
+\r
+       @Override\r
+       protected String getPageName() {\r
+               return getString("gb.history");\r
+       }\r
+}\r
index cd75df9cc9fbda6ad86333ebcff493a8443c9bab..38148f5aaeada85778b4e6791e1b74b1edb5280e 100644 (file)
@@ -15,16 +15,17 @@ public class LogPage extends RepositoryPage {
                int pageNumber = WicketUtils.getPage(params);\r
                int prevPage = Math.max(0, pageNumber - 1);\r
                int nextPage = pageNumber + 1;\r
+               LogPanel logPanel = new LogPanel("logPanel", repositoryName, objectId, getRepository(), -1, pageNumber - 1);\r
+               boolean hasMore = logPanel.hasMore();\r
+               add(logPanel);\r
 \r
-               add(new BookmarkablePageLink<Void>("firstPageTop", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)));\r
+               add(new BookmarkablePageLink<Void>("firstPageTop", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)).setEnabled(pageNumber > 1));\r
                add(new BookmarkablePageLink<Void>("prevPageTop", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, prevPage)).setEnabled(pageNumber > 1));\r
-               add(new BookmarkablePageLink<Void>("nextPageTop", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage)));\r
+               add(new BookmarkablePageLink<Void>("nextPageTop", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage)).setEnabled(hasMore));\r
 \r
-               add(new LogPanel("logPanel", repositoryName, objectId, getRepository(), -1, pageNumber - 1));\r
-\r
-               add(new BookmarkablePageLink<Void>("firstPageBottom", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)));\r
+               add(new BookmarkablePageLink<Void>("firstPageBottom", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)).setEnabled(pageNumber > 1));\r
                add(new BookmarkablePageLink<Void>("prevPageBottom", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, prevPage)).setEnabled(pageNumber > 1));\r
-               add(new BookmarkablePageLink<Void>("nextPageBottom", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage)));\r
+               add(new BookmarkablePageLink<Void>("nextPageBottom", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage)).setEnabled(hasMore));\r
        }\r
 \r
        @Override\r
index 5ebb1b655624b826a1b806d43e81ec6b8f00c6c0..2ab164da3dc291e9a5a09af43dd4f03223bfc812 100644 (file)
@@ -26,22 +26,22 @@ public class TreePage extends RepositoryPage {
        public TreePage(PageParameters params) {\r
                super(params);\r
 \r
-               final String basePath = WicketUtils.getPath(params);\r
+               final String path = WicketUtils.getPath(params);\r
 \r
                Repository r = getRepository();\r
                RevCommit commit = JGitUtils.getCommit(r, objectId);\r
-               List<PathModel> paths = JGitUtils.getFilesInPath(r, basePath, commit);\r
+               List<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);\r
 \r
                // tree page links\r
                add(new Label("historyLink", getString("gb.history")));\r
-               add(new BookmarkablePageLink<Void>("headLink", TreePage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, basePath)));\r
+               add(new BookmarkablePageLink<Void>("headLink", TreePage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, path)));\r
 \r
                add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));\r
 \r
                // breadcrumbs\r
-               add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, basePath, objectId));\r
-               if (basePath != null && basePath.trim().length() > 0) {\r
-                       paths.add(0, PathModel.getParentPath(basePath, objectId));\r
+               add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));\r
+               if (path != null && path.trim().length() > 0) {\r
+                       paths.add(0, PathModel.getParentPath(path, objectId));\r
                }\r
 \r
                final ByteFormat byteFormat = new ByteFormat();\r
@@ -69,7 +69,7 @@ public class TreePage extends RepositoryPage {
                                                // links\r
                                                Fragment links = new Fragment("pathLinks", "treeLinks", this);\r
                                                links.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
-                                               links.add(new BookmarkablePageLink<Void>("history", TreePage.class).setEnabled(false));\r
+                                               links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
                                                item.add(links);\r
                                        } else {\r
                                                // blob link\r
@@ -81,7 +81,7 @@ public class TreePage extends RepositoryPage {
                                                links.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
                                                links.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
                                                links.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));\r
-                                               links.add(new BookmarkablePageLink<Void>("history", BlobPage.class).setEnabled(false));\r
+                                               links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
                                                item.add(links);\r
                                        }\r
                                }\r
diff --git a/src/com/gitblit/wicket/panels/HistoryPanel.html b/src/com/gitblit/wicket/panels/HistoryPanel.html
new file mode 100644 (file)
index 0000000..9ba95de
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml"  \r
+      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"  \r
+      xml:lang="en"  \r
+      lang="en"> \r
+\r
+<body>\r
+<wicket:panel>\r
+\r
+       <!-- header --> \r
+       <div class="header" wicket:id="header">[history header]</div>\r
+\r
+       <!-- breadcrumbs -->\r
+       <div wicket:id="breadcrumbs">[breadcrumbs]</div>\r
+               \r
+       <table style="width:100%" class="pretty">\r
+               <tbody>\r
+                       <tr wicket:id="commit">\r
+                       <td class="date"><span wicket:id="commitDate">[commit date]</span></td>\r
+                       <td class="author"><span wicket:id="commitAuthor">[commit author]</span></td>\r
+                       <td><div wicket:id="commitShortMessage">[commit short message]</div></td>\r
+                       <td class="rightAlign"><div wicket:id="commitRefs">[commit refs]</div></td>                     \r
+                       <td class="rightAlign">\r
+                               <span class="link">\r
+                                               <a wicket:id="view"><wicket:message key="gb.view"></wicket:message></a> | <a wicket:id="commitdiff"><wicket:message key="gb.commitdiff"></wicket:message></a> | <a wicket:id="difftocurrent"><wicket:message key="gb.difftocurrent"></wicket:message></a>\r
+                                       </span>\r
+                               </td>\r
+                       </tr>\r
+       </tbody>\r
+       </table>        \r
+       <div wicket:id="moreHistory">[more...]</div>\r
+       \r
+</wicket:panel>\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/HistoryPanel.java b/src/com/gitblit/wicket/panels/HistoryPanel.java
new file mode 100644 (file)
index 0000000..236e077
--- /dev/null
@@ -0,0 +1,130 @@
+package com.gitblit.wicket.panels;\r
+\r
+import java.util.Date;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.wicket.markup.html.basic.Label;\r
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+import org.apache.wicket.markup.repeater.Item;\r
+import org.apache.wicket.markup.repeater.data.DataView;\r
+import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
+import org.apache.wicket.model.StringResourceModel;\r
+import org.eclipse.jgit.lib.ObjectId;\r
+import org.eclipse.jgit.lib.Repository;\r
+import org.eclipse.jgit.revwalk.RevCommit;\r
+\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
+import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.LinkPanel;\r
+import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.pages.BlobDiffPage;\r
+import com.gitblit.wicket.pages.CommitDiffPage;\r
+import com.gitblit.wicket.pages.CommitPage;\r
+import com.gitblit.wicket.pages.HistoryPage;\r
+import com.gitblit.wicket.pages.LogPage;\r
+\r
+public class HistoryPanel extends BasePanel {\r
+\r
+       private static final long serialVersionUID = 1L;\r
+       \r
+       private boolean hasMore = false;\r
+\r
+       public HistoryPanel(String wicketId, final String repositoryName, String objectId, final String path, Repository r, int limit, int pageOffset) {\r
+               super(wicketId);\r
+               boolean pageResults = limit <= 0;\r
+               int itemsPerPage = GitBlit.self().settings().getInteger(Keys.web.logPageCommitCount, 50);\r
+               if (itemsPerPage <= 1) {\r
+                       itemsPerPage = 50;\r
+               }\r
+               \r
+               RevCommit commit = JGitUtils.getCommit(r, objectId);            \r
+               final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);\r
+               List<RevCommit> commits;\r
+               if (pageResults) {\r
+                       // Paging result set\r
+                       commits = JGitUtils.getRevLog(r, objectId, path, pageOffset * itemsPerPage, itemsPerPage);\r
+               } else {\r
+                       // Fixed size result set\r
+                       commits = JGitUtils.getRevLog(r, objectId, path, 0, limit);\r
+               }\r
+               \r
+               // inaccurate way to determine if there are more commits.\r
+               // works unless commits.size() represents the exact end. \r
+               hasMore = commits.size() >= itemsPerPage;\r
+\r
+               // header\r
+               if (pageResults) {\r
+                       // history page\r
+                       // show commit page link\r
+                       add(new LinkPanel("header", "title", commit.getShortMessage(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, commit.getName())));\r
+               } else {\r
+                       // summary page\r
+                       // show history page link\r
+                       add(new LinkPanel("header", "title", new StringResourceModel("gb.history", this, null), LogPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+               }\r
+\r
+               // breadcrumbs\r
+               add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));\r
+\r
+               ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);\r
+               DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) {\r
+                       private static final long serialVersionUID = 1L;\r
+                       int counter = 0;\r
+\r
+                       public void populateItem(final Item<RevCommit> item) {\r
+                               final RevCommit entry = item.getModelObject();\r
+                               final Date date = JGitUtils.getCommitDate(entry);\r
+\r
+                               item.add(WicketUtils.createDateLabel("commitDate", date, getTimeZone()));\r
+\r
+                               String author = entry.getAuthorIdent().getName();\r
+                               item.add(WicketUtils.createAuthorLabel("commitAuthor", author));\r
+\r
+                               String shortMessage = entry.getShortMessage();\r
+                               String trimmedMessage = StringUtils.trimShortLog(shortMessage);\r
+                               LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()));\r
+                               if (!shortMessage.equals(trimmedMessage)) {\r
+                                       WicketUtils.setHtmlTitle(shortlog, shortMessage);\r
+                               }\r
+                               item.add(shortlog);\r
+\r
+                               item.add(new RefsPanel("commitRefs", repositoryName, entry, allRefs));\r
+\r
+                               item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+                               item.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+                               item.add(new BookmarkablePageLink<Void>("difftocurrent", BlobDiffPage.class, WicketUtils.newPathParameter(repositoryName, entry.getName(), path)).setEnabled(counter > 0));\r
+\r
+                               WicketUtils.setAlternatingBackground(item, counter);\r
+                               counter++;\r
+                       }\r
+               };\r
+               add(logView);\r
+\r
+               // determine to show pager, more, or neither\r
+               if (limit <= 0) {\r
+                       // no display limit\r
+                       add(new Label("moreHistory", "").setVisible(false));\r
+               } else {\r
+                       if (pageResults) {\r
+                               // paging\r
+                               add(new Label("moreHistory", "").setVisible(false));\r
+                       } else {\r
+                               // more\r
+                               if (commits.size() == limit) {\r
+                                       // show more\r
+                                       add(new LinkPanel("moreHistory", "link", new StringResourceModel("gb.moreHistory", this, null), HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, path)));\r
+                               } else {\r
+                                       // no more\r
+                                       add(new Label("moreHistory", "").setVisible(false));\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       \r
+       public boolean hasMore() {\r
+               return hasMore;\r
+       }\r
+}\r
index 2075410804c62bce31228ed1af5779cda612ff91..954af757fb119ad4628cc3ff42f8138cb47d7520 100644 (file)
@@ -29,6 +29,8 @@ import com.gitblit.wicket.pages.TreePage;
 public class LogPanel extends BasePanel {\r
 \r
        private static final long serialVersionUID = 1L;\r
+       \r
+       private boolean hasMore = false;\r
 \r
        public LogPanel(String wicketId, final String repositoryName, String objectId, Repository r, int limit, int pageOffset) {\r
                super(wicketId);\r
@@ -48,6 +50,10 @@ public class LogPanel extends BasePanel {
                        commits = JGitUtils.getRevLog(r, objectId, 0, limit);\r
                }\r
 \r
+               // inaccurate way to determine if there are more commits.\r
+               // works unless commits.size() represents the exact end. \r
+               hasMore = commits.size() >= itemsPerPage;\r
+\r
                // header\r
                if (pageResults) {\r
                        // shortlog page\r
@@ -113,4 +119,8 @@ public class LogPanel extends BasePanel {
                        }\r
                }\r
        }\r
+       \r
+       public boolean hasMore() {\r
+               return hasMore;\r
+       }\r
 }\r