From: James Moger Date: Fri, 8 Apr 2011 21:17:28 +0000 (-0400) Subject: created panels for logs, tags, and branches. X-Git-Tag: v0.5.0~99 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=698678268f53067c239a11e928dfd16761a2f9f7;p=gitblit.git created panels for logs, tags, and branches. --- diff --git a/src/com/gitblit/wicket/BasePage.java b/src/com/gitblit/wicket/BasePage.java index d24485f7..d795c615 100644 --- a/src/com/gitblit/wicket/BasePage.java +++ b/src/com/gitblit/wicket/BasePage.java @@ -1,10 +1,7 @@ package com.gitblit.wicket; -import java.util.Date; - import javax.servlet.http.HttpServletRequest; -import org.apache.wicket.Component; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; @@ -14,10 +11,8 @@ import org.slf4j.LoggerFactory; import com.gitblit.Constants; import com.gitblit.StoredSettings; -import com.gitblit.utils.Utils; import com.gitblit.wicket.pages.SummaryPage; - public abstract class BasePage extends WebPage { Logger logger = LoggerFactory.getLogger(BasePage.class); @@ -58,49 +53,7 @@ public abstract class BasePage extends WebPage { HttpServletRequest req = servletWebRequest.getHttpServletRequest(); return req.getServerName(); } - - protected Label createAuthorLabel(String wicketId, String author) { - Label label = new Label(wicketId, author); - WicketUtils.setHtmlTitle(label, author); - return label; - } - - protected Label createDateLabel(String wicketId, Date date) { - Label label = new Label(wicketId, GitBlitWebSession.get().formatDate(date)); - WicketUtils.setCssClass(label, Utils.timeAgoCss(date)); - WicketUtils.setHtmlTitle(label, Utils.timeAgo(date)); - return label; - } - - protected Label createShortlogDateLabel(String wicketId, Date date) { - String dateString = GitBlitWebSession.get().formatDate(date); - String title = Utils.timeAgo(date); - if ((System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000l) { - dateString = title; - title = GitBlitWebSession.get().formatDate(date); - } - Label label = new Label(wicketId, dateString); - WicketUtils.setCssClass(label, Utils.timeAgoCss(date)); - WicketUtils.setHtmlTitle(label, title); - return label; - } - - protected void setAlternatingBackground(Component c, int i) { - String clazz = i % 2 == 0 ? "dark" : "light"; - WicketUtils.setCssClass(c, clazz); - } - - protected String trimShortLog(String string) { - return trimString(string, 60); - } - protected String trimString(String value, int max) { - if (value.length() <= max) { - return value; - } - return value.substring(0, max - 3) + "..."; - } - public void error(String message, Throwable t) { super.error(message); logger.error(message, t); diff --git a/src/com/gitblit/wicket/GitBlitWebApp.java b/src/com/gitblit/wicket/GitBlitWebApp.java index 70bb9702..caaf221f 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/com/gitblit/wicket/GitBlitWebApp.java @@ -33,7 +33,7 @@ import com.gitblit.wicket.pages.BranchesPage; import com.gitblit.wicket.pages.CommitPage; import com.gitblit.wicket.pages.DiffPage; import com.gitblit.wicket.pages.RepositoriesPage; -import com.gitblit.wicket.pages.ShortLogPage; +import com.gitblit.wicket.pages.LogPage; import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TagPage; import com.gitblit.wicket.pages.TagsPage; @@ -63,7 +63,7 @@ public class GitBlitWebApp extends WebApplication { // setup the standard gitweb-ish urls mount(new MixedParamUrlCodingStrategy("/summary", SummaryPage.class, new String[] { "p" })); - mount(new MixedParamUrlCodingStrategy("/shortlog", ShortLogPage.class, new String[] { "p", "h" })); + 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" })); diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index ba077c79..621cb718 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -25,10 +25,10 @@ gb.remote = remote gb.branches = branches gb.patch = patch gb.diff = diff -gb.shortlog = shortlog -gb.more = more -gb.allTags = all tags -gb.allBranches = all branches +gb.log = log +gb.moreLogs = more commits... +gb.allTags = all tags... +gb.allBranches = all branches... gb.summary = summary gb.ticket = ticket gb.newRepository = new repository diff --git a/src/com/gitblit/wicket/RepositoryPage.java b/src/com/gitblit/wicket/RepositoryPage.java index 1a764a3d..0cbda3dd 100644 --- a/src/com/gitblit/wicket/RepositoryPage.java +++ b/src/com/gitblit/wicket/RepositoryPage.java @@ -33,7 +33,7 @@ public abstract class RepositoryPage extends BasePage { redirectToInterceptPage(new RepositoriesPage()); } repositoryName = params.getString("p", ""); - commitId = params.getString("h", ""); + commitId = params.getString("h", "HEAD"); Repository r = getRepository(); @@ -112,24 +112,18 @@ public abstract class RepositoryPage extends BasePage { } protected PageParameters newRepositoryParameter() { - return new PageParameters("p=" + repositoryName); + return WicketUtils.newRepositoryParameter(repositoryName); } protected PageParameters newCommitParameter() { - return newCommitParameter(commitId); + return WicketUtils.newCommitParameter(repositoryName, commitId); } protected PageParameters newCommitParameter(String commitId) { - if (commitId == null || commitId.trim().length() == 0) { - return newRepositoryParameter(); - } - return new PageParameters("p=" + repositoryName + ",h=" + commitId); + return WicketUtils.newCommitParameter(repositoryName, commitId); } protected PageParameters newPathParameter(String path) { - if (path == null || path.trim().length() == 0) { - return newCommitParameter(); - } - return new PageParameters("p=" + repositoryName + ",h=" + commitId + ",f=" + path); + return WicketUtils.newPathParameter(repositoryName, commitId, path); } } diff --git a/src/com/gitblit/wicket/WicketUtils.java b/src/com/gitblit/wicket/WicketUtils.java index ee055c1f..63efd548 100644 --- a/src/com/gitblit/wicket/WicketUtils.java +++ b/src/com/gitblit/wicket/WicketUtils.java @@ -1,9 +1,18 @@ package com.gitblit.wicket; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; +import java.util.TimeZone; import org.apache.wicket.Component; +import org.apache.wicket.PageParameters; import org.apache.wicket.behavior.SimpleAttributeModifier; +import org.apache.wicket.markup.html.basic.Label; + +import com.gitblit.StoredSettings; +import com.gitblit.utils.Utils; public class WicketUtils { @@ -46,4 +55,62 @@ public class WicketUtils { } return sb.toString().trim(); } + + public static void setAlternatingBackground(Component c, int i) { + String clazz = i % 2 == 0 ? "dark" : "light"; + setCssClass(c, clazz); + } + + public static Label createAuthorLabel(String wicketId, String author) { + Label label = new Label(wicketId, author); + WicketUtils.setHtmlTitle(label, author); + return label; + } + + public static String trimShortLog(String string) { + return trimString(string, 60); + } + + public static String trimString(String value, int max) { + if (value.length() <= max) { + return value; + } + return value.substring(0, max - 3) + "..."; + } + + public static PageParameters newRepositoryParameter(String repositoryName) { + return new PageParameters("p=" + repositoryName); + } + + public static PageParameters newCommitParameter(String repositoryName, String commitId) { + if (commitId == null || commitId.trim().length() == 0) { + return newRepositoryParameter(repositoryName); + } + return new PageParameters("p=" + repositoryName + ",h=" + commitId); + } + + public static PageParameters newPathParameter(String repositoryName, String commitId, String path) { + if (path == null || path.trim().length() == 0) { + return newCommitParameter(repositoryName, commitId); + } + return new PageParameters("p=" + repositoryName + ",h=" + commitId + ",f=" + path); + } + + public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone) { + DateFormat df = new SimpleDateFormat(StoredSettings.getString("datestampShortFormat", "MM/dd/yy")); + if (timeZone != null) { + df.setTimeZone(timeZone); + } + String dateString = df.format(date); + String title = Utils.timeAgo(date); + if ((System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000l) { + String tmp = dateString; + dateString = title; + title = tmp; + } + Label label = new Label(wicketId, dateString); + WicketUtils.setCssClass(label, Utils.timeAgoCss(date)); + WicketUtils.setHtmlTitle(label, title); + return label; + } } diff --git a/src/com/gitblit/wicket/models/RefModel.java b/src/com/gitblit/wicket/models/RefModel.java index 08de1105..0c784340 100644 --- a/src/com/gitblit/wicket/models/RefModel.java +++ b/src/com/gitblit/wicket/models/RefModel.java @@ -52,7 +52,8 @@ public class RefModel implements Serializable, Comparable { } public boolean isAnnotatedTag() { - return ref.isPeeled(); + // ref.isPeeled() ?? + return !getCommitId().equals(getObjectId()); } @Override diff --git a/src/com/gitblit/wicket/pages/BlobPage.html b/src/com/gitblit/wicket/pages/BlobPage.html index 913ab0bc..82ba3202 100644 --- a/src/com/gitblit/wicket/pages/BlobPage.html +++ b/src/com/gitblit/wicket/pages/BlobPage.html @@ -31,7 +31,7 @@
[breadcrumbs]
-
[blob content]
+
[blob content]
diff --git a/src/com/gitblit/wicket/pages/BranchesPage.html b/src/com/gitblit/wicket/pages/BranchesPage.html index 33d50825..606cbf4b 100644 --- a/src/com/gitblit/wicket/pages/BranchesPage.html +++ b/src/com/gitblit/wicket/pages/BranchesPage.html @@ -9,20 +9,10 @@
[page links]
- - -
[header]
- - - - - - - - - -
[branch date]
[branch name]
[branch type]
[branch links]
+ +
[branches panel]
+ \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/BranchesPage.java b/src/com/gitblit/wicket/pages/BranchesPage.java index 30fac1a8..f4359d81 100644 --- a/src/com/gitblit/wicket/pages/BranchesPage.java +++ b/src/com/gitblit/wicket/pages/BranchesPage.java @@ -1,23 +1,9 @@ package com.gitblit.wicket.pages; -import java.util.ArrayList; -import java.util.List; - import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.markup.repeater.data.DataView; -import org.apache.wicket.markup.repeater.data.ListDataProvider; -import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.Repository; -import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.Utils; -import com.gitblit.wicket.LinkPanel; import com.gitblit.wicket.RepositoryPage; -import com.gitblit.wicket.WicketUtils; -import com.gitblit.wicket.models.RefModel; -import com.gitblit.wicket.panels.BranchLinksPanel; +import com.gitblit.wicket.panels.BranchesPanel; public class BranchesPage extends RepositoryPage { @@ -25,44 +11,7 @@ public class BranchesPage extends RepositoryPage { public BranchesPage(PageParameters params) { super(params); - Repository r = getRepository(); - List branches = new ArrayList(); - branches.addAll(JGitUtils.getLocalBranches(r, -1)); - branches.addAll(JGitUtils.getRemoteBranches(r, -1)); - - // shortlog - add(new LinkPanel("summary", "title", repositoryName, SummaryPage.class, newRepositoryParameter())); - - ListDataProvider branchesDp = new ListDataProvider(branches); - DataView branchView = new DataView("branch", branchesDp) { - private static final long serialVersionUID = 1L; - int counter = 0; - - public void populateItem(final Item item) { - final RefModel entry = item.getModelObject(); - String date; - if (entry.getDate() != null) { - date = Utils.timeAgo(entry.getDate()); - } else { - date = ""; - } - Label branchDateLabel = new Label("branchDate", date); - item.add(branchDateLabel); - WicketUtils.setCssClass(branchDateLabel, Utils.timeAgoCss(entry.getDate())); - - item.add(new LinkPanel("branchName", "list name", entry.getDisplayName(), ShortLogPage.class, newCommitParameter(entry.getName()))); - - boolean remote = entry.getName().startsWith(Constants.R_REMOTES); - item.add(new Label("branchType", remote ? getString("gb.remote"):getString("gb.local"))); - - item.add(new BranchLinksPanel("branchLinks", repositoryName, entry)); - - String clazz = counter % 2 == 0 ? "dark" : "light"; - WicketUtils.setCssClass(item, clazz); - counter++; - } - }; - add(branchView); + add(new BranchesPanel("branchesPanel", repositoryName, getRepository(), -1)); } @Override diff --git a/src/com/gitblit/wicket/pages/CommitPage.html b/src/com/gitblit/wicket/pages/CommitPage.html index 1b79e637..e49cd576 100644 --- a/src/com/gitblit/wicket/pages/CommitPage.html +++ b/src/com/gitblit/wicket/pages/CommitPage.html @@ -38,7 +38,11 @@ - +
[commit path][path links] + +
diff --git a/src/com/gitblit/wicket/pages/CommitPage.java b/src/com/gitblit/wicket/pages/CommitPage.java index f4608277..b0a92b06 100644 --- a/src/com/gitblit/wicket/pages/CommitPage.java +++ b/src/com/gitblit/wicket/pages/CommitPage.java @@ -5,6 +5,7 @@ import java.util.List; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; @@ -17,7 +18,6 @@ import com.gitblit.wicket.LinkPanel; import com.gitblit.wicket.RepositoryPage; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.models.PathModel; -import com.gitblit.wicket.panels.PathLinksPanel; public class CommitPage extends RepositoryPage { @@ -45,7 +45,7 @@ public class CommitPage extends RepositoryPage { } add(new Label("patchLink", getString("gb.patch"))); - add(new LinkPanel("shortlog", "title", c.getShortMessage(), ShortLogPage.class, newRepositoryParameter())); + add(new LinkPanel("shortlog", "title", c.getShortMessage(), LogPage.class, newRepositoryParameter())); addRefs(r, c); @@ -89,9 +89,12 @@ public class CommitPage extends RepositoryPage { } else { item.add(new LinkPanel("pathName", "list", entry.path, BlobPage.class, newPathParameter(entry.path))); } - item.add(new PathLinksPanel("pathLinks", repositoryName, entry)); - String clazz = counter % 2 == 0 ? "dark" : "light"; - WicketUtils.setCssClass(item, clazz); + + item.add(new BookmarkablePageLink("diff", DiffPage.class, newPathParameter(entry.path))); + item.add(new BookmarkablePageLink("view", BlobPage.class, newPathParameter(entry.path))); + item.add(new BookmarkablePageLink("history", BlobPage.class).setEnabled(false)); + + WicketUtils.setAlternatingBackground(item, counter); counter++; } }; diff --git a/src/com/gitblit/wicket/pages/LogPage.html b/src/com/gitblit/wicket/pages/LogPage.html new file mode 100644 index 00000000..82abb1b1 --- /dev/null +++ b/src/com/gitblit/wicket/pages/LogPage.html @@ -0,0 +1,18 @@ + + + + + + + +
[page links]
+ + +
[log panel]
+ +
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/LogPage.java b/src/com/gitblit/wicket/pages/LogPage.java new file mode 100644 index 00000000..56ab07a8 --- /dev/null +++ b/src/com/gitblit/wicket/pages/LogPage.java @@ -0,0 +1,21 @@ +package com.gitblit.wicket.pages; + +import org.apache.wicket.PageParameters; + +import com.gitblit.wicket.RepositoryPage; +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)); + } + + @Override + protected String getPageName() { + return getString("gb.log"); + } +} diff --git a/src/com/gitblit/wicket/pages/ShortLogPage.html b/src/com/gitblit/wicket/pages/ShortLogPage.html deleted file mode 100644 index 33369316..00000000 --- a/src/com/gitblit/wicket/pages/ShortLogPage.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -
[page links]
- - -
[shortlog header]
- - - - - - - - - - -
[commit date][commit author]
[commit short message]
[commit refs]
[commit links]
-
[pager]
- -
- - \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/ShortLogPage.java b/src/com/gitblit/wicket/pages/ShortLogPage.java deleted file mode 100644 index c83050d8..00000000 --- a/src/com/gitblit/wicket/pages/ShortLogPage.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.gitblit.wicket.pages; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.navigation.paging.PagingNavigator; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.markup.repeater.data.DataView; -import org.apache.wicket.markup.repeater.data.ListDataProvider; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; - -import com.gitblit.utils.JGitUtils; -import com.gitblit.wicket.GitBlitWebApp; -import com.gitblit.wicket.LinkPanel; -import com.gitblit.wicket.RepositoryPage; -import com.gitblit.wicket.WicketUtils; -import com.gitblit.wicket.panels.RefsPanel; -import com.gitblit.wicket.panels.ShortLogLinksPanel; - - -public class ShortLogPage extends RepositoryPage { - - public ShortLogPage(PageParameters params) { - super(params); - - Repository r = getRepository(); - final Map> allRefs = JGitUtils.getAllRefs(r); - List commits = JGitUtils.getRevLog(r, 100); - - // shortlog - add(new LinkPanel("summary", "title", repositoryName, SummaryPage.class, newRepositoryParameter())); - - ListDataProvider dp = new ListDataProvider(commits); - DataView shortlogView = new DataView("commit", dp) { - private static final long serialVersionUID = 1L; - int counter = 0; - - public void populateItem(final Item item) { - final RevCommit entry = item.getModelObject(); - final Date date = JGitUtils.getCommitDate(entry); - - item.add(createShortlogDateLabel("commitDate", date)); - - String author = entry.getAuthorIdent().getName(); - item.add(createAuthorLabel("commitAuthor", author)); - - String shortMessage = entry.getShortMessage(); - String trimmedMessage = trimShortLog(shortMessage); - LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, newCommitParameter(entry.getName())); - if (!shortMessage.equals(trimmedMessage)) { - WicketUtils.setHtmlTitle(shortlog, shortMessage); - } - item.add(shortlog); - - item.add(new RefsPanel("commitRefs", entry, allRefs)); - - item.add(new ShortLogLinksPanel("commitLinks", repositoryName, entry.getName())); - - String clazz = counter % 2 == 0 ? "dark" : "light"; - WicketUtils.setCssClass(item, clazz); - counter++; - } - }; - shortlogView.setItemsPerPage(GitBlitWebApp.PAGING_ITEM_COUNT); - add(shortlogView); - add(new PagingNavigator("navigator", shortlogView)); - } - - @Override - protected String getPageName() { - return getString("gb.shortlog"); - } -} diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html index cba149e5..4151640a 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.html +++ b/src/com/gitblit/wicket/pages/SummaryPage.html @@ -27,54 +27,17 @@ - -
[shortlog header]
- - - - - - - - - - -
[commit date][commit author]
[commit short message]
[commit refs]
[commit links]
-
[more shortlogs]
+ +
[commits panel]
- +
- -
[branches header]
- - - - - - - - -
[branch date]
[branch name]
[branch links]
-
[all branches]
- +
[branches panel]
- +
- -
[tags header]
- - - - - - - - - -
[tag date]
[tag name]
[tag description]
[tag links]
-
[all tags]
- +
[tags panel]
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 0fef375a..72643a76 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -1,21 +1,12 @@ package com.gitblit.wicket.pages; import java.awt.Dimension; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; import java.util.List; -import java.util.Map; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.image.ContextImage; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.markup.repeater.data.DataView; -import org.apache.wicket.markup.repeater.data.ListDataProvider; -import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; import com.codecommit.wicket.AbstractChartData; import com.codecommit.wicket.Chart; @@ -28,16 +19,11 @@ import com.gitblit.StoredSettings; import com.gitblit.utils.JGitUtils; import com.gitblit.wicket.GitBlitWebApp; import com.gitblit.wicket.GitBlitWebSession; -import com.gitblit.wicket.LinkPanel; import com.gitblit.wicket.RepositoryPage; -import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.models.Metric; -import com.gitblit.wicket.models.RefModel; -import com.gitblit.wicket.panels.AnnotatedTagLinksPanel; -import com.gitblit.wicket.panels.BranchLinksPanel; -import com.gitblit.wicket.panels.RefsPanel; -import com.gitblit.wicket.panels.ShortLogLinksPanel; -import com.gitblit.wicket.panels.TagLinksPanel; +import com.gitblit.wicket.panels.BranchesPanel; +import com.gitblit.wicket.panels.LogPanel; +import com.gitblit.wicket.panels.TagsPanel; public class SummaryPage extends RepositoryPage { @@ -57,8 +43,7 @@ public class SummaryPage extends RepositoryPage { numberRefs = numRefsDef; } - Repository r = getRepository(); - final Map> allRefs = JGitUtils.getAllRefs(r); + Repository r = getRepository(); String owner = JGitUtils.getRepositoryOwner(r); GitBlitWebSession session = GitBlitWebSession.get(); @@ -71,120 +56,9 @@ public class SummaryPage extends RepositoryPage { add(new Label("repositoryLastChange", lastchange)); add(new Label("repositoryCloneUrl", cloneurl)); - // shortlog - add(new LinkPanel("shortlog", "title", getString("gb.shortlog"), ShortLogPage.class, newRepositoryParameter())); - - List commits = JGitUtils.getRevLog(r, numberCommits); - ListDataProvider dp = new ListDataProvider(commits); - DataView shortlogView = new DataView("commit", dp) { - private static final long serialVersionUID = 1L; - int counter = 0; - - public void populateItem(final Item item) { - RevCommit entry = item.getModelObject(); - Date date = JGitUtils.getCommitDate(entry); - - item.add(createShortlogDateLabel("commitDate", date)); - - String author = entry.getAuthorIdent().getName(); - item.add(createAuthorLabel("commitAuthor", author)); - - String shortMessage = entry.getShortMessage(); - String trimmedMessage = trimShortLog(shortMessage); - LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, newCommitParameter(entry.getName())); - if (!shortMessage.equals(trimmedMessage)) { - WicketUtils.setHtmlTitle(shortlog, shortMessage); - } - item.add(shortlog); - - item.add(new RefsPanel("commitRefs", entry, allRefs)); - - item.add(new ShortLogLinksPanel("commitLinks", repositoryName, entry.getName())); - - setAlternatingBackground(item, counter); - counter++; - } - }; - add(shortlogView); - if (commits.size() < numberCommits) { - add(new Label("shortlogMore", "").setVisible(false)); - } else { - add(new LinkPanel("shortlogMore", "link", getString("gb.more") + "...", ShortLogPage.class, newRepositoryParameter())); - } - - // tags - List tags = JGitUtils.getTags(r, numberRefs); - add(new LinkPanel("tags", "title", getString("gb.tags"), TagsPage.class, newRepositoryParameter())); - - ListDataProvider tagsDp = new ListDataProvider(tags); - DataView tagView = new DataView("tag", tagsDp) { - private static final long serialVersionUID = 1L; - int counter = 0; - - public void populateItem(final Item item) { - final RefModel entry = item.getModelObject(); - - item.add(createDateLabel("tagDate", entry.getDate())); - - item.add(new LinkPanel("tagName", "list name", entry.getDisplayName(), CommitPage.class, newCommitParameter(entry.getCommitId().getName()))); - - if (entry.isAnnotatedTag()) { - // annotated tag - item.add(new LinkPanel("tagDescription", "list subject", entry.getShortLog(), TagPage.class, newCommitParameter(entry.getObjectId().getName()))); - item.add(new AnnotatedTagLinksPanel("tagLinks", repositoryName, entry)); - } else { - // simple tag on commit object - item.add(new Label("tagDescription", "")); - item.add(new TagLinksPanel("tagLinks", repositoryName, entry)); - } - - setAlternatingBackground(item, counter); - counter++; - } - }; - add(tagView); - if (tags.size() < numberRefs) { - add(new Label("allTags", "").setVisible(false)); - } else { - add(new LinkPanel("allTags", "link", getString("gb.allTags") + "...", TagsPage.class, newRepositoryParameter())); - } - - // branches - List branches = new ArrayList(); - branches.addAll(JGitUtils.getLocalBranches(r, numberRefs)); - branches.addAll(JGitUtils.getRemoteBranches(r, numberRefs)); - Collections.sort(branches); - Collections.reverse(branches); - if (numberRefs > 0 && branches.size() > numberRefs) { - branches = new ArrayList(branches.subList(0, numberRefs)); - } - - add(new LinkPanel("branches", "title", getString("gb.branches"), BranchesPage.class, newRepositoryParameter())); - - ListDataProvider branchesDp = new ListDataProvider(branches); - DataView branchesView = new DataView("branch", branchesDp) { - private static final long serialVersionUID = 1L; - int counter = 0; - - public void populateItem(final Item item) { - final RefModel entry = item.getModelObject(); - - item.add(createDateLabel("branchDate", entry.getDate())); - - item.add(new LinkPanel("branchName", "list name", trimString(entry.getDisplayName(), 28), ShortLogPage.class, newCommitParameter(entry.getName()))); - - item.add(new BranchLinksPanel("branchLinks", repositoryName, entry)); - - setAlternatingBackground(item, counter); - counter++; - } - }; - add(branchesView); - if (branches.size() < numberRefs) { - add(new Label("allBranches", "").setVisible(false)); - } else { - add(new LinkPanel("allBranches", "link", getString("gb.allBranches") + "...", BranchesPage.class, newRepositoryParameter())); - } + add(new LogPanel("commitsPanel", repositoryName, r, numberCommits, false)); + add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs)); + add(new BranchesPanel("branchesPanel", repositoryName, r, numberRefs)); // Display an activity line graph insertActivityGraph(r); diff --git a/src/com/gitblit/wicket/pages/TagsPage.html b/src/com/gitblit/wicket/pages/TagsPage.html index f2bce497..3a49a745 100644 --- a/src/com/gitblit/wicket/pages/TagsPage.html +++ b/src/com/gitblit/wicket/pages/TagsPage.html @@ -10,18 +10,8 @@
[page links]
- -
[header]
- - - - - - - - - -
[tag date]
[tag name]
[tag description]
[tag links]
+ +
[tags panel]
diff --git a/src/com/gitblit/wicket/pages/TagsPage.java b/src/com/gitblit/wicket/pages/TagsPage.java index 2f5b0295..eb1742d1 100644 --- a/src/com/gitblit/wicket/pages/TagsPage.java +++ b/src/com/gitblit/wicket/pages/TagsPage.java @@ -1,58 +1,18 @@ package com.gitblit.wicket.pages; -import java.util.List; - import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.markup.repeater.data.DataView; -import org.apache.wicket.markup.repeater.data.ListDataProvider; -import org.eclipse.jgit.lib.Repository; -import com.gitblit.utils.JGitUtils; -import com.gitblit.wicket.LinkPanel; import com.gitblit.wicket.RepositoryPage; -import com.gitblit.wicket.models.RefModel; -import com.gitblit.wicket.panels.AnnotatedTagLinksPanel; -import com.gitblit.wicket.panels.TagLinksPanel; +import com.gitblit.wicket.panels.TagsPanel; public class TagsPage extends RepositoryPage { public TagsPage(PageParameters params) { super(params); - Repository r = getRepository(); - List tags = JGitUtils.getTags(r, -1); - - // shortlog - add(new LinkPanel("summary", "title", repositoryName, SummaryPage.class, newRepositoryParameter())); - - ListDataProvider tagsDp = new ListDataProvider(tags); - DataView tagView = new DataView("tag", tagsDp) { - private static final long serialVersionUID = 1L; - int counter = 0; - - public void populateItem(final Item item) { - final RefModel entry = item.getModelObject(); - item.add(createDateLabel("tagDate", entry.getDate())); - - item.add(new LinkPanel("tagName", "list name", entry.getDisplayName(), CommitPage.class, newCommitParameter(entry.getObjectId().getName()))); - - if (entry.isAnnotatedTag()) { - // annotated tag - item.add(new LinkPanel("tagDescription", "list subject", entry.getShortLog(), TagPage.class, newCommitParameter(entry.getObjectId().getName()))); - item.add(new AnnotatedTagLinksPanel("tagLinks", repositoryName, entry)); - } else { - // simple tag on commit object - item.add(new Label("tagDescription", "")); - item.add(new TagLinksPanel("tagLinks", repositoryName, entry)); - } - - setAlternatingBackground(item, counter); - counter++; - } - }; - add(tagView); + + add(new TagsPanel("tagsPanel", repositoryName, getRepository(), -1)); + } @Override diff --git a/src/com/gitblit/wicket/pages/TicGitPage.html b/src/com/gitblit/wicket/pages/TicGitPage.html index 262257e8..e339232f 100644 --- a/src/com/gitblit/wicket/pages/TicGitPage.html +++ b/src/com/gitblit/wicket/pages/TicGitPage.html @@ -11,7 +11,7 @@
[page links]
-
[header]
+
[header]
diff --git a/src/com/gitblit/wicket/pages/TicGitPage.java b/src/com/gitblit/wicket/pages/TicGitPage.java index 001002c3..2cfb7723 100644 --- a/src/com/gitblit/wicket/pages/TicGitPage.java +++ b/src/com/gitblit/wicket/pages/TicGitPage.java @@ -7,10 +7,10 @@ import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; -import org.eclipse.jgit.lib.Repository; import com.gitblit.utils.JGitUtils; import com.gitblit.utils.TicGitTicket; +import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.LinkPanel; import com.gitblit.wicket.RepositoryPage; import com.gitblit.wicket.WicketUtils; @@ -20,11 +20,10 @@ public class TicGitPage extends RepositoryPage { public TicGitPage(PageParameters params) { super(params); - Repository r = getRepository(); - List tickets = JGitUtils.getTicGitTickets(r); + List tickets = JGitUtils.getTicGitTickets(getRepository()); - // shortlog - add(new LinkPanel("summary", "title", repositoryName, SummaryPage.class, newRepositoryParameter())); + // header + add(new LinkPanel("header", "title", repositoryName, SummaryPage.class, newRepositoryParameter())); ListDataProvider ticketsDp = new ListDataProvider(tickets); DataView ticketsView = new DataView("ticket", ticketsDp) { @@ -36,11 +35,11 @@ public class TicGitPage extends RepositoryPage { Label stateLabel = new Label("ticketState", entry.state); WicketUtils.setTicketCssClass(stateLabel, entry.state); item.add(stateLabel); - item.add(createDateLabel("ticketDate", entry.date)); - item.add(new Label("ticketHandler", trimString(entry.handler, 30))); - item.add(new LinkPanel("ticketTitle", null, trimString(entry.title, 80), TicGitTicketPage.class, newPathParameter(entry.name))); + item.add(WicketUtils.createDateLabel("ticketDate", entry.date, GitBlitWebSession.get().getTimezone())); + item.add(new Label("ticketHandler", WicketUtils.trimString(entry.handler, 30))); + item.add(new LinkPanel("ticketTitle", null, WicketUtils.trimString(entry.title, 80), TicGitTicketPage.class, newPathParameter(entry.name))); - setAlternatingBackground(item, counter); + WicketUtils.setAlternatingBackground(item, counter); counter++; } }; diff --git a/src/com/gitblit/wicket/pages/TicGitTicketPage.html b/src/com/gitblit/wicket/pages/TicGitTicketPage.html index 5b39268f..47fa87be 100644 --- a/src/com/gitblit/wicket/pages/TicGitTicketPage.html +++ b/src/com/gitblit/wicket/pages/TicGitTicketPage.html @@ -30,7 +30,7 @@ - + diff --git a/src/com/gitblit/wicket/pages/TicGitTicketPage.java b/src/com/gitblit/wicket/pages/TicGitTicketPage.java index 06a7a5ac..5d3ceb48 100644 --- a/src/com/gitblit/wicket/pages/TicGitTicketPage.java +++ b/src/com/gitblit/wicket/pages/TicGitTicketPage.java @@ -41,10 +41,10 @@ public class TicGitTicketPage extends RepositoryPage { public void populateItem(final Item item) { final Comment entry = item.getModelObject(); - item.add(createDateLabel("commentDate", entry.date)); + item.add(WicketUtils.createDateLabel("commentDate", entry.date, GitBlitWebSession.get().getTimezone())); item.add(new Label("commentAuthor", entry.author)); item.add(new Label("commentText", prepareComment(entry.text)).setEscapeModelStrings(false)); - setAlternatingBackground(item, counter); + WicketUtils.setAlternatingBackground(item, counter); counter++; } }; diff --git a/src/com/gitblit/wicket/panels/AdminLinksPanel.java b/src/com/gitblit/wicket/panels/AdminLinksPanel.java index 628036fb..3199447a 100644 --- a/src/com/gitblit/wicket/panels/AdminLinksPanel.java +++ b/src/com/gitblit/wicket/panels/AdminLinksPanel.java @@ -1,10 +1,11 @@ package com.gitblit.wicket.panels; import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.panel.Panel; import com.gitblit.wicket.pages.RepositoriesPage; -public class AdminLinksPanel extends BasePanel { +public class AdminLinksPanel extends Panel { private static final long serialVersionUID = 1L; diff --git a/src/com/gitblit/wicket/panels/AnnotatedTagLinksPanel.html b/src/com/gitblit/wicket/panels/AnnotatedTagLinksPanel.html deleted file mode 100644 index 1bedc697..00000000 --- a/src/com/gitblit/wicket/panels/AnnotatedTagLinksPanel.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/AnnotatedTagLinksPanel.java b/src/com/gitblit/wicket/panels/AnnotatedTagLinksPanel.java deleted file mode 100644 index 3a494dfa..00000000 --- a/src/com/gitblit/wicket/panels/AnnotatedTagLinksPanel.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; - -import com.gitblit.wicket.models.RefModel; -import com.gitblit.wicket.pages.CommitPage; -import com.gitblit.wicket.pages.ShortLogPage; -import com.gitblit.wicket.pages.TagPage; - - -public class AnnotatedTagLinksPanel extends BasePanel { - - private static final long serialVersionUID = 1L; - - public AnnotatedTagLinksPanel(String id, String repositoryName, RefModel tag) { - super(id); - add(new BookmarkablePageLink("tag", TagPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getObjectId().getName()))); - add(new BookmarkablePageLink("commit", CommitPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getCommitId().getName()))); - add(new BookmarkablePageLink("shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getName()))); - } -} \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/BasePanel.java b/src/com/gitblit/wicket/panels/BasePanel.java deleted file mode 100644 index 48f52188..00000000 --- a/src/com/gitblit/wicket/panels/BasePanel.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.StringResourceModel; - -public abstract class BasePanel extends Panel { - - private static final long serialVersionUID = 1L; - - public BasePanel(String id) { - super(id); - } - - public StringResourceModel stringModel(String key) { - return new StringResourceModel(key, this, null); - } -} diff --git a/src/com/gitblit/wicket/panels/BranchLinksPanel.html b/src/com/gitblit/wicket/panels/BranchLinksPanel.html deleted file mode 100644 index 3e519480..00000000 --- a/src/com/gitblit/wicket/panels/BranchLinksPanel.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/BranchLinksPanel.java b/src/com/gitblit/wicket/panels/BranchLinksPanel.java deleted file mode 100644 index ccc8f4e6..00000000 --- a/src/com/gitblit/wicket/panels/BranchLinksPanel.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; - -import com.gitblit.wicket.models.RefModel; -import com.gitblit.wicket.pages.ShortLogPage; -import com.gitblit.wicket.pages.TreePage; - -public class BranchLinksPanel extends BasePanel { - - private static final long serialVersionUID = 1L; - - public BranchLinksPanel(String id, String repositoryName, RefModel tag) { - super(id); - add(new BookmarkablePageLink("shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getName()))); - add(new BookmarkablePageLink("tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getName()))); - } -} \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.html b/src/com/gitblit/wicket/panels/BranchesPanel.html new file mode 100644 index 00000000..50a16812 --- /dev/null +++ b/src/com/gitblit/wicket/panels/BranchesPanel.html @@ -0,0 +1,34 @@ + + + + + + + +
[branches header]
+ +
[comment date]
[comment author]
[comment author]
[comment text]
+ + + + + + + + +
[branch date][branch name][branch type] + +
+ +
[all branches]
+ + +
+ + + \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java new file mode 100644 index 00000000..dd4596da --- /dev/null +++ b/src/com/gitblit/wicket/panels/BranchesPanel.java @@ -0,0 +1,84 @@ +package com.gitblit.wicket.panels; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.markup.repeater.data.DataView; +import org.apache.wicket.markup.repeater.data.ListDataProvider; +import org.apache.wicket.model.StringResourceModel; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.Repository; + +import com.gitblit.utils.JGitUtils; +import com.gitblit.wicket.GitBlitWebSession; +import com.gitblit.wicket.LinkPanel; +import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.models.RefModel; +import com.gitblit.wicket.pages.BranchesPage; +import com.gitblit.wicket.pages.LogPage; +import com.gitblit.wicket.pages.SummaryPage; +import com.gitblit.wicket.pages.TreePage; + +public class BranchesPanel extends Panel { + + private static final long serialVersionUID = 1L; + + public BranchesPanel(String wicketId, final String repositoryName, Repository r, final int maxCount) { + super(wicketId); + + // branches + List branches = new ArrayList(); + branches.addAll(JGitUtils.getLocalBranches(r, maxCount)); + branches.addAll(JGitUtils.getRemoteBranches(r, maxCount)); + Collections.sort(branches); + Collections.reverse(branches); + if (maxCount > 0 && branches.size() > maxCount) { + branches = new ArrayList(branches.subList(0, maxCount)); + } + + if (maxCount > 0) { + // summary page + // show branches page link + add(new LinkPanel("branches", "title", new StringResourceModel("gb.branches", this, null), BranchesPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } else { + // branches page + // show repository summary page link + add(new LinkPanel("branches", "title", repositoryName, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } + + ListDataProvider branchesDp = new ListDataProvider(branches); + DataView branchesView = new DataView("branch", branchesDp) { + private static final long serialVersionUID = 1L; + int counter = 0; + + public void populateItem(final Item item) { + final RefModel entry = item.getModelObject(); + + 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()))); + + // 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()))); + + WicketUtils.setAlternatingBackground(item, counter); + counter++; + } + }; + add(branchesView); + if (branches.size() < maxCount || maxCount <= 0) { + add(new Label("allBranches", "").setVisible(false)); + } else { + add(new LinkPanel("allBranches", "link", new StringResourceModel("gb.allBranches", this, null), BranchesPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } + } +} diff --git a/src/com/gitblit/wicket/panels/LogPanel.html b/src/com/gitblit/wicket/panels/LogPanel.html new file mode 100644 index 00000000..e342f006 --- /dev/null +++ b/src/com/gitblit/wicket/panels/LogPanel.html @@ -0,0 +1,34 @@ + + + + + + + +
[log header]
+ + + + + + + + + + + +
[commit date][commit author]
[commit short message]
[commit refs]
+
+
[pager]
+
[more...]
+ + +
+
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/LogPanel.java b/src/com/gitblit/wicket/panels/LogPanel.java new file mode 100644 index 00000000..630be610 --- /dev/null +++ b/src/com/gitblit/wicket/panels/LogPanel.java @@ -0,0 +1,118 @@ +package com.gitblit.wicket.panels; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +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; +import org.apache.wicket.markup.repeater.data.ListDataProvider; +import org.apache.wicket.model.StringResourceModel; +import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.revwalk.RevCommit; + +import com.gitblit.utils.JGitUtils; +import com.gitblit.wicket.GitBlitWebApp; +import com.gitblit.wicket.GitBlitWebSession; +import com.gitblit.wicket.LinkPanel; +import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.pages.CommitPage; +import com.gitblit.wicket.pages.DiffPage; +import com.gitblit.wicket.pages.LogPage; +import com.gitblit.wicket.pages.SummaryPage; +import com.gitblit.wicket.pages.TreePage; + +public class LogPanel extends Panel { + + private static final long serialVersionUID = 1L; + + public LogPanel(String wicketId, final String repositoryName, Repository r, int maxCount, boolean showPager) { + super(wicketId); + + final Map> allRefs = JGitUtils.getAllRefs(r); + List commits = JGitUtils.getRevLog(r, maxCount); + + // header + if (showPager) { + // shortlog page + // show repository summary page link + add(new LinkPanel("header", "title", repositoryName, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } else { + // summary page + // show shortlog page link + add(new LinkPanel("header", "title", new StringResourceModel("gb.log", this, null), LogPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } + + ListDataProvider dp = new ListDataProvider(commits); + DataView logView = new DataView("commit", dp) { + private static final long serialVersionUID = 1L; + int counter = 0; + + public void populateItem(final Item item) { + final RevCommit entry = item.getModelObject(); + final Date date = JGitUtils.getCommitDate(entry); + + item.add(WicketUtils.createDateLabel("commitDate", date, GitBlitWebSession.get().getTimezone())); + + String author = entry.getAuthorIdent().getName(); + item.add(WicketUtils.createAuthorLabel("commitAuthor", author)); + + String shortMessage = entry.getShortMessage(); + String trimmedMessage = WicketUtils.trimShortLog(shortMessage); + LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getName())); + if (!shortMessage.equals(trimmedMessage)) { + WicketUtils.setHtmlTitle(shortlog, shortMessage); + } + item.add(shortlog); + + 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()))); + + WicketUtils.setAlternatingBackground(item, counter); + counter++; + } + }; + add(logView); + + // determine to show pager, more, or neither + if (maxCount <= 0) { + // no display limit + add(new Label("moreLogs", "").setVisible(false)); + add(new Label("pageLogs", "").setVisible(false)); + } else { + if (commits.size() == maxCount) { + + } + if (showPager) { + // paging + add(new Label("moreLogs", "").setVisible(false)); + if (commits.size() == maxCount) { + // show pager + logView.setItemsPerPage(GitBlitWebApp.PAGING_ITEM_COUNT); + add(new PagingNavigator("pageLogs", logView)); + } else { + // nothing to page + add(new Label("pageLogs", "").setVisible(false)); + } + } else { + // more + add(new Label("pageLogs", "").setVisible(false)); + if (commits.size() == maxCount) { + // show more + add(new LinkPanel("moreLogs", "link", new StringResourceModel("gb.moreLogs", this, null), LogPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } else { + // no more + add(new Label("moreLogs", "").setVisible(false)); + } + } + } + } +} diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.html b/src/com/gitblit/wicket/panels/PageLinksPanel.html index db827281..f2e4d316 100644 --- a/src/com/gitblit/wicket/panels/PageLinksPanel.html +++ b/src/com/gitblit/wicket/panels/PageLinksPanel.html @@ -7,7 +7,7 @@ \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.java b/src/com/gitblit/wicket/panels/PageLinksPanel.java index d9c25275..9c6298c0 100644 --- a/src/com/gitblit/wicket/panels/PageLinksPanel.java +++ b/src/com/gitblit/wicket/panels/PageLinksPanel.java @@ -6,9 +6,9 @@ import java.util.List; import java.util.Map; import org.apache.wicket.Component; -import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; @@ -16,14 +16,15 @@ import org.eclipse.jgit.lib.Repository; import com.gitblit.utils.JGitUtils; import com.gitblit.wicket.LinkPanel; +import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.pages.BranchesPage; -import com.gitblit.wicket.pages.ShortLogPage; +import com.gitblit.wicket.pages.LogPage; import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TagsPage; import com.gitblit.wicket.pages.TicGitPage; import com.gitblit.wicket.pages.TreePage; -public class PageLinksPanel extends BasePanel { +public class PageLinksPanel extends Panel { private static final long serialVersionUID = 1L; @@ -33,7 +34,7 @@ public class PageLinksPanel extends BasePanel { { put("summary", "gb.summary"); - put("shortlog", "gb.shortlog"); + put("log", "gb.log"); put("branches", "gb.branches"); put("tags", "gb.tags"); put("tree", "gb.tree"); @@ -45,11 +46,11 @@ public class PageLinksPanel extends BasePanel { super(id); // summary - add(new BookmarkablePageLink("summary", SummaryPage.class, new PageParameters("p=" + repositoryName))); - add(new BookmarkablePageLink("shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName))); - add(new BookmarkablePageLink("branches", BranchesPage.class, new PageParameters("p=" + repositoryName))); - add(new BookmarkablePageLink("tags", TagsPage.class, new PageParameters("p=" + repositoryName))); - add(new BookmarkablePageLink("tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=HEAD"))); + add(new BookmarkablePageLink("summary", SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + add(new BookmarkablePageLink("log", LogPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + add(new BookmarkablePageLink("branches", BranchesPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + add(new BookmarkablePageLink("tags", TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newRepositoryParameter(repositoryName))); // Add dynamic repository extras List extras = new ArrayList(); @@ -65,7 +66,7 @@ public class PageLinksPanel extends BasePanel { String extra = item.getModelObject(); if (extra.equals("ticgit")) { item.add(new Label("extraSeparator", " | ")); - item.add(new LinkPanel("extraLink", null, "ticgit", TicGitPage.class, new PageParameters("p=" + repositoryName))); + item.add(new LinkPanel("extraLink", null, "ticgit", TicGitPage.class, WicketUtils.newRepositoryParameter(repositoryName))); } } }; @@ -77,8 +78,10 @@ public class PageLinksPanel extends BasePanel { String key = knownPages.get(wicketId); String linkName = getString(key); if (linkName.equals(pageName)) { - Component c = get(wicketId); - c.setEnabled(false); + Component c = get(wicketId); + if (c != null) { + c.setEnabled(false); + } break; } } diff --git a/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java b/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java index a8a5c285..d27133ce 100644 --- a/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java +++ b/src/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java @@ -4,7 +4,6 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.markup.repeater.Item; @@ -12,6 +11,7 @@ import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; import com.gitblit.wicket.LinkPanel; +import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.pages.TreePage; public class PathBreadcrumbsPanel extends Panel { @@ -49,7 +49,7 @@ public class PathBreadcrumbsPanel extends Panel { parameters += ",f=" + path; } - item.add(new LinkPanel("pathLink", null, entry.name, TreePage.class, new PageParameters(parameters))); + item.add(new LinkPanel("pathLink", null, entry.name, TreePage.class, WicketUtils.newPathParameter(repositoryName, commitId, path))); item.add(new Label("pathSeparator", entry.isLeaf ? "" : "/")); } }; diff --git a/src/com/gitblit/wicket/panels/PathLinksPanel.html b/src/com/gitblit/wicket/panels/PathLinksPanel.html deleted file mode 100644 index 8079eccb..00000000 --- a/src/com/gitblit/wicket/panels/PathLinksPanel.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/PathLinksPanel.java b/src/com/gitblit/wicket/panels/PathLinksPanel.java deleted file mode 100644 index e1c489ff..00000000 --- a/src/com/gitblit/wicket/panels/PathLinksPanel.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; - -import com.gitblit.wicket.models.PathModel; -import com.gitblit.wicket.pages.BlobPage; -import com.gitblit.wicket.pages.DiffPage; - - -public class PathLinksPanel extends BasePanel { - - private static final long serialVersionUID = 1L; - - public PathLinksPanel(String id, String repositoryName, PathModel path) { - super(id); - add(new BookmarkablePageLink("diff", DiffPage.class, new PageParameters("p=" + repositoryName + ",h=" + path.commitId + ",f=" + path.path))); - add(new BookmarkablePageLink("view", BlobPage.class, new PageParameters("p=" + repositoryName + ",h=" + path.commitId + ",f=" + path.path))); - add(new BookmarkablePageLink("history", BlobPage.class, new PageParameters()).setEnabled(false)); - } -} \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/ShortLogLinksPanel.html b/src/com/gitblit/wicket/panels/ShortLogLinksPanel.html deleted file mode 100644 index 2208ceb8..00000000 --- a/src/com/gitblit/wicket/panels/ShortLogLinksPanel.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/ShortLogLinksPanel.java b/src/com/gitblit/wicket/panels/ShortLogLinksPanel.java deleted file mode 100644 index bf2c7729..00000000 --- a/src/com/gitblit/wicket/panels/ShortLogLinksPanel.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; - -import com.gitblit.wicket.pages.CommitPage; -import com.gitblit.wicket.pages.DiffPage; -import com.gitblit.wicket.pages.TreePage; - - -public class ShortLogLinksPanel extends BasePanel { - - private static final long serialVersionUID = 1L; - - public ShortLogLinksPanel(String id, String repositoryName, String commitId) { - super(id); - - add(new BookmarkablePageLink("commit", CommitPage.class, new PageParameters("p=" + repositoryName + ",h=" + commitId))); - add(new BookmarkablePageLink("commitdiff", DiffPage.class, new PageParameters("p=" + repositoryName + ",h=" + commitId))); - add(new BookmarkablePageLink("tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=" + commitId))); - } -} \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TagLinksPanel.html b/src/com/gitblit/wicket/panels/TagLinksPanel.html deleted file mode 100644 index 34a39c95..00000000 --- a/src/com/gitblit/wicket/panels/TagLinksPanel.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TagLinksPanel.java b/src/com/gitblit/wicket/panels/TagLinksPanel.java deleted file mode 100644 index e7f7c8da..00000000 --- a/src/com/gitblit/wicket/panels/TagLinksPanel.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gitblit.wicket.panels; - -import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; - -import com.gitblit.wicket.models.RefModel; -import com.gitblit.wicket.pages.CommitPage; -import com.gitblit.wicket.pages.ShortLogPage; - - -public class TagLinksPanel extends BasePanel { - - private static final long serialVersionUID = 1L; - - public TagLinksPanel(String id, String repositoryName, RefModel tag) { - super(id); - add(new BookmarkablePageLink("commit", CommitPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getCommitId().getName()))); - add(new BookmarkablePageLink("shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName + ",h=" + tag.getName()))); - } -} \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TagsPanel.html b/src/com/gitblit/wicket/panels/TagsPanel.html new file mode 100644 index 00000000..599412d6 --- /dev/null +++ b/src/com/gitblit/wicket/panels/TagsPanel.html @@ -0,0 +1,33 @@ + + + + + + + +
[tags header]
+ + + + + + + + + +
[tag date][tag name][tag description] + +
+ +
[all tags]
+ + +
+
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TagsPanel.java b/src/com/gitblit/wicket/panels/TagsPanel.java new file mode 100644 index 00000000..92307b41 --- /dev/null +++ b/src/com/gitblit/wicket/panels/TagsPanel.java @@ -0,0 +1,81 @@ +package com.gitblit.wicket.panels; + +import java.util.List; + +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.markup.repeater.data.DataView; +import org.apache.wicket.markup.repeater.data.ListDataProvider; +import org.apache.wicket.model.StringResourceModel; +import org.eclipse.jgit.lib.Repository; + +import com.gitblit.utils.JGitUtils; +import com.gitblit.wicket.GitBlitWebSession; +import com.gitblit.wicket.LinkPanel; +import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.models.RefModel; +import com.gitblit.wicket.pages.CommitPage; +import com.gitblit.wicket.pages.LogPage; +import com.gitblit.wicket.pages.SummaryPage; +import com.gitblit.wicket.pages.TagPage; +import com.gitblit.wicket.pages.TagsPage; + +public class TagsPanel extends Panel { + + private static final long serialVersionUID = 1L; + + public TagsPanel(String wicketId, final String repositoryName, Repository r, final int maxCount) { + super(wicketId); + + // header + List tags = JGitUtils.getTags(r, maxCount); + if (maxCount > 0) { + // summary page + // show tags page link + add(new LinkPanel("header", "title", new StringResourceModel("gb.tags", this, null), TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } else { + // tags page + // show repository summary page link + add(new LinkPanel("header", "title", repositoryName, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } + + ListDataProvider tagsDp = new ListDataProvider(tags); + DataView tagView = new DataView("tag", tagsDp) { + private static final long serialVersionUID = 1L; + int counter = 0; + + public void populateItem(final Item item) { + RefModel entry = item.getModelObject(); + + 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()))); + String message; + if (maxCount > 0) { + message = WicketUtils.trimString(entry.getShortLog(), 40); + } else { + message = entry.getShortLog(); + } + if (entry.isAnnotatedTag()) { + item.add(new LinkPanel("tagDescription", "list subject", message, TagPage.class, WicketUtils.newCommitParameter(repositoryName, entry.getObjectId().getName()))); + } else { + item.add(new LinkPanel("tagDescription", "list subject", message, CommitPage.class, WicketUtils.newCommitParameter(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()))); + + WicketUtils.setAlternatingBackground(item, counter); + counter++; + } + }; + add(tagView); + if (tags.size() < maxCount || maxCount <= 0) { + add(new Label("allTags", "").setVisible(false)); + } else { + add(new LinkPanel("allTags", "link", new StringResourceModel("gb.allTags", this, null), TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + } + } +} diff --git a/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.java b/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.java index c8277ae0..e1e6f795 100644 --- a/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.java +++ b/src/com/gitblit/wicket/panels/TreeBlobLinksPanel.java @@ -1,20 +1,21 @@ package com.gitblit.wicket.panels; -import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.panel.Panel; +import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.models.PathModel; import com.gitblit.wicket.pages.BlobPage; -public class TreeBlobLinksPanel extends BasePanel { +public class TreeBlobLinksPanel extends Panel { private static final long serialVersionUID = 1L; public TreeBlobLinksPanel(String id, String repositoryName, PathModel path) { super(id); - add(new BookmarkablePageLink("view", BlobPage.class, new PageParameters("p=" + repositoryName + ",h=" + path.commitId + ",f=" + path.path))); - add(new BookmarkablePageLink("raw", BlobPage.class, new PageParameters()).setEnabled(false)); - add(new BookmarkablePageLink("history", BlobPage.class, new PageParameters()).setEnabled(false)); + add(new BookmarkablePageLink("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, path.commitId, path.path))); + add(new BookmarkablePageLink("raw", BlobPage.class).setEnabled(false)); + add(new BookmarkablePageLink("history", BlobPage.class).setEnabled(false)); } } \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/TreeLinksPanel.java b/src/com/gitblit/wicket/panels/TreeLinksPanel.java index 9a42943c..4965004a 100644 --- a/src/com/gitblit/wicket/panels/TreeLinksPanel.java +++ b/src/com/gitblit/wicket/panels/TreeLinksPanel.java @@ -1,19 +1,20 @@ package com.gitblit.wicket.panels; -import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.panel.Panel; +import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.models.PathModel; import com.gitblit.wicket.pages.TreePage; -public class TreeLinksPanel extends BasePanel { +public class TreeLinksPanel extends Panel { private static final long serialVersionUID = 1L; public TreeLinksPanel(String id, String repositoryName, PathModel path) { super(id); - add(new BookmarkablePageLink("tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=" + path.commitId + ",f=" + path.path))); - add(new BookmarkablePageLink("history", TreePage.class, new PageParameters()).setEnabled(false)); + add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newPathParameter(repositoryName, path.commitId, path.path))); + add(new BookmarkablePageLink("history", TreePage.class).setEnabled(false)); } } \ No newline at end of file diff --git a/src/com/gitblit/wicket/resources/gitblit.css b/src/com/gitblit/wicket/resources/gitblit.css index 6e1717cb..42ab2c0c 100644 --- a/src/com/gitblit/wicket/resources/gitblit.css +++ b/src/com/gitblit/wicket/resources/gitblit.css @@ -103,6 +103,12 @@ div.link a { font-size: inherit; } +div.link em, div.link span em { + font-style: normal; + font-family: inherit; + font-size: inherit; +} + div.page_header { height: 25px; padding: 5px; @@ -157,6 +163,10 @@ div.page_nav a:hover { text-decoration: underline; } +div.page_nav em { + font-style: normal; +} + div.page_nav2 { padding: 2px 5px 7px 5px; }