James Moger
2013-01-11 e4e68298c2f55c93dc2464e26a24b119a649e642
Show indicators for Sparkleshared repositories
4 files added
15 files modified
79 ■■■■ changed files
build.xml 3 ●●●●● patch | view | raw | blame | history
resources/folder_star_16x16.png patch | view | raw | blame | history
resources/folder_star_32x32.png patch | view | raw | blame | history
resources/star_16x16.png patch | view | raw | blame | history
resources/star_32x32.png patch | view | raw | blame | history
src/com/gitblit/GitBlit.java 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/PagesServlet.java 2 ●●● patch | view | raw | blame | history
src/com/gitblit/client/IndicatorsRenderer.java 8 ●●●●● patch | view | raw | blame | history
src/com/gitblit/models/RepositoryModel.java 6 ●●●●● patch | view | raw | blame | history
src/com/gitblit/utils/IssueUtils.java 2 ●●● patch | view | raw | blame | history
src/com/gitblit/utils/JGitUtils.java 24 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/GitBlitWebApp.properties 3 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/RawPage.java 4 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/RepositoryPage.html 2 ●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/RepositoryPage.java 8 ●●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/panels/ProjectRepositoryPanel.html 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java 6 ●●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/panels/RepositoriesPanel.html 2 ●●● patch | view | raw | blame | history
src/com/gitblit/wicket/panels/RepositoriesPanel.java 7 ●●●●● patch | view | raw | blame | history
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>
resources/folder_star_16x16.png
resources/folder_star_32x32.png
resources/star_16x16.png
resources/star_32x32.png
src/com/gitblit/GitBlit.java
@@ -1715,6 +1715,7 @@
        }
        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://")) {
src/com/gitblit/PagesServlet.java
@@ -170,7 +170,7 @@
                        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) {
src/com/gitblit/client/IndicatorsRenderer.java
@@ -55,6 +55,8 @@
    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 @@
        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 @@
        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/>");
src/com/gitblit/models/RepositoryModel.java
@@ -82,6 +82,7 @@
    
    public transient boolean isCollectingGarbage;
    public Date lastGC;
    public String sparkleshareId;
    
    public RepositoryModel() {
        this("", "", "", new Date(0));
@@ -176,6 +177,10 @@
        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 @@
        clone.useTickets = useTickets;
        clone.skipSizeCalculation = skipSizeCalculation;
        clone.skipSummaryMetrics = skipSummaryMetrics;
        clone.sparkleshareId = sparkleshareId;
        return clone;
    }
}
src/com/gitblit/utils/IssueUtils.java
@@ -380,7 +380,7 @@
        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;
src/com/gitblit/utils/JGitUtils.java
@@ -537,7 +537,7 @@
     * @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 @@
                }
            }
        } 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 @@
     * @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 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 @@
        }
        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);
    }
}
src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -440,4 +440,5 @@
gb.validity = validity
gb.siteName = site name
gb.siteNameDescription = short, descriptive name of your server 
gb.excludeFromActivity = exclude from activity page
gb.excludeFromActivity = exclude from activity page
gb.isSparkleshared = repository is Sparkleshared
src/com/gitblit/wicket/pages/RawPage.java
@@ -109,7 +109,7 @@
                        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 @@
                            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 + "\"");
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>
src/com/gitblit/wicket/pages/RepositoryPage.java
@@ -246,6 +246,14 @@
            }
        }
        
        // 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 {
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" />
                                
src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java
@@ -87,6 +87,12 @@
            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));
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">
src/com/gitblit/wicket/panels/RepositoriesPanel.java
@@ -233,6 +233,13 @@
                            .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")));