*/
package com.gitblit.wicket.pages;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.ExternalLink;
+import org.apache.wicket.markup.html.link.Link;
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.apache.wicket.request.target.resource.ResourceStreamRequestTarget;
+import org.apache.wicket.util.resource.AbstractResourceStreamWriter;
+import org.apache.wicket.util.resource.IResourceStream;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.models.GitNote;
import com.gitblit.models.PathModel.PathChangeModel;
import com.gitblit.models.SubmoduleModel;
+import com.gitblit.models.UserModel;
import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.DiffUtils;
import com.gitblit.utils.DiffUtils.DiffComparator;
import com.gitblit.utils.DiffUtils.DiffOutputType;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.CacheControl;
+import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.CommitHeaderPanel;
@Override
public void populateItem(final Item<PathChangeModel> item) {
final PathChangeModel entry = item.getModelObject();
- final String filestoreItemUrl = entry.isFilestoreItem() ? JGitUtils.getLfsRepositoryUrl(getContextUrl(), repositoryName, entry.getFilestoreOid()) : null;
Label changeType = new Label("changeType", "");
WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
item.add(new LinkPanel("pathName", "list", entry.path + " @ " + getShortObjectId(submoduleId), "#n" + entry.objectId));
} else {
// add relative link
- item.add(new LinkPanel("pathName", "list", entry.path, entry.isFilestoreItem() ? filestoreItemUrl : "#n" + entry.objectId));
+ if (entry.isFilestoreItem()) {
+
+ item.add(new LinkPanel("pathName", "list", entry.path, new Link<Object>("link", null) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick() {
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void write(OutputStream output) {
+ UserModel user = GitBlitWebSession.get().getUser();
+ user = user == null ? UserModel.ANONYMOUS : user;
+
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);
+ }
+ };
+
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));
+ }}));
+ }
+ else
+ {
+ item.add(new LinkPanel("pathName", "list", entry.path, "#n" + entry.objectId));
+ }
}
// quick links
if (entry.isFilestoreItem()) {
item.add(new Label("filestore", getString("gb.filestore")).setVisible(true));
- item.add(new ExternalLink("view", filestoreItemUrl));
- item.add(new ExternalLink("raw", filestoreItemUrl));
+ item.add(new Link<Object>("view", null) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick() {
+
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void write(OutputStream output) {
+ UserModel user = GitBlitWebSession.get().getUser();
+ user = user == null ? UserModel.ANONYMOUS : user;
+
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);
+ }
+ };
+
+
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));
+ }});
+
+ item.add(new Link<Object>("raw", null) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick() {
+
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void write(OutputStream output) {
+ UserModel user = GitBlitWebSession.get().getUser();
+ user = user == null ? UserModel.ANONYMOUS : user;
+
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);
+ }
+ };
+
+
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));
+ }});
} else {
item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
*/\r
package com.gitblit.wicket.pages;\r
\r
+import java.io.OutputStream;\r
+import java.sql.Blob;\r
import java.util.ArrayList;\r
import java.util.Arrays;\r
import java.util.List;\r
+import java.util.concurrent.Callable;\r
\r
import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.behavior.SimpleAttributeModifier;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+import org.apache.wicket.markup.html.link.DownloadLink;\r
import org.apache.wicket.markup.html.link.ExternalLink;\r
+import org.apache.wicket.markup.html.link.Link;\r
+import org.apache.wicket.markup.html.link.ResourceLink;\r
import org.apache.wicket.markup.repeater.Item;\r
import org.apache.wicket.markup.repeater.data.DataView;\r
import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
+import org.apache.wicket.model.AbstractReadOnlyModel;\r
+import org.apache.wicket.model.IModel;\r
import org.apache.wicket.model.StringResourceModel;\r
+import org.apache.wicket.request.target.basic.RedirectRequestTarget;\r
+import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;\r
+import org.apache.wicket.util.resource.AbstractResourceStream;\r
+import org.apache.wicket.util.resource.AbstractResourceStreamWriter;\r
+import org.apache.wicket.util.resource.IResourceStream;\r
+import org.bouncycastle.jcajce.provider.symmetric.Threefish;\r
import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
import com.gitblit.Constants;\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.manager.FilestoreManager;\r
+import com.gitblit.manager.GitblitManager;\r
+import com.gitblit.models.FilestoreModel;\r
import com.gitblit.models.GitNote;\r
+import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.PathModel.PathChangeModel;\r
import com.gitblit.models.SubmoduleModel;\r
+import com.gitblit.models.UserModel;\r
import com.gitblit.servlet.RawServlet;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.wicket.CacheControl;\r
+import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.CacheControl.LastModified;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.panels.CommitHeaderPanel;\r
}\r
\r
if (entry.isFilestoreItem()) {\r
- item.add(new LinkPanel("pathName", "list", entry.path, filestoreItemUrl));\r
+ item.add(new LinkPanel("pathName", "list", entry.path, new Link<Object>("link", null) {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public void onClick() {\r
+ \r
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override \r
+ public void write(OutputStream output) {\r
+ UserModel user = GitBlitWebSession.get().getUser();\r
+ user = user == null ? UserModel.ANONYMOUS : user;\r
+ \r
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);\r
+ }\r
+ };\r
+ \r
+ \r
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));\r
+ }}));\r
+ \r
+ \r
} else {\r
item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,\r
WicketUtils.newPathParameter(repositoryName, entry.commitId, path)));\r
if (entry.isFilestoreItem()) {\r
item.add(new Label("filestore", getString("gb.filestore")).setVisible(true));\r
\r
- item.add(new ExternalLink("view", filestoreItemUrl));\r
- item.add(new ExternalLink("raw", filestoreItemUrl));\r
+ \r
+ \r
+ item.add(new Link<Object>("view", null) {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public void onClick() {\r
+ \r
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override \r
+ public void write(OutputStream output) {\r
+ UserModel user = GitBlitWebSession.get().getUser();\r
+ user = user == null ? UserModel.ANONYMOUS : user;\r
+ \r
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);\r
+ }\r
+ };\r
+ \r
+ \r
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));\r
+ }});\r
+ \r
+ item.add(new Link<Object>("raw", null) {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public void onClick() {\r
+ \r
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override \r
+ public void write(OutputStream output) {\r
+ UserModel user = GitBlitWebSession.get().getUser();\r
+ user = user == null ? UserModel.ANONYMOUS : user;\r
+ \r
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);\r
+ }\r
+ };\r
+ \r
+ \r
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));\r
+ }});\r
+ \r
} else {\r
item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));\r
\r
*/\r
package com.gitblit.wicket.pages;\r
\r
+import java.io.OutputStream;\r
import java.util.List;\r
\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
import org.apache.wicket.markup.html.link.ExternalLink;\r
+import org.apache.wicket.markup.html.link.Link;\r
import org.apache.wicket.markup.html.panel.Fragment;\r
import org.apache.wicket.markup.repeater.Item;\r
import org.apache.wicket.markup.repeater.data.DataView;\r
import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
+import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;\r
+import org.apache.wicket.util.resource.AbstractResourceStreamWriter;\r
+import org.apache.wicket.util.resource.IResourceStream;\r
import org.eclipse.jgit.lib.FileMode;\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
import com.gitblit.models.PathModel;\r
import com.gitblit.models.SubmoduleModel;\r
+import com.gitblit.models.UserModel;\r
import com.gitblit.servlet.RawServlet;\r
import com.gitblit.utils.ByteFormat;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.wicket.CacheControl;\r
+import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.CacheControl.LastModified;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.panels.CommitHeaderPanel;\r
\r
@Override\r
public void populateItem(final Item<PathModel> item) {\r
- PathModel entry = item.getModelObject();\r
+ final PathModel entry = item.getModelObject();\r
\r
item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));\r
\r
if (entry.isFilestoreItem()) {\r
item.add(new Label("filestore", getString("gb.filestore")).setVisible(true));\r
\r
- final String filestoreItemUrl = JGitUtils.getLfsRepositoryUrl(getContextUrl(), repositoryName, entry.getFilestoreOid());\r
+ item.add(new LinkPanel("pathName", "list", displayPath, new Link<Object>("link", null) {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public void onClick() {\r
+ \r
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override \r
+ public void write(OutputStream output) {\r
+ UserModel user = GitBlitWebSession.get().getUser();\r
+ user = user == null ? UserModel.ANONYMOUS : user;\r
+ \r
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);\r
+ }\r
+ };\r
+ \r
+ \r
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));\r
+ }}));\r
\r
- item.add(new LinkPanel("pathName", "list", displayPath, filestoreItemUrl));\r
- links.add(new ExternalLink("view", filestoreItemUrl));\r
- links.add(new ExternalLink("raw", filestoreItemUrl));\r
+ links.add(new Link<Object>("view", null) {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public void onClick() {\r
+ \r
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override \r
+ public void write(OutputStream output) {\r
+ UserModel user = GitBlitWebSession.get().getUser();\r
+ user = user == null ? UserModel.ANONYMOUS : user;\r
+ \r
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);\r
+ }\r
+ };\r
+ \r
+ \r
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));\r
+ }});\r
+ \r
+ links.add(new Link<Object>("raw", null) {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override\r
+ public void onClick() {\r
+ \r
+ IResourceStream resourceStream = new AbstractResourceStreamWriter() {\r
+ \r
+ private static final long serialVersionUID = 1L;\r
+\r
+ @Override \r
+ public void write(OutputStream output) {\r
+ UserModel user = GitBlitWebSession.get().getUser();\r
+ user = user == null ? UserModel.ANONYMOUS : user;\r
+ \r
+ app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output);\r
+ }\r
+ };\r
+ \r
+ \r
+ getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path));\r
+ }});\r
\r
} else {\r
item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));\r
*/\r
package com.gitblit.wicket.panels;\r
\r
+import java.io.OutputStream;\r
+import java.util.concurrent.Callable;\r
+\r
import org.apache.wicket.Component;\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.behavior.SimpleAttributeModifier;\r
import org.apache.wicket.markup.html.panel.Panel;\r
import org.apache.wicket.model.IModel;\r
import org.apache.wicket.model.Model;\r
+import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;\r
+import org.apache.wicket.util.resource.AbstractResourceStreamWriter;\r
+import org.apache.wicket.util.resource.IResourceStream;\r
\r
+import com.gitblit.models.UserModel;\r
import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.WicketUtils;\r
\r
public class LinkPanel extends Panel {\r
add(link);\r
}\r
\r
+ public LinkPanel(String wicketId, String linkCssClass, String label, Link<?> link) {\r
+ super(wicketId);\r
+ \r
+ this.labelModel = new Model<String>(label);\r
+ \r
+ if (linkCssClass != null) {\r
+ link.add(new SimpleAttributeModifier("class", linkCssClass));\r
+ }\r
+ \r
+ link.add(new Label("icon").setVisible(false));\r
+ link.add(new Label("label", labelModel));\r
+ add(link);\r
+ }\r
+\r
public void setNoFollow() {\r
Component c = get("link");\r
c.add(new SimpleAttributeModifier("rel", "nofollow"));\r