From 3f4a7a3296af87ecd7d6e0e0a8d4ab541cf8629c Mon Sep 17 00:00:00 2001
From: mrbytes <eguervos@msn.com>
Date: Fri, 19 Jul 2013 16:04:58 -0400
Subject: [PATCH] GitBlitWebApp_es.properties: - Best translation in three phrases.
---
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java | 122 +++++++++++++++++++++++++++++++++++-----
1 files changed, 107 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
index 90fdd40..f5b8c96 100644
--- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
@@ -19,6 +19,7 @@
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -28,6 +29,7 @@
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 org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.TextField;
@@ -41,9 +43,12 @@
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.gitblit.Constants;
import com.gitblit.GitBlit;
+import com.gitblit.GitBlitException;
import com.gitblit.Keys;
import com.gitblit.PagesServlet;
import com.gitblit.SyndicationServlet;
@@ -52,11 +57,14 @@
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.SubmoduleModel;
import com.gitblit.models.UserModel;
+import com.gitblit.models.UserRepositoryPreferences;
import com.gitblit.utils.ArrayUtils;
+import com.gitblit.utils.DeepCopier;
import com.gitblit.utils.JGitUtils;
-import com.gitblit.utils.PushLogUtils;
+import com.gitblit.utils.RefLogUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.utils.TicgitUtils;
+import com.gitblit.wicket.CacheControl;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.PageRegistration;
import com.gitblit.wicket.PageRegistration.OtherPageLink;
@@ -67,7 +75,11 @@
import com.gitblit.wicket.panels.RefsPanel;
public abstract class RepositoryPage extends RootPage {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ private final String PARAM_STAR = "star";
+
protected final String projectName;
protected final String repositoryName;
protected final String objectId;
@@ -104,7 +116,7 @@
if (getRepositoryModel().isCollectingGarbage) {
error(MessageFormat.format(getString("gb.busyCollectingGarbage"), getRepositoryModel().name), true);
}
-
+
if (objectId != null) {
RefModel branch = null;
if ((branch = JGitUtils.getBranch(getRepository(), objectId)) != null) {
@@ -117,6 +129,22 @@
branch.reference.getName());
if (!canAccess) {
error(getString("gb.accessDenied"), true);
+ }
+ }
+ }
+
+ if (params.containsKey(PARAM_STAR)) {
+ // set starred state
+ boolean star = params.getBoolean(PARAM_STAR);
+ UserModel user = GitBlitWebSession.get().getUser();
+ if (user != null && user.isAuthenticated) {
+ UserRepositoryPreferences prefs = user.getPreferences().getRepositoryPreferences(getRepositoryModel().name);
+ prefs.starred = star;
+ try {
+ GitBlit.self().updateUserModel(user.username, user, false);
+ } catch (GitBlitException e) {
+ logger.error("Failed to update user " + user.username, e);
+ error(getString("gb.failedToUpdateUser"), false);
}
}
}
@@ -161,29 +189,31 @@
RepositoryModel model = getRepositoryModel();
// standard links
- if (PushLogUtils.getPushLogBranch(r) == null) {
+ if (RefLogUtils.getRefLogBranch(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("reflog", new PageRegistration("gb.reflog", ReflogPage.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, true));
if (GitBlit.getBoolean(Keys.web.allowForking, true)) {
- pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params));
+ pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params, true));
}
// conditional links
// per-repository extra page links
if (model.useTickets && TicgitUtils.getTicketsBranch(r) != null) {
- pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, params));
+ pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, params, true));
}
if (model.showReadme || model.useDocs) {
- pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params));
+ pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
}
if (JGitUtils.getPagesBranch(r) != null) {
OtherPageLink pagesLink = new OtherPageLink("gb.pages", PagesServlet.asLink(
- getRequest().getRelativePathPrefixToContextRoot(), repositoryName, null));
+ getRequest().getRelativePathPrefixToContextRoot(), repositoryName, null), true);
pages.put("pages", pagesLink);
}
@@ -198,9 +228,6 @@
isOwner = GitBlitWebSession.get().isLoggedIn()
&& (model.isOwner(GitBlitWebSession.get()
.getUsername()));
- if (showAdmin || isOwner) {
- pages.put("edit", new PageRegistration("gb.edit", EditRepositoryPage.class, params));
- }
return pages;
}
@@ -258,6 +285,26 @@
}
}
+ // (un)star link allows a user to star a repository
+ if (user.isAuthenticated) {
+ PageParameters starParams = DeepCopier.copy(getPageParameters());
+ starParams.put(PARAM_STAR, !user.getPreferences().isStarredRepository(model.name));
+ String toggleStarUrl = getRequestCycle().urlFor(getClass(), starParams).toString();
+ if (user.getPreferences().isStarredRepository(model.name)) {
+ // show unstar button
+ add(new Label("starLink").setVisible(false));
+ addToolbarButton("unstarLink", "icon-star-empty", getString("gb.unstar"), toggleStarUrl);
+ } else {
+ // show star button
+ addToolbarButton("starLink", "icon-star", getString("gb.star"), toggleStarUrl);
+ add(new Label("unstarLink").setVisible(false));
+ }
+ } else {
+ // anonymous user
+ add(new Label("starLink").setVisible(false));
+ add(new Label("unstarLink").setVisible(false));
+ }
+
// fork controls
if (!allowForkControls() || user == null || !user.isAuthenticated) {
// must be logged-in to fork, hide all fork controls
@@ -288,7 +335,24 @@
}
}
+ if (showAdmin || isOwner) {
+ String url = getRequestCycle().urlFor(EditRepositoryPage.class, WicketUtils.newRepositoryParameter(model.name)).toString();
+ add(new ExternalLink("editLink", url));
+ } else {
+ add(new Label("editLink").setVisible(false));
+ }
+
super.setupPage(repositoryName, pageName);
+ }
+
+ protected void addToolbarButton(String wicketId, String iconClass, String label, String url) {
+ Fragment button = new Fragment(wicketId, "toolbarLinkFragment", this);
+ Label icon = new Label("icon");
+ WicketUtils.setCssClass(icon, iconClass);
+ button.add(icon);
+ button.add(new Label("label", label));
+ button.add(new SimpleAttributeModifier("href", url));
+ add(button);
}
protected void addSyndicationDiscoveryLink() {
@@ -332,13 +396,14 @@
RevCommit commit = JGitUtils.getCommit(r, objectId);
if (commit == null) {
error(MessageFormat.format(getString("gb.failedToFindCommit"),
- objectId, repositoryName, getPageName()), true);
+ objectId, repositoryName, getPageName()), null, LogPage.class,
+ WicketUtils.newRepositoryParameter(repositoryName));
}
getSubmodules(commit);
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())) {
@@ -349,7 +414,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);
@@ -380,7 +448,7 @@
if (submoduleName.lastIndexOf('/') > -1) {
String name = submoduleName.substring(submoduleName.lastIndexOf('/') + 1);
candidates.add(currentPath + StringUtils.stripDotGit(name));
- candidates.add(currentPath + candidates.get(candidates.size() - 1) + ".git");
+ candidates.add(candidates.get(candidates.size() - 1) + ".git");
}
// absolute
@@ -506,6 +574,30 @@
setupPage(repositoryName, "/ " + getPageName());
super.onBeforeRender();
}
+
+ @Override
+ protected void setLastModified() {
+ if (getClass().isAnnotationPresent(CacheControl.class)) {
+ CacheControl cacheControl = getClass().getAnnotation(CacheControl.class);
+ switch (cacheControl.value()) {
+ case REPOSITORY:
+ RepositoryModel repository = getRepositoryModel();
+ if (repository != null) {
+ setLastModified(repository.lastChange);
+ }
+ break;
+ case COMMIT:
+ RevCommit commit = getCommit();
+ if (commit != null) {
+ Date commitDate = JGitUtils.getCommitDate(commit);
+ setLastModified(commitDate);
+ }
+ break;
+ default:
+ super.setLastModified();
+ }
+ }
+ }
protected PageParameters newRepositoryParameter() {
return WicketUtils.newRepositoryParameter(repositoryName);
--
Gitblit v1.9.1