]> source.dussan.org Git - gitblit.git/commitdiff
Show indicators for Sparkleshared repositories
authorJames Moger <james.moger@gitblit.com>
Sat, 12 Jan 2013 04:53:32 +0000 (23:53 -0500)
committerJames Moger <james.moger@gitblit.com>
Sat, 12 Jan 2013 04:53:32 +0000 (23:53 -0500)
19 files changed:
build.xml
resources/folder_star_16x16.png [new file with mode: 0644]
resources/folder_star_32x32.png [new file with mode: 0644]
resources/star_16x16.png [new file with mode: 0644]
resources/star_32x32.png [new file with mode: 0644]
src/com/gitblit/GitBlit.java
src/com/gitblit/PagesServlet.java
src/com/gitblit/client/IndicatorsRenderer.java
src/com/gitblit/models/RepositoryModel.java
src/com/gitblit/utils/IssueUtils.java
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/pages/RawPage.java
src/com/gitblit/wicket/pages/RepositoryPage.html
src/com/gitblit/wicket/pages/RepositoryPage.java
src/com/gitblit/wicket/panels/ProjectRepositoryPanel.html
src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
src/com/gitblit/wicket/panels/RepositoriesPanel.html
src/com/gitblit/wicket/panels/RepositoriesPanel.java

index 008859792855ac6664343c733e703a01429ce847..200fc91c107451db5da3c7c18d76a94b2e5fce3d 100644 (file)
--- a/build.xml
+++ b/build.xml
                        <resource file="${basedir}/resources/commit_changes_16x16.png" />\r
                        <resource file="${basedir}/resources/commit_merge_16x16.png" />\r
                        <resource file="${basedir}/resources/commit_divide_16x16.png" />\r
+                       <resource file="${basedir}/resources/star_16x16.png" />\r
                        <resource file="${basedir}/resources/blank.png" />\r
                        <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp.properties" />\r
                        <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_es.properties" />\r
                        <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_ja.properties" />\r
                        <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_ko.properties" />\r
+                       <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_nl.properties" />\r
                        <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_pl.properties" />\r
+                       <resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_pt_BR.properties" />\r
 \r
                        <class name="com.gitblit.client.GitblitManagerLauncher" />\r
                        <classfilter>\r
diff --git a/resources/folder_star_16x16.png b/resources/folder_star_16x16.png
new file mode 100644 (file)
index 0000000..ae8fded
Binary files /dev/null and b/resources/folder_star_16x16.png differ
diff --git a/resources/folder_star_32x32.png b/resources/folder_star_32x32.png
new file mode 100644 (file)
index 0000000..d2a076a
Binary files /dev/null and b/resources/folder_star_32x32.png differ
diff --git a/resources/star_16x16.png b/resources/star_16x16.png
new file mode 100644 (file)
index 0000000..883e4de
Binary files /dev/null and b/resources/star_16x16.png differ
diff --git a/resources/star_32x32.png b/resources/star_32x32.png
new file mode 100644 (file)
index 0000000..92865b1
Binary files /dev/null and b/resources/star_32x32.png differ
index 489ba63ca60c59b9ae6b90db9794651c4aa529bb..f417b3eb8707b3402be3b30b691c83fee66983f4 100644 (file)
@@ -1715,6 +1715,7 @@ public class GitBlit implements ServletContextListener {
                }\r
                model.HEAD = JGitUtils.getHEADRef(r);\r
                model.availableRefs = JGitUtils.getAvailableHeadTargets(r);\r
+               model.sparkleshareId = JGitUtils.getSparkleshareId(r);\r
                r.close();\r
                \r
                if (model.origin != null && model.origin.startsWith("file://")) {\r
index ad9276b4cbd5a1bf5dcb93938024edc39b811a6a..91f25b70de2c7fd8ff702ae5bba80b5c234316c5 100644 (file)
@@ -170,7 +170,7 @@ public class PagesServlet extends HttpServlet {
                                                content = JGitUtils.getStringContent(r, tree, resource, encodings).getBytes(\r
                                                                Constants.ENCODING);\r
                                        } else {\r
-                                               content = JGitUtils.getByteContent(r, tree, resource);\r
+                                               content = JGitUtils.getByteContent(r, tree, resource, false);\r
                                        }\r
                                        response.setContentType(contentType);\r
                                } catch (Exception e) {\r
index 59ce6dd1675296598089455b2cd5963d038a711c..44b39d01f21440a7dfd84cfd9013905984121d97 100644 (file)
@@ -55,6 +55,8 @@ public class IndicatorsRenderer extends JPanel implements TableCellRenderer, Ser
        private final ImageIcon federatedIcon;\r
        \r
        private final ImageIcon forkIcon;\r
+       \r
+       private final ImageIcon sparkleshareIcon;\r
 \r
        public IndicatorsRenderer() {\r
                super(new FlowLayout(FlowLayout.RIGHT, 1, 0));\r
@@ -67,6 +69,7 @@ public class IndicatorsRenderer extends JPanel implements TableCellRenderer, Ser
                frozenIcon = new ImageIcon(getClass().getResource("/cold_16x16.png"));\r
                federatedIcon = new ImageIcon(getClass().getResource("/federated_16x16.png"));\r
                forkIcon = new ImageIcon(getClass().getResource("/commit_divide_16x16.png"));\r
+               sparkleshareIcon = new ImageIcon(getClass().getResource("/star_16x16.png"));\r
        }\r
 \r
        @Override\r
@@ -80,6 +83,11 @@ public class IndicatorsRenderer extends JPanel implements TableCellRenderer, Ser
                if (value instanceof RepositoryModel) {\r
                        StringBuilder tooltip = new StringBuilder();\r
                        RepositoryModel model = (RepositoryModel) value;\r
+                       if (model.isSparkleshared()) {\r
+                               JLabel icon = new JLabel(sparkleshareIcon);\r
+                               tooltip.append(Translation.get("gb.isSparkleshared")).append("<br/>");\r
+                               add(icon);\r
+                       }\r
                        if (model.isFork()) {\r
                                JLabel icon = new JLabel(forkIcon);\r
                                tooltip.append(Translation.get("gb.isFork")).append("<br/>");\r
index 5be33a2d9612c01be20ac888a44cf2156539011d..022fd2005f8111f8200008522acbd9ebe37a38fd 100644 (file)
@@ -82,6 +82,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
        \r
        public transient boolean isCollectingGarbage;\r
        public Date lastGC;\r
+       public String sparkleshareId;\r
        \r
        public RepositoryModel() {\r
                this("", "", "", new Date(0));\r
@@ -176,6 +177,10 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
                return !accessRestriction.atLeast(AccessRestrictionType.VIEW);\r
        }\r
        \r
+       public boolean isSparkleshared() {\r
+               return !StringUtils.isEmpty(sparkleshareId);\r
+       }\r
+       \r
        public RepositoryModel cloneAs(String cloneName) {\r
                RepositoryModel clone = new RepositoryModel();\r
                clone.originRepository = name;\r
@@ -193,6 +198,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
                clone.useTickets = useTickets;\r
                clone.skipSizeCalculation = skipSizeCalculation;\r
                clone.skipSummaryMetrics = skipSummaryMetrics;\r
+               clone.sparkleshareId = sparkleshareId; \r
                return clone;\r
        }\r
 }
\ No newline at end of file
index 1b90c7d6ad1f517aca101d9a2f85b7bdaab3488e..dd09235bed651cd235abb65a41f0bebb699b535f 100644 (file)
@@ -380,7 +380,7 @@ public class IssueUtils {
                String issuePath = getIssuePath(issueId);\r
                RevTree tree = JGitUtils.getCommit(repository, GB_ISSUES).getTree();\r
                byte[] content = JGitUtils\r
-                               .getByteContent(repository, tree, issuePath + "/" + attachment.id);\r
+                               .getByteContent(repository, tree, issuePath + "/" + attachment.id, false);\r
                attachment.content = content;\r
                attachment.size = content.length;\r
                return attachment;\r
index 099036e537deb373fdb1d1335b8a58b568b55c82..e11277086bf5ef6746391857d940cb5bdc53368c 100644 (file)
@@ -537,7 +537,7 @@ public class JGitUtils {
         * @param path\r
         * @return content as a byte []\r
         */\r
-       public static byte[] getByteContent(Repository repository, RevTree tree, final String path) {\r
+       public static byte[] getByteContent(Repository repository, RevTree tree, final String path, boolean throwError) {\r
                RevWalk rw = new RevWalk(repository);\r
                TreeWalk tw = new TreeWalk(repository);\r
                tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));\r
@@ -572,7 +572,9 @@ public class JGitUtils {
                                }\r
                        }\r
                } catch (Throwable t) {\r
-                       error(t, repository, "{0} can't find {1} in tree {2}", path, tree.name());\r
+                       if (throwError) {\r
+                               error(t, repository, "{0} can't find {1} in tree {2}", path, tree.name());\r
+                       }\r
                } finally {\r
                        rw.dispose();\r
                        tw.release();\r
@@ -591,7 +593,7 @@ public class JGitUtils {
         * @return UTF-8 string content\r
         */\r
        public static String getStringContent(Repository repository, RevTree tree, String blobPath, String... charsets) {\r
-               byte[] content = getByteContent(repository, tree, blobPath);\r
+               byte[] content = getByteContent(repository, tree, blobPath, true);\r
                if (content == null) {\r
                        return null;\r
                }\r
@@ -1584,7 +1586,7 @@ public class JGitUtils {
         */\r
        public static List<SubmoduleModel> getSubmodules(Repository repository, RevTree tree) {\r
                List<SubmoduleModel> list = new ArrayList<SubmoduleModel>();\r
-               byte [] blob = getByteContent(repository, tree, ".gitmodules");\r
+               byte [] blob = getByteContent(repository, tree, ".gitmodules", false);\r
                if (blob == null) {\r
                        return list;\r
                }\r
@@ -1734,4 +1736,18 @@ public class JGitUtils {
                }\r
                return success;\r
        }\r
+       \r
+       /**\r
+        * Reads the sparkleshare id, if present, from the repository.\r
+        * \r
+        * @param repository\r
+        * @return an id or null\r
+        */\r
+       public static String getSparkleshareId(Repository repository) {\r
+               byte[] content = getByteContent(repository, null, ".sparkleshare", false);\r
+               if (content == null) {\r
+                       return null;\r
+               }\r
+               return StringUtils.decodeString(content);\r
+       }\r
 }\r
index 16f7641185bdca6268268528d8c07f42b757bfb0..dfdf70c2f31db8f34214abcae8791b47ef1d484c 100644 (file)
@@ -440,4 +440,5 @@ gb.sslCertificateGeneratedRestart = Successfully generated new server SSL certif
 gb.validity = validity\r
 gb.siteName = site name\r
 gb.siteNameDescription = short, descriptive name of your server \r
-gb.excludeFromActivity = exclude from activity page
\ No newline at end of file
+gb.excludeFromActivity = exclude from activity page\r
+gb.isSparkleshared = repository is Sparkleshared
\ No newline at end of file
index 7f6ed139074e42c22fec4871e398026c1c50f7e9..28e8bae29dc005cb5d39b3fcf8ae109af4396e4a 100644 (file)
@@ -109,7 +109,7 @@ public class RawPage extends WebPage {
                                                switch (type) {\r
                                                case 2:\r
                                                        // image blobs\r
-                                                       byte[] image = JGitUtils.getByteContent(r, commit.getTree(), blobPath);\r
+                                                       byte[] image = JGitUtils.getByteContent(r, commit.getTree(), blobPath, true);\r
                                                        response.setContentType("image/" + extension.toLowerCase());\r
                                                        response.setContentLength(image.length);\r
                                                        try {\r
@@ -120,7 +120,7 @@ public class RawPage extends WebPage {
                                                        break;\r
                                                case 3:\r
                                                        // binary blobs (download)\r
-                                                       byte[] binary = JGitUtils.getByteContent(r, commit.getTree(), blobPath);\r
+                                                       byte[] binary = JGitUtils.getByteContent(r, commit.getTree(), blobPath, true);\r
                                                        response.setContentLength(binary.length);\r
                                                        response.setContentType("application/octet-stream");\r
                                                        response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");\r
index 63a894dad320ae265e1eada55c1dc69fdac07814..d49f0188fa516ee640c68e544b851dd4ae365c25 100644 (file)
@@ -52,7 +52,7 @@
                                                </div>\r
                                        </div>\r
                                        <div class="span7">\r
-                                               <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>\r
+                                               <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>\r
                                                <span wicket:id="originRepository">[origin repository]</span>\r
                                        </div>\r
                                </div>\r
index aac527d7c513f042830a4d493a3b8eb64f491eb8..16087fa6e4e38f15d48b8de9846c7d368587707c 100644 (file)
@@ -246,6 +246,14 @@ public abstract class RepositoryPage extends BasePage {
                        }\r
                }\r
                \r
+               // show sparkleshare folder icon\r
+               if (model.isSparkleshared()) {\r
+                       add(WicketUtils.newImage("repositoryIcon", "folder_star_32x32.png",\r
+                                       getString("gb.isSparkleshared")));\r
+               } else {\r
+                       add(WicketUtils.newClearPixel("repositoryIcon").setVisible(false));\r
+               }\r
+               \r
                if (getRepositoryModel().isBare) {\r
                        add(new Label("workingCopyIndicator").setVisible(false));\r
                } else {\r
index 46781536ffb10efce08ca4e842391266b5980d51..9b621d5a32917c73df6badbea30104035fc3b131 100644 (file)
@@ -38,6 +38,7 @@
                        <div class="pull-right" style="text-align:right;padding-right:15px;">\r
                                <span wicket:id="repositoryLinks"></span>\r
                                <div>\r
+                                       <img class="inlineIcon" wicket:id="sparkleshareIcon" />\r
                                        <img class="inlineIcon" wicket:id="frozenIcon" />\r
                                        <img class="inlineIcon" wicket:id="federatedIcon" />\r
                                                        \r
index 50f0d52d2aefebe7b8d3d3fa4a0b76a5821071af..3c9bf7f03be4de178b2f74f93a3c222b2ded5f25 100644 (file)
@@ -87,6 +87,12 @@ public class ProjectRepositoryPanel extends BasePanel {
                        add(forkFrag);\r
                }\r
 \r
+               if (entry.isSparkleshared()) {\r
+                       add(WicketUtils.newImage("sparkleshareIcon", "star_16x16.png", localizer.getString("gb.isSparkleshared", parent)));\r
+               } else {\r
+                       add(WicketUtils.newClearPixel("sparkleshareIcon").setVisible(false));\r
+               }\r
+\r
                add(new BookmarkablePageLink<Void>("tickets", TicketsPage.class, pp).setVisible(entry.useTickets));\r
                add(new BookmarkablePageLink<Void>("docs", DocsPage.class, pp).setVisible(entry.useDocs));\r
 \r
index 42f9f1f2a399be68eff1003a756f76b16d507ccd..81a4c6eb77b92db1c8e7736db9b36bccb6245e5c 100644 (file)
@@ -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>\r
         <td class="hidden-phone"><span class="list" wicket:id="repositoryDescription">[repository description]</span></td>\r
         <td class="hidden-tablet hidden-phone author"><span wicket:id="repositoryOwner">[repository owner]</span></td>\r
-        <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>\r
+        <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>\r
         <td><span wicket:id="repositoryLastChange">[last change]</span></td>\r
         <td class="hidden-phone" style="text-align: right;padding-right:15px;"><span style="font-size:0.8em;" wicket:id="repositorySize">[repository size]</span></td>\r
         <td class="rightAlign">\r
index 976c517f0350b0ffc645ec61a33e3c26ce781747..ee5edfce0f1cfc3d2acbdcfd67e514a723e54a56 100644 (file)
@@ -233,6 +233,13 @@ public class RepositoriesPanel extends BasePanel {
                                                        .setEscapeModelStrings(false));\r
                                }\r
 \r
+                               if (entry.isSparkleshared()) {\r
+                                       row.add(WicketUtils.newImage("sparkleshareIcon", "star_16x16.png",\r
+                                                       getString("gb.isSparkleshared")));\r
+                               } else {\r
+                                       row.add(WicketUtils.newClearPixel("sparkleshareIcon").setVisible(false));\r
+                               }\r
+                               \r
                                if (entry.isFork()) {\r
                                        row.add(WicketUtils.newImage("forkIcon", "commit_divide_16x16.png",\r
                                                        getString("gb.isFork")));\r