]> source.dussan.org Git - gitblit.git/commitdiff
Page log.
authorJames Moger <james.moger@gitblit.com>
Mon, 11 Apr 2011 12:18:22 +0000 (08:18 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 11 Apr 2011 12:18:22 +0000 (08:18 -0400)
16 files changed:
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/wicket/GitBlitWebApp.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/RepositoryPage.java
src/com/gitblit/wicket/WicketUtils.java
src/com/gitblit/wicket/pages/BlobPage.java
src/com/gitblit/wicket/pages/DiffPage.java
src/com/gitblit/wicket/pages/LogPage.html
src/com/gitblit/wicket/pages/LogPage.java
src/com/gitblit/wicket/pages/RepositoriesPage.java
src/com/gitblit/wicket/pages/SummaryPage.java
src/com/gitblit/wicket/pages/TagPage.java
src/com/gitblit/wicket/pages/TreePage.java
src/com/gitblit/wicket/panels/BranchesPanel.java
src/com/gitblit/wicket/panels/LogPanel.java
src/com/gitblit/wicket/panels/TagsPanel.java

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