summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/wicket/panels
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/gitblit/wicket/panels')
-rw-r--r--src/main/java/com/gitblit/wicket/panels/GravatarImage.java14
-rw-r--r--src/main/java/com/gitblit/wicket/panels/PushesPanel.html37
-rw-r--r--src/main/java/com/gitblit/wicket/panels/PushesPanel.java206
-rw-r--r--src/main/java/com/gitblit/wicket/panels/RefsPanel.java4
-rw-r--r--src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.html27
-rw-r--r--src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java48
-rw-r--r--src/main/java/com/gitblit/wicket/panels/TagsPanel.java4
7 files changed, 328 insertions, 12 deletions
diff --git a/src/main/java/com/gitblit/wicket/panels/GravatarImage.java b/src/main/java/com/gitblit/wicket/panels/GravatarImage.java
index 7f1874f2..80dbddba 100644
--- a/src/main/java/com/gitblit/wicket/panels/GravatarImage.java
+++ b/src/main/java/com/gitblit/wicket/panels/GravatarImage.java
@@ -50,22 +50,28 @@ public class GravatarImage extends Panel {
}
public GravatarImage(String id, PersonIdent person, int width, boolean linked) {
+ this(id, person.getName(), person.getEmailAddress(), "gravatar", width, linked);
+ }
+
+ public GravatarImage(String id, String username, String emailaddress, String cssClass, int width, boolean linked) {
super(id);
- String email = person.getEmailAddress() == null ? person.getName().toLowerCase() : person.getEmailAddress().toLowerCase();
+ String email = emailaddress == null ? username.toLowerCase() : emailaddress.toLowerCase();
String hash = StringUtils.getMD5(email);
Link<Void> link = new BookmarkablePageLink<Void>("link", GravatarProfilePage.class,
WicketUtils.newObjectParameter(hash));
link.add(new SimpleAttributeModifier("target", "_blank"));
String url = ActivityUtils.getGravatarThumbnailUrl(email, width);
ExternalImage image = new ExternalImage("image", url);
- WicketUtils.setCssClass(image, "gravatar");
+ if (cssClass != null) {
+ WicketUtils.setCssClass(image, cssClass);
+ }
link.add(image);
if (linked) {
WicketUtils.setHtmlTooltip(link,
- MessageFormat.format("View Gravatar profile for {0}", person.getName()));
+ MessageFormat.format("View Gravatar profile for {0}", username));
} else {
- WicketUtils.setHtmlTooltip(link, person.getName());
+ WicketUtils.setHtmlTooltip(link, username);
}
add(link.setEnabled(linked));
setVisible(GitBlit.getBoolean(Keys.web.allowGravatar, true));
diff --git a/src/main/java/com/gitblit/wicket/panels/PushesPanel.html b/src/main/java/com/gitblit/wicket/panels/PushesPanel.html
new file mode 100644
index 00000000..5bdc30a5
--- /dev/null
+++ b/src/main/java/com/gitblit/wicket/panels/PushesPanel.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"
+ xml:lang="en"
+ lang="en">
+
+<body>
+<wicket:panel>
+<div wicket:id="push">
+ <table style="padding: 3px 0px;">
+ <tr>
+ <td class="hidden-phone" style="vertical-align: top;"><span wicket:id="whoAvatar"></span></td>
+ <td style="padding-left: 7px;">
+ <div><span wicket:id="whoPushed">[pusher]</span> <span wicket:id="whatPushed"></span><span wicket:id="wherePushed"></span></div>
+ <div wicket:id="whenPushed"></div>
+ <button type="button" class="btn btn-mini" style="padding: 1px 3px;line-height: 12px;" data-toggle="collapse" data-target="#demo"><span class="caret"></span></button>
+ <div id="demo" class="collapse">
+ <div style="padding: 10px 0px;">
+ <table>
+ <tr wicket:id="commit" style="border-left: 1px solid #ddd;">
+ <td style="vertical-align:top;"><span wicket:id="hashLink" style="padding-left: 10px;">[hash link]</span></td>
+ <td><img wicket:id="commitIcon" /></td>
+ <td style="vertical-align:top;">
+ <div wicket:id="commitShortMessage">[commit short message]</div>
+ <div wicket:id="commitRefs">[commit refs]</div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+</div>
+</wicket:panel>
+</body>
+</html> \ No newline at end of file
diff --git a/src/main/java/com/gitblit/wicket/panels/PushesPanel.java b/src/main/java/com/gitblit/wicket/panels/PushesPanel.java
new file mode 100644
index 00000000..bab9c9e9
--- /dev/null
+++ b/src/main/java/com/gitblit/wicket/panels/PushesPanel.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.wicket.panels;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.Constants;
+import com.gitblit.GitBlit;
+import com.gitblit.Keys;
+import com.gitblit.models.PushLogEntry;
+import com.gitblit.models.RepositoryCommit;
+import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.UserModel;
+import com.gitblit.utils.PushLogUtils;
+import com.gitblit.utils.StringUtils;
+import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.pages.CommitPage;
+import com.gitblit.wicket.pages.GitSearchPage;
+import com.gitblit.wicket.pages.SummaryPage;
+import com.gitblit.wicket.pages.UserPage;
+
+public class PushesPanel extends BasePanel {
+
+ private static final long serialVersionUID = 1L;
+
+ private final boolean hasPushes;
+
+ private boolean hasMore;
+
+ public PushesPanel(String wicketId, final RepositoryModel model, Repository r, int limit, int pageOffset) {
+ super(wicketId);
+ boolean pageResults = limit <= 0;
+ int itemsPerPage = GitBlit.getInteger(Keys.web.itemsPerPage, 50);
+ if (itemsPerPage <= 1) {
+ itemsPerPage = 50;
+ }
+
+ final Map<String, String> usernameLookup = new HashMap<String, String>();
+ final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);
+ List<PushLogEntry> entries = PushLogUtils.getPushLog(model.name, r, limit);
+ // establish pusher identities
+ for (PushLogEntry push : entries) {
+ // handle push logs with email address instead of account name
+ String username = push.user.username;
+ if (push.user.username.indexOf('@') > -1) {
+ // push username is an email address, reverse lookup for account
+ if (!usernameLookup.containsKey(push.user.username)) {
+ for (UserModel user : GitBlit.self().getAllUsers()) {
+ if (push.user.username.equals(user.emailAddress)) {
+ username = user.username;
+ usernameLookup.put(push.user.username, username);
+ break;
+ }
+ }
+ } else {
+ username = usernameLookup.get(push.user.username);
+ }
+ } else {
+ // push username is an account name, lookup for email address
+ if (!usernameLookup.containsKey(push.user.username)) {
+ UserModel user = GitBlit.self().getUserModel(push.user.username);
+ if (user != null) {
+ push.user.emailAddress = user.emailAddress;
+ usernameLookup.put(push.user.username, user.emailAddress);
+ }
+ } else {
+ push.user.emailAddress = usernameLookup.get(push.user.username);
+ }
+ }
+ }
+
+ hasPushes = entries.size() > 0;
+
+ ListDataProvider<PushLogEntry> dp = new ListDataProvider<PushLogEntry>(entries);
+ DataView<PushLogEntry> pushView = new DataView<PushLogEntry>("push", dp) {
+ private static final long serialVersionUID = 1L;
+
+ public void populateItem(final Item<PushLogEntry> pushItem) {
+ final PushLogEntry push = pushItem.getModelObject();
+
+
+ pushItem.add(new GravatarImage("whoAvatar", push.getCommitterIdent(), 40));
+ pushItem.add(new LinkPanel("whoPushed", null, push.user.getDisplayName(),
+ UserPage.class, WicketUtils.newUsernameParameter(push.user.username)));
+ pushItem.add(new Label("whatPushed",
+ MessageFormat.format(push.getCommitCount() > 1 ? "pushed {0} commits to":"pushed 1 commit to", push.getCommitCount())));
+ String repoName = StringUtils.stripDotGit(model.name);
+ pushItem.add(new LinkPanel("wherePushed", null, repoName,
+ SummaryPage.class, WicketUtils.newRepositoryParameter(model.name)));
+ pushItem.add(WicketUtils.createDateLabel("whenPushed", push.date, getTimeZone(), getTimeUtils()));
+
+ ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(push.getCommits());
+ DataView<RepositoryCommit> commitsView = new DataView<RepositoryCommit>("commit", cdp) {
+ private static final long serialVersionUID = 1L;
+
+ public void populateItem(final Item<RepositoryCommit> commitItem) {
+ final RepositoryCommit commit = commitItem.getModelObject();
+
+ // author search link
+ String author = commit.getAuthorIdent().getName();
+ LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author,
+ GitSearchPage.class, WicketUtils.newSearchParameter(model.name,
+ null, author, Constants.SearchType.AUTHOR));
+ setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);
+ commitItem.add(authorLink);
+
+ // merge icon
+ if (commit.getParentCount() > 1) {
+ commitItem.add(WicketUtils.newImage("commitIcon", "commit_merge_16x16.png"));
+ } else {
+ commitItem.add(WicketUtils.newBlankImage("commitIcon"));
+ }
+
+ // short message
+ String shortMessage = commit.getShortMessage();
+ String trimmedMessage = shortMessage;
+ if (commit.getRefs() != null && commit.getRefs().size() > 0) {
+ trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS);
+ } else {
+ trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG);
+ }
+ LinkPanel shortlog = new LinkPanel("commitShortMessage", "list",
+ trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(
+ model.name, commit.getName()));
+ if (!shortMessage.equals(trimmedMessage)) {
+ WicketUtils.setHtmlTooltip(shortlog, shortMessage);
+ }
+ commitItem.add(shortlog);
+
+ commitItem.add(new RefsPanel("commitRefs", commit.repository, commit.getRefs()));
+
+ // commit hash link
+ LinkPanel commitHash = new LinkPanel("hashLink", null, commit.getName().substring(0, hashLen),
+ CommitPage.class, WicketUtils.newObjectParameter(
+ model.name, commit.getName()));
+ WicketUtils.setCssClass(commitHash, "shortsha1");
+ WicketUtils.setHtmlTooltip(commitHash, commit.getName());
+ commitItem.add(commitHash);
+
+// item.add(new BookmarkablePageLink<Void>("diff", CommitDiffPage.class, WicketUtils
+// .newObjectParameter(repositoryName, entry.getName())).setEnabled(entry
+// .getParentCount() > 0));
+// item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+// .newObjectParameter(repositoryName, entry.getName())));
+ }
+ };
+
+ pushItem.add(commitsView);
+ }
+ };
+ add(pushView);
+
+ // determine to show pager, more, or neither
+// if (limit <= 0) {
+// // no display limit
+// add(new Label("moreLogs", "").setVisible(false));
+// } else {
+// if (pageResults) {
+// // paging
+// add(new Label("moreLogs", "").setVisible(false));
+// } else {
+// // more
+// if (commits.size() == limit) {
+// // 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));
+// }
+// }
+// }
+ }
+
+ public boolean hasMore() {
+ return hasMore;
+ }
+
+ public boolean hideIfEmpty() {
+ setVisible(hasPushes);
+ return hasPushes;
+ }
+}
diff --git a/src/main/java/com/gitblit/wicket/panels/RefsPanel.java b/src/main/java/com/gitblit/wicket/panels/RefsPanel.java
index c3807ac2..5776a13e 100644
--- a/src/main/java/com/gitblit/wicket/panels/RefsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/RefsPanel.java
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.Item;
@@ -35,7 +36,6 @@ import com.gitblit.models.RefModel;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.CommitPage;
import com.gitblit.wicket.pages.LogPage;
-import com.gitblit.wicket.pages.RepositoryPage;
import com.gitblit.wicket.pages.TagPage;
public class RefsPanel extends Panel {
@@ -99,7 +99,7 @@ public class RefsPanel extends Panel {
String name = entry.displayName;
String objectid = entry.getReferencedObjectId().getName();
boolean breakLine = false;
- Class<? extends RepositoryPage> linkClass = CommitPage.class;
+ Class<? extends WebPage> linkClass = CommitPage.class;
String cssClass = "";
if (name.startsWith(Constants.R_HEADS)) {
// local branch
diff --git a/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.html b/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.html
index ec5b4a44..4b28e71c 100644
--- a/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.html
+++ b/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.html
@@ -8,22 +8,29 @@
<div wicket:id="repositoryUrlPanel"></div>
<div wicket:id="applicationMenusPanel"></div>
-
+ <div wicket:id="repositoryIndicators"></div>
<wicket:fragment wicket:id="repositoryUrlFragment">
<div class="btn-toolbar" style="margin: 0px;">
<div class="btn-group repositoryUrlContainer">
<img style="vertical-align: middle;padding: 0px 0px 1px 3px;" wicket:id="accessRestrictionIcon"></img>
<span wicket:id="menu"></span>
- <span class="repositoryUrl">
+ <div class="repositoryUrl">
<span wicket:id="primaryUrl">[repository primary url]</span>
<span class="hidden-phone hidden-tablet" wicket:id="copyFunction"></span>
- </span>
+ </div>
<span class="hidden-phone hidden-tablet repositoryUrlRightCap" wicket:id="primaryUrlPermission">[repository primary url permission]</span>
</div>
</div>
</wicket:fragment>
+ <wicket:fragment wicket:id="indicatorsFragment">
+ <div>
+ <div wicket:id="workingCopyIndicator"></div>
+ <div wicket:id="forksProhibitedIndicator"></div>
+ </div>
+ </wicket:fragment>
+
<wicket:fragment wicket:id="applicationMenusFragment">
<div class="btn-toolbar" style="margin: 4px 0px 0px 0px;">
<div class="btn-group" wicket:id="appMenus">
@@ -90,6 +97,18 @@
scale="noscale"
allowScriptAccess="always"></object>
</wicket:fragment>
-
+
+ <wicket:fragment wicket:id="workingCopyFragment">
+ <div class="repositoryIndicator">
+ <span class="alert alert-info"><i class="icon-exclamation-sign"></i>&nbsp;<span class="hidden-phone" wicket:id="workingCopy">[working copy]</span></span>
+ </div>
+ </wicket:fragment>
+
+ <wicket:fragment wicket:id="forksProhibitedFragment">
+ <div class="repositoryIndicator">
+ <span class="alert alert-error"><i class="icon-ban-circle"></i>&nbsp;<span class="hidden-phone" wicket:id="forksProhibited">[forks prohibited]</span></span>
+ </div>
+ </wicket:fragment>
+
</wicket:panel>
</html> \ No newline at end of file
diff --git a/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java b/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java
index 7f43d63c..b28599f3 100644
--- a/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java
@@ -91,12 +91,19 @@ public class RepositoryUrlPanel extends BasePanel {
// no urls, nothing to show.
add(new Label("repositoryUrlPanel").setVisible(false));
add(new Label("applicationMenusPanel").setVisible(false));
+ add(new Label("repositoryIndicators").setVisible(false));
return;
}
// display primary url
add(createPrimaryUrlPanel("repositoryUrlPanel", repository, repositoryUrls));
+ if (onlyUrls) {
+ add(new Label("repositoryIndicators").setVisible(false));
+ } else {
+ add(createRepositoryIndicators(repository));
+ }
+
boolean allowAppLinks = GitBlit.getBoolean(Keys.web.allowAppCloneLinks, true);
if (onlyUrls || !canClone || !allowAppLinks) {
// only display the url(s)
@@ -425,4 +432,45 @@ public class RepositoryUrlPanel extends BasePanel {
}
return accessRestrictionsMap;
}
+
+ protected Component createRepositoryIndicators(RepositoryModel repository) {
+ Fragment fragment = new Fragment("repositoryIndicators", "indicatorsFragment", this);
+ if (repository.isBare) {
+ fragment.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);
+ fragment.add(wc);
+ }
+
+ boolean allowForking = GitBlit.getBoolean(Keys.web.allowForking, true);
+ if (!allowForking || user == null || !user.isAuthenticated) {
+ // must be logged-in to fork, hide all fork controls
+ fragment.add(new Label("forksProhibitedIndicator").setVisible(false));
+ } else {
+ String fork = GitBlit.self().getFork(user.username, repository.name);
+ boolean hasFork = fork != null;
+ boolean canFork = user.canFork(repository);
+
+ if (hasFork || !canFork) {
+ if (user.canFork() && !repository.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);
+ fragment.add(wc);
+ } else {
+ // can not fork, no need for forks prohibited indicator
+ fragment.add(new Label("forksProhibitedIndicator").setVisible(false));
+ }
+ } else if (canFork) {
+ // can fork and we do not have one
+ fragment.add(new Label("forksProhibitedIndicator").setVisible(false));
+ }
+ }
+ return fragment;
+ }
}
diff --git a/src/main/java/com/gitblit/wicket/panels/TagsPanel.java b/src/main/java/com/gitblit/wicket/panels/TagsPanel.java
index 2bee6a60..907b3174 100644
--- a/src/main/java/com/gitblit/wicket/panels/TagsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/TagsPanel.java
@@ -17,6 +17,7 @@ package com.gitblit.wicket.panels;
import java.util.List;
+import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Fragment;
@@ -35,7 +36,6 @@ import com.gitblit.wicket.pages.BlobPage;
import com.gitblit.wicket.pages.CommitPage;
import com.gitblit.wicket.pages.LogPage;
import com.gitblit.wicket.pages.RawPage;
-import com.gitblit.wicket.pages.RepositoryPage;
import com.gitblit.wicket.pages.TagPage;
import com.gitblit.wicket.pages.TagsPage;
import com.gitblit.wicket.pages.TreePage;
@@ -71,7 +71,7 @@ public class TagsPanel extends BasePanel {
item.add(WicketUtils.createDateLabel("tagDate", entry.getDate(), getTimeZone(), getTimeUtils()));
- Class<? extends RepositoryPage> linkClass;
+ Class<? extends WebPage> linkClass;
switch (entry.getReferencedObjectType()) {
case Constants.OBJ_BLOB:
linkClass = BlobPage.class;