From 80aecb7e33714ba6416710835ca372c4cd28fcad Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 24 May 2013 17:43:16 -0400
Subject: [PATCH] Polish the tag page
---
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java | 85 ++++++++++++++++++------------------------
1 files changed, 37 insertions(+), 48 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
index a477b74..072475a 100644
--- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
@@ -54,6 +54,7 @@
import com.gitblit.models.UserModel;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.PushLogUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.utils.TicgitUtils;
import com.gitblit.wicket.GitBlitWebSession;
@@ -65,7 +66,7 @@
import com.gitblit.wicket.panels.NavigationPanel;
import com.gitblit.wicket.panels.RefsPanel;
-public abstract class RepositoryPage extends BasePage {
+public abstract class RepositoryPage extends RootPage {
protected final String projectName;
protected final String repositoryName;
@@ -125,7 +126,7 @@
// standard page links
List<PageRegistration> pages = new ArrayList<PageRegistration>(registeredPages.values());
- NavigationPanel navigationPanel = new NavigationPanel("navPanel", getClass(), pages);
+ NavigationPanel navigationPanel = new NavigationPanel("repositoryNavPanel", getRepoNavPageClass(), pages);
add(navigationPanel);
add(new ExternalLink("syndication", SyndicationServlet.asLink(getRequest()
@@ -139,7 +140,16 @@
// set stateless page preference
setStatelessHint(true);
}
+
+ @Override
+ protected Class<? extends BasePage> getRootNavPageClass() {
+ return RepositoriesPage.class;
+ }
+ protected Class<? extends BasePage> getRepoNavPageClass() {
+ return getClass();
+ }
+
private Map<String, PageRegistration> registerPages() {
PageParameters params = null;
if (!StringUtils.isEmpty(repositoryName)) {
@@ -147,26 +157,29 @@
}
Map<String, PageRegistration> pages = new LinkedHashMap<String, PageRegistration>();
+ Repository r = getRepository();
+ RepositoryModel model = getRepositoryModel();
+
// standard links
- pages.put("repositories", new PageRegistration("gb.repositories", RepositoriesPage.class));
- pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
- pages.put("log", new PageRegistration("gb.log", LogPage.class, params));
- pages.put("branches", new PageRegistration("gb.branches", BranchesPage.class, params));
- pages.put("tags", new PageRegistration("gb.tags", TagsPage.class, params));
+ if (PushLogUtils.getPushLogBranch(r) == null) {
+ pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
+ } else {
+ pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
+// pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params));
+ }
+ pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));
pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
+ pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params));
if (GitBlit.getBoolean(Keys.web.allowForking, true)) {
pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params));
}
// conditional links
- Repository r = getRepository();
- RepositoryModel model = getRepositoryModel();
-
// per-repository extra page links
if (model.useTickets && TicgitUtils.getTicketsBranch(r) != null) {
pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, params));
}
- if (model.useDocs) {
+ if (model.showReadme || model.useDocs) {
pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params));
}
if (JGitUtils.getPagesBranch(r) != null) {
@@ -246,30 +259,11 @@
}
}
- // show sparkleshare folder icon
- if (model.isSparkleshared()) {
- add(WicketUtils.newImage("repositoryIcon", "folder_star_32x32.png",
- getString("gb.isSparkleshared")));
- } else {
- add(WicketUtils.newClearPixel("repositoryIcon").setVisible(false));
- }
-
- if (getRepositoryModel().isBare) {
- add(new Label("workingCopyIndicator").setVisible(false));
- } else {
- Fragment wc = new Fragment("workingCopyIndicator", "workingCopyFragment", this);
- Label lbl = new Label("workingCopy", getString("gb.workingCopy"));
- WicketUtils.setHtmlTooltip(lbl, getString("gb.workingCopyWarning"));
- wc.add(lbl);
- add(wc);
- }
-
// fork controls
if (!allowForkControls() || user == null || !user.isAuthenticated) {
// must be logged-in to fork, hide all fork controls
add(new ExternalLink("forkLink", "").setVisible(false));
add(new ExternalLink("myForkLink", "").setVisible(false));
- add(new Label("forksProhibitedIndicator").setVisible(false));
} else {
String fork = GitBlit.self().getFork(user.username, model.name);
boolean hasFork = fork != null;
@@ -278,18 +272,6 @@
if (hasFork || !canFork) {
// user not allowed to fork or fork already exists or repo forbids forking
add(new ExternalLink("forkLink", "").setVisible(false));
-
- if (user.canFork() && !model.allowForks) {
- // show forks prohibited indicator
- Fragment wc = new Fragment("forksProhibitedIndicator", "forksProhibitedFragment", this);
- Label lbl = new Label("forksProhibited", getString("gb.forksProhibited"));
- WicketUtils.setHtmlTooltip(lbl, getString("gb.forksProhibitedWarning"));
- wc.add(lbl);
- add(wc);
- } else {
- // can not fork, no need for forks prohibited indicator
- add(new Label("forksProhibitedIndicator").setVisible(false));
- }
if (hasFork && !fork.equals(model.name)) {
// user has fork, view my fork link
@@ -301,7 +283,6 @@
}
} else if (canFork) {
// can fork and we do not have one
- add(new Label("forksProhibitedIndicator").setVisible(false));
add(new ExternalLink("myForkLink", "").setVisible(false));
String url = getRequestCycle().urlFor(ForkPage.class, WicketUtils.newRepositoryParameter(model.name)).toString();
add(new ExternalLink("forkLink", url));
@@ -358,7 +339,7 @@
return commit;
}
- private Map<String, SubmoduleModel> getSubmodules(RevCommit commit) {
+ protected Map<String, SubmoduleModel> getSubmodules(RevCommit commit) {
if (submodules == null) {
submodules = new HashMap<String, SubmoduleModel>();
for (SubmoduleModel model : JGitUtils.getSubmodules(r, commit.getTree())) {
@@ -369,7 +350,10 @@
}
protected SubmoduleModel getSubmodule(String path) {
- SubmoduleModel model = submodules.get(path);
+ SubmoduleModel model = null;
+ if (submodules != null) {
+ model = submodules.get(path);
+ }
if (model == null) {
// undefined submodule?!
model = new SubmoduleModel(path.substring(path.lastIndexOf('/') + 1), path, path);
@@ -439,9 +423,9 @@
}
protected void addFullText(String wicketId, String text, boolean substituteRegex) {
- String html = StringUtils.escapeForHtml(text, true);
+ String html = StringUtils.escapeForHtml(text, false);
if (substituteRegex) {
- html = GitBlit.self().processCommitMessage(repositoryName, text);
+ html = GitBlit.self().processCommitMessage(repositoryName, html);
} else {
html = StringUtils.breakLinesForHtml(html);
}
@@ -579,7 +563,12 @@
public void onSubmit() {
Constants.SearchType searchType = searchTypeModel.getObject();
String searchString = searchBoxModel.getObject();
- if (searchString == null) {
+ if (StringUtils.isEmpty(searchString)) {
+ // redirect to self to avoid wicket page update bug
+ PageParameters params = RepositoryPage.this.getPageParameters();
+ String relativeUrl = urlFor(RepositoryPage.this.getClass(), params).toString();
+ String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
+ getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
return;
}
for (Constants.SearchType type : Constants.SearchType.values()) {
--
Gitblit v1.9.1