summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-01-11 23:53:32 -0500
committerJames Moger <james.moger@gitblit.com>2013-01-11 23:53:32 -0500
commite4e68298c2f55c93dc2464e26a24b119a649e642 (patch)
tree80f3094fb062fc26be705fd8f5c86fa03cc97aea
parent5316d20e861640867d10405b25cfe75aeca0a34c (diff)
downloadgitblit-e4e68298c2f55c93dc2464e26a24b119a649e642.tar.gz
gitblit-e4e68298c2f55c93dc2464e26a24b119a649e642.zip
Show indicators for Sparkleshared repositories
-rw-r--r--build.xml3
-rw-r--r--resources/folder_star_16x16.pngbin0 -> 830 bytes
-rw-r--r--resources/folder_star_32x32.pngbin0 -> 1529 bytes
-rw-r--r--resources/star_16x16.pngbin0 -> 611 bytes
-rw-r--r--resources/star_32x32.pngbin0 -> 1548 bytes
-rw-r--r--src/com/gitblit/GitBlit.java1
-rw-r--r--src/com/gitblit/PagesServlet.java2
-rw-r--r--src/com/gitblit/client/IndicatorsRenderer.java8
-rw-r--r--src/com/gitblit/models/RepositoryModel.java6
-rw-r--r--src/com/gitblit/utils/IssueUtils.java2
-rw-r--r--src/com/gitblit/utils/JGitUtils.java24
-rw-r--r--src/com/gitblit/wicket/GitBlitWebApp.properties3
-rw-r--r--src/com/gitblit/wicket/pages/RawPage.java4
-rw-r--r--src/com/gitblit/wicket/pages/RepositoryPage.html2
-rw-r--r--src/com/gitblit/wicket/pages/RepositoryPage.java8
-rw-r--r--src/com/gitblit/wicket/panels/ProjectRepositoryPanel.html1
-rw-r--r--src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java6
-rw-r--r--src/com/gitblit/wicket/panels/RepositoriesPanel.html2
-rw-r--r--src/com/gitblit/wicket/panels/RepositoriesPanel.java7
19 files changed, 68 insertions, 11 deletions
diff --git a/build.xml b/build.xml
index 00885979..200fc91c 100644
--- a/build.xml
+++ b/build.xml
@@ -717,12 +717,15 @@
<resource file="${basedir}/resources/commit_changes_16x16.png" />
<resource file="${basedir}/resources/commit_merge_16x16.png" />
<resource file="${basedir}/resources/commit_divide_16x16.png" />
+ <resource file="${basedir}/resources/star_16x16.png" />
<resource file="${basedir}/resources/blank.png" />
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp.properties" />
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_es.properties" />
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_ja.properties" />
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_ko.properties" />
+ <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_nl.properties" />
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_pl.properties" />
+ <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_pt_BR.properties" />
<class name="com.gitblit.client.GitblitManagerLauncher" />
<classfilter>
diff --git a/resources/folder_star_16x16.png b/resources/folder_star_16x16.png
new file mode 100644
index 00000000..ae8fdeda
--- /dev/null
+++ b/resources/folder_star_16x16.png
Binary files differ
diff --git a/resources/folder_star_32x32.png b/resources/folder_star_32x32.png
new file mode 100644
index 00000000..d2a076a9
--- /dev/null
+++ b/resources/folder_star_32x32.png
Binary files differ
diff --git a/resources/star_16x16.png b/resources/star_16x16.png
new file mode 100644
index 00000000..883e4dec
--- /dev/null
+++ b/resources/star_16x16.png
Binary files differ
diff --git a/resources/star_32x32.png b/resources/star_32x32.png
new file mode 100644
index 00000000..92865b19
--- /dev/null
+++ b/resources/star_32x32.png
Binary files differ
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 489ba63c..f417b3eb 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -1715,6 +1715,7 @@ public class GitBlit implements ServletContextListener {
}
model.HEAD = JGitUtils.getHEADRef(r);
model.availableRefs = JGitUtils.getAvailableHeadTargets(r);
+ model.sparkleshareId = JGitUtils.getSparkleshareId(r);
r.close();
if (model.origin != null && model.origin.startsWith("file://")) {
diff --git a/src/com/gitblit/PagesServlet.java b/src/com/gitblit/PagesServlet.java
index ad9276b4..91f25b70 100644
--- a/src/com/gitblit/PagesServlet.java
+++ b/src/com/gitblit/PagesServlet.java
@@ -170,7 +170,7 @@ public class PagesServlet extends HttpServlet {
content = JGitUtils.getStringContent(r, tree, resource, encodings).getBytes(
Constants.ENCODING);
} else {
- content = JGitUtils.getByteContent(r, tree, resource);
+ content = JGitUtils.getByteContent(r, tree, resource, false);
}
response.setContentType(contentType);
} catch (Exception e) {
diff --git a/src/com/gitblit/client/IndicatorsRenderer.java b/src/com/gitblit/client/IndicatorsRenderer.java
index 59ce6dd1..44b39d01 100644
--- a/src/com/gitblit/client/IndicatorsRenderer.java
+++ b/src/com/gitblit/client/IndicatorsRenderer.java
@@ -55,6 +55,8 @@ public class IndicatorsRenderer extends JPanel implements TableCellRenderer, Ser
private final ImageIcon federatedIcon;
private final ImageIcon forkIcon;
+
+ private final ImageIcon sparkleshareIcon;
public IndicatorsRenderer() {
super(new FlowLayout(FlowLayout.RIGHT, 1, 0));
@@ -67,6 +69,7 @@ public class IndicatorsRenderer extends JPanel implements TableCellRenderer, Ser
frozenIcon = new ImageIcon(getClass().getResource("/cold_16x16.png"));
federatedIcon = new ImageIcon(getClass().getResource("/federated_16x16.png"));
forkIcon = new ImageIcon(getClass().getResource("/commit_divide_16x16.png"));
+ sparkleshareIcon = new ImageIcon(getClass().getResource("/star_16x16.png"));
}
@Override
@@ -80,6 +83,11 @@ public class IndicatorsRenderer extends JPanel implements TableCellRenderer, Ser
if (value instanceof RepositoryModel) {
StringBuilder tooltip = new StringBuilder();
RepositoryModel model = (RepositoryModel) value;
+ if (model.isSparkleshared()) {
+ JLabel icon = new JLabel(sparkleshareIcon);
+ tooltip.append(Translation.get("gb.isSparkleshared")).append("<br/>");
+ add(icon);
+ }
if (model.isFork()) {
JLabel icon = new JLabel(forkIcon);
tooltip.append(Translation.get("gb.isFork")).append("<br/>");
diff --git a/src/com/gitblit/models/RepositoryModel.java b/src/com/gitblit/models/RepositoryModel.java
index 5be33a2d..022fd200 100644
--- a/src/com/gitblit/models/RepositoryModel.java
+++ b/src/com/gitblit/models/RepositoryModel.java
@@ -82,6 +82,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
public transient boolean isCollectingGarbage;
public Date lastGC;
+ public String sparkleshareId;
public RepositoryModel() {
this("", "", "", new Date(0));
@@ -176,6 +177,10 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
return !accessRestriction.atLeast(AccessRestrictionType.VIEW);
}
+ public boolean isSparkleshared() {
+ return !StringUtils.isEmpty(sparkleshareId);
+ }
+
public RepositoryModel cloneAs(String cloneName) {
RepositoryModel clone = new RepositoryModel();
clone.originRepository = name;
@@ -193,6 +198,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
clone.useTickets = useTickets;
clone.skipSizeCalculation = skipSizeCalculation;
clone.skipSummaryMetrics = skipSummaryMetrics;
+ clone.sparkleshareId = sparkleshareId;
return clone;
}
} \ No newline at end of file
diff --git a/src/com/gitblit/utils/IssueUtils.java b/src/com/gitblit/utils/IssueUtils.java
index 1b90c7d6..dd09235b 100644
--- a/src/com/gitblit/utils/IssueUtils.java
+++ b/src/com/gitblit/utils/IssueUtils.java
@@ -380,7 +380,7 @@ public class IssueUtils {
String issuePath = getIssuePath(issueId);
RevTree tree = JGitUtils.getCommit(repository, GB_ISSUES).getTree();
byte[] content = JGitUtils
- .getByteContent(repository, tree, issuePath + "/" + attachment.id);
+ .getByteContent(repository, tree, issuePath + "/" + attachment.id, false);
attachment.content = content;
attachment.size = content.length;
return attachment;
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index 099036e5..e1127708 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -537,7 +537,7 @@ public class JGitUtils {
* @param path
* @return content as a byte []
*/
- public static byte[] getByteContent(Repository repository, RevTree tree, final String path) {
+ public static byte[] getByteContent(Repository repository, RevTree tree, final String path, boolean throwError) {
RevWalk rw = new RevWalk(repository);
TreeWalk tw = new TreeWalk(repository);
tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
@@ -572,7 +572,9 @@ public class JGitUtils {
}
}
} catch (Throwable t) {
- error(t, repository, "{0} can't find {1} in tree {2}", path, tree.name());
+ if (throwError) {
+ error(t, repository, "{0} can't find {1} in tree {2}", path, tree.name());
+ }
} finally {
rw.dispose();
tw.release();
@@ -591,7 +593,7 @@ public class JGitUtils {
* @return UTF-8 string content
*/
public static String getStringContent(Repository repository, RevTree tree, String blobPath, String... charsets) {
- byte[] content = getByteContent(repository, tree, blobPath);
+ byte[] content = getByteContent(repository, tree, blobPath, true);
if (content == null) {
return null;
}
@@ -1584,7 +1586,7 @@ public class JGitUtils {
*/
public static List<SubmoduleModel> getSubmodules(Repository repository, RevTree tree) {
List<SubmoduleModel> list = new ArrayList<SubmoduleModel>();
- byte [] blob = getByteContent(repository, tree, ".gitmodules");
+ byte [] blob = getByteContent(repository, tree, ".gitmodules", false);
if (blob == null) {
return list;
}
@@ -1734,4 +1736,18 @@ public class JGitUtils {
}
return success;
}
+
+ /**
+ * Reads the sparkleshare id, if present, from the repository.
+ *
+ * @param repository
+ * @return an id or null
+ */
+ public static String getSparkleshareId(Repository repository) {
+ byte[] content = getByteContent(repository, null, ".sparkleshare", false);
+ if (content == null) {
+ return null;
+ }
+ return StringUtils.decodeString(content);
+ }
}
diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties
index 16f76411..dfdf70c2 100644
--- a/src/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -440,4 +440,5 @@ gb.sslCertificateGeneratedRestart = Successfully generated new server SSL certif
gb.validity = validity
gb.siteName = site name
gb.siteNameDescription = short, descriptive name of your server
-gb.excludeFromActivity = exclude from activity page \ No newline at end of file
+gb.excludeFromActivity = exclude from activity page
+gb.isSparkleshared = repository is Sparkleshared \ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/RawPage.java b/src/com/gitblit/wicket/pages/RawPage.java
index 7f6ed139..28e8bae2 100644
--- a/src/com/gitblit/wicket/pages/RawPage.java
+++ b/src/com/gitblit/wicket/pages/RawPage.java
@@ -109,7 +109,7 @@ public class RawPage extends WebPage {
switch (type) {
case 2:
// image blobs
- byte[] image = JGitUtils.getByteContent(r, commit.getTree(), blobPath);
+ byte[] image = JGitUtils.getByteContent(r, commit.getTree(), blobPath, true);
response.setContentType("image/" + extension.toLowerCase());
response.setContentLength(image.length);
try {
@@ -120,7 +120,7 @@ public class RawPage extends WebPage {
break;
case 3:
// binary blobs (download)
- byte[] binary = JGitUtils.getByteContent(r, commit.getTree(), blobPath);
+ byte[] binary = JGitUtils.getByteContent(r, commit.getTree(), blobPath, true);
response.setContentLength(binary.length);
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.html b/src/com/gitblit/wicket/pages/RepositoryPage.html
index 63a894da..d49f0188 100644
--- a/src/com/gitblit/wicket/pages/RepositoryPage.html
+++ b/src/com/gitblit/wicket/pages/RepositoryPage.html
@@ -52,7 +52,7 @@
</div>
</div>
<div class="span7">
- <div><span class="project" wicket:id="projectTitle">[project title]</span>/<span class="repository" wicket:id="repositoryName">[repository name]</span> <span class="hidden-phone"><span wicket:id="pageName">[page name]</span></span></div>
+ <div><span class="project" wicket:id="projectTitle">[project title]</span>/<img wicket:id="repositoryIcon" style="padding-left: 10px;"></img><span class="repository" wicket:id="repositoryName">[repository name]</span> <span class="hidden-phone"><span wicket:id="pageName">[page name]</span></span></div>
<span wicket:id="originRepository">[origin repository]</span>
</div>
</div>
diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java
index aac527d7..16087fa6 100644
--- a/src/com/gitblit/wicket/pages/RepositoryPage.java
+++ b/src/com/gitblit/wicket/pages/RepositoryPage.java
@@ -246,6 +246,14 @@ public abstract class RepositoryPage extends BasePage {
}
}
+ // 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 {
diff --git a/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.html b/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.html
index 46781536..9b621d5a 100644
--- a/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.html
+++ b/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.html
@@ -38,6 +38,7 @@
<div class="pull-right" style="text-align:right;padding-right:15px;">
<span wicket:id="repositoryLinks"></span>
<div>
+ <img class="inlineIcon" wicket:id="sparkleshareIcon" />
<img class="inlineIcon" wicket:id="frozenIcon" />
<img class="inlineIcon" wicket:id="federatedIcon" />
diff --git a/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java b/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
index 50f0d52d..3c9bf7f0 100644
--- a/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
+++ b/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
@@ -87,6 +87,12 @@ public class ProjectRepositoryPanel extends BasePanel {
add(forkFrag);
}
+ if (entry.isSparkleshared()) {
+ add(WicketUtils.newImage("sparkleshareIcon", "star_16x16.png", localizer.getString("gb.isSparkleshared", parent)));
+ } else {
+ add(WicketUtils.newClearPixel("sparkleshareIcon").setVisible(false));
+ }
+
add(new BookmarkablePageLink<Void>("tickets", TicketsPage.class, pp).setVisible(entry.useTickets));
add(new BookmarkablePageLink<Void>("docs", DocsPage.class, pp).setVisible(entry.useDocs));
diff --git a/src/com/gitblit/wicket/panels/RepositoriesPanel.html b/src/com/gitblit/wicket/panels/RepositoriesPanel.html
index 42f9f1f2..81a4c6eb 100644
--- a/src/com/gitblit/wicket/panels/RepositoriesPanel.html
+++ b/src/com/gitblit/wicket/panels/RepositoriesPanel.html
@@ -89,7 +89,7 @@
<td class="left" style="padding-left:3px;" ><b><span class="repositorySwatch" wicket:id="repositorySwatch"></span></b> <span style="padding-left:3px;" wicket:id="repositoryName">[repository name]</span></td>
<td class="hidden-phone"><span class="list" wicket:id="repositoryDescription">[repository description]</span></td>
<td class="hidden-tablet hidden-phone author"><span wicket:id="repositoryOwner">[repository owner]</span></td>
- <td class="hidden-phone" style="text-align: right;padding-right:10px;"><img class="inlineIcon" wicket:id="forkIcon" /><img class="inlineIcon" wicket:id="ticketsIcon" /><img class="inlineIcon" wicket:id="docsIcon" /><img class="inlineIcon" wicket:id="frozenIcon" /><img class="inlineIcon" wicket:id="federatedIcon" /><img class="inlineIcon" wicket:id="accessRestrictionIcon" /></td>
+ <td class="hidden-phone" style="text-align: right;padding-right:10px;"><img class="inlineIcon" wicket:id="sparkleshareIcon" /><img class="inlineIcon" wicket:id="forkIcon" /><img class="inlineIcon" wicket:id="ticketsIcon" /><img class="inlineIcon" wicket:id="docsIcon" /><img class="inlineIcon" wicket:id="frozenIcon" /><img class="inlineIcon" wicket:id="federatedIcon" /><img class="inlineIcon" wicket:id="accessRestrictionIcon" /></td>
<td><span wicket:id="repositoryLastChange">[last change]</span></td>
<td class="hidden-phone" style="text-align: right;padding-right:15px;"><span style="font-size:0.8em;" wicket:id="repositorySize">[repository size]</span></td>
<td class="rightAlign">
diff --git a/src/com/gitblit/wicket/panels/RepositoriesPanel.java b/src/com/gitblit/wicket/panels/RepositoriesPanel.java
index 976c517f..ee5edfce 100644
--- a/src/com/gitblit/wicket/panels/RepositoriesPanel.java
+++ b/src/com/gitblit/wicket/panels/RepositoriesPanel.java
@@ -233,6 +233,13 @@ public class RepositoriesPanel extends BasePanel {
.setEscapeModelStrings(false));
}
+ if (entry.isSparkleshared()) {
+ row.add(WicketUtils.newImage("sparkleshareIcon", "star_16x16.png",
+ getString("gb.isSparkleshared")));
+ } else {
+ row.add(WicketUtils.newClearPixel("sparkleshareIcon").setVisible(false));
+ }
+
if (entry.isFork()) {
row.add(WicketUtils.newImage("forkIcon", "commit_divide_16x16.png",
getString("gb.isFork")));