Sfoglia il codice sorgente

Show indicators for Sparkleshared repositories

tags/v1.2.1
James Moger 11 anni fa
parent
commit
e4e68298c2

+ 3
- 0
build.xml Vedi File

<resource file="${basedir}/resources/commit_changes_16x16.png" /> <resource file="${basedir}/resources/commit_changes_16x16.png" />
<resource file="${basedir}/resources/commit_merge_16x16.png" /> <resource file="${basedir}/resources/commit_merge_16x16.png" />
<resource file="${basedir}/resources/commit_divide_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}/resources/blank.png" />
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp.properties" /> <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_es.properties" />
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_ja.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_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_pl.properties" />
<resource file="${basedir}/src/com/gitblit/wicket/GitBlitWebApp_pt_BR.properties" />
<class name="com.gitblit.client.GitblitManagerLauncher" /> <class name="com.gitblit.client.GitblitManagerLauncher" />
<classfilter> <classfilter>

BIN
resources/folder_star_16x16.png Vedi File


BIN
resources/folder_star_32x32.png Vedi File


BIN
resources/star_16x16.png Vedi File


BIN
resources/star_32x32.png Vedi File


+ 1
- 0
src/com/gitblit/GitBlit.java Vedi File

} }
model.HEAD = JGitUtils.getHEADRef(r); model.HEAD = JGitUtils.getHEADRef(r);
model.availableRefs = JGitUtils.getAvailableHeadTargets(r); model.availableRefs = JGitUtils.getAvailableHeadTargets(r);
model.sparkleshareId = JGitUtils.getSparkleshareId(r);
r.close(); r.close();
if (model.origin != null && model.origin.startsWith("file://")) { if (model.origin != null && model.origin.startsWith("file://")) {

+ 1
- 1
src/com/gitblit/PagesServlet.java Vedi File

content = JGitUtils.getStringContent(r, tree, resource, encodings).getBytes( content = JGitUtils.getStringContent(r, tree, resource, encodings).getBytes(
Constants.ENCODING); Constants.ENCODING);
} else { } else {
content = JGitUtils.getByteContent(r, tree, resource);
content = JGitUtils.getByteContent(r, tree, resource, false);
} }
response.setContentType(contentType); response.setContentType(contentType);
} catch (Exception e) { } catch (Exception e) {

+ 8
- 0
src/com/gitblit/client/IndicatorsRenderer.java Vedi File

private final ImageIcon federatedIcon; private final ImageIcon federatedIcon;
private final ImageIcon forkIcon; private final ImageIcon forkIcon;
private final ImageIcon sparkleshareIcon;
public IndicatorsRenderer() { public IndicatorsRenderer() {
super(new FlowLayout(FlowLayout.RIGHT, 1, 0)); super(new FlowLayout(FlowLayout.RIGHT, 1, 0));
frozenIcon = new ImageIcon(getClass().getResource("/cold_16x16.png")); frozenIcon = new ImageIcon(getClass().getResource("/cold_16x16.png"));
federatedIcon = new ImageIcon(getClass().getResource("/federated_16x16.png")); federatedIcon = new ImageIcon(getClass().getResource("/federated_16x16.png"));
forkIcon = new ImageIcon(getClass().getResource("/commit_divide_16x16.png")); forkIcon = new ImageIcon(getClass().getResource("/commit_divide_16x16.png"));
sparkleshareIcon = new ImageIcon(getClass().getResource("/star_16x16.png"));
} }
@Override @Override
if (value instanceof RepositoryModel) { if (value instanceof RepositoryModel) {
StringBuilder tooltip = new StringBuilder(); StringBuilder tooltip = new StringBuilder();
RepositoryModel model = (RepositoryModel) value; 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()) { if (model.isFork()) {
JLabel icon = new JLabel(forkIcon); JLabel icon = new JLabel(forkIcon);
tooltip.append(Translation.get("gb.isFork")).append("<br/>"); tooltip.append(Translation.get("gb.isFork")).append("<br/>");

+ 6
- 0
src/com/gitblit/models/RepositoryModel.java Vedi File

public transient boolean isCollectingGarbage; public transient boolean isCollectingGarbage;
public Date lastGC; public Date lastGC;
public String sparkleshareId;
public RepositoryModel() { public RepositoryModel() {
this("", "", "", new Date(0)); this("", "", "", new Date(0));
return !accessRestriction.atLeast(AccessRestrictionType.VIEW); return !accessRestriction.atLeast(AccessRestrictionType.VIEW);
} }
public boolean isSparkleshared() {
return !StringUtils.isEmpty(sparkleshareId);
}
public RepositoryModel cloneAs(String cloneName) { public RepositoryModel cloneAs(String cloneName) {
RepositoryModel clone = new RepositoryModel(); RepositoryModel clone = new RepositoryModel();
clone.originRepository = name; clone.originRepository = name;
clone.useTickets = useTickets; clone.useTickets = useTickets;
clone.skipSizeCalculation = skipSizeCalculation; clone.skipSizeCalculation = skipSizeCalculation;
clone.skipSummaryMetrics = skipSummaryMetrics; clone.skipSummaryMetrics = skipSummaryMetrics;
clone.sparkleshareId = sparkleshareId;
return clone; return clone;
} }
} }

+ 1
- 1
src/com/gitblit/utils/IssueUtils.java Vedi File

String issuePath = getIssuePath(issueId); String issuePath = getIssuePath(issueId);
RevTree tree = JGitUtils.getCommit(repository, GB_ISSUES).getTree(); RevTree tree = JGitUtils.getCommit(repository, GB_ISSUES).getTree();
byte[] content = JGitUtils byte[] content = JGitUtils
.getByteContent(repository, tree, issuePath + "/" + attachment.id);
.getByteContent(repository, tree, issuePath + "/" + attachment.id, false);
attachment.content = content; attachment.content = content;
attachment.size = content.length; attachment.size = content.length;
return attachment; return attachment;

+ 20
- 4
src/com/gitblit/utils/JGitUtils.java Vedi File

* @param path * @param path
* @return content as a byte [] * @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); RevWalk rw = new RevWalk(repository);
TreeWalk tw = new TreeWalk(repository); TreeWalk tw = new TreeWalk(repository);
tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path))); tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
} }
} }
} catch (Throwable t) { } 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 { } finally {
rw.dispose(); rw.dispose();
tw.release(); tw.release();
* @return UTF-8 string content * @return UTF-8 string content
*/ */
public static String getStringContent(Repository repository, RevTree tree, String blobPath, String... charsets) { 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) { if (content == null) {
return null; return null;
} }
*/ */
public static List<SubmoduleModel> getSubmodules(Repository repository, RevTree tree) { public static List<SubmoduleModel> getSubmodules(Repository repository, RevTree tree) {
List<SubmoduleModel> list = new ArrayList<SubmoduleModel>(); List<SubmoduleModel> list = new ArrayList<SubmoduleModel>();
byte [] blob = getByteContent(repository, tree, ".gitmodules");
byte [] blob = getByteContent(repository, tree, ".gitmodules", false);
if (blob == null) { if (blob == null) {
return list; return list;
} }
} }
return success; 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);
}
} }

+ 2
- 1
src/com/gitblit/wicket/GitBlitWebApp.properties Vedi File

gb.validity = validity gb.validity = validity
gb.siteName = site name gb.siteName = site name
gb.siteNameDescription = short, descriptive name of your server 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

+ 2
- 2
src/com/gitblit/wicket/pages/RawPage.java Vedi File

switch (type) { switch (type) {
case 2: case 2:
// image blobs // 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.setContentType("image/" + extension.toLowerCase());
response.setContentLength(image.length); response.setContentLength(image.length);
try { try {
break; break;
case 3: case 3:
// binary blobs (download) // 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.setContentLength(binary.length);
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");

+ 1
- 1
src/com/gitblit/wicket/pages/RepositoryPage.html Vedi File

</div> </div>
</div> </div>
<div class="span7"> <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> <span wicket:id="originRepository">[origin repository]</span>
</div> </div>
</div> </div>

+ 8
- 0
src/com/gitblit/wicket/pages/RepositoryPage.java Vedi File

} }
} }
// 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) { if (getRepositoryModel().isBare) {
add(new Label("workingCopyIndicator").setVisible(false)); add(new Label("workingCopyIndicator").setVisible(false));
} else { } else {

+ 1
- 0
src/com/gitblit/wicket/panels/ProjectRepositoryPanel.html Vedi File

<div class="pull-right" style="text-align:right;padding-right:15px;"> <div class="pull-right" style="text-align:right;padding-right:15px;">
<span wicket:id="repositoryLinks"></span> <span wicket:id="repositoryLinks"></span>
<div> <div>
<img class="inlineIcon" wicket:id="sparkleshareIcon" />
<img class="inlineIcon" wicket:id="frozenIcon" /> <img class="inlineIcon" wicket:id="frozenIcon" />
<img class="inlineIcon" wicket:id="federatedIcon" /> <img class="inlineIcon" wicket:id="federatedIcon" />

+ 6
- 0
src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java Vedi File

add(forkFrag); 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>("tickets", TicketsPage.class, pp).setVisible(entry.useTickets));
add(new BookmarkablePageLink<Void>("docs", DocsPage.class, pp).setVisible(entry.useDocs)); add(new BookmarkablePageLink<Void>("docs", DocsPage.class, pp).setVisible(entry.useDocs));

+ 1
- 1
src/com/gitblit/wicket/panels/RepositoriesPanel.html Vedi File

<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="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-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-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><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="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"> <td class="rightAlign">

+ 7
- 0
src/com/gitblit/wicket/panels/RepositoriesPanel.java Vedi File

.setEscapeModelStrings(false)); .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()) { if (entry.isFork()) {
row.add(WicketUtils.newImage("forkIcon", "commit_divide_16x16.png", row.add(WicketUtils.newImage("forkIcon", "commit_divide_16x16.png",
getString("gb.isFork"))); getString("gb.isFork")));

Loading…
Annulla
Salva