summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java86
-rw-r--r--src/main/java/com/gitblit/wicket/pages/CommitPage.java100
-rw-r--r--src/main/java/com/gitblit/wicket/pages/TreePage.java83
-rw-r--r--src/main/java/com/gitblit/wicket/panels/LinkPanel.java22
4 files changed, 279 insertions, 12 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
index 9bc1570d..eaff2067 100644
--- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
@@ -15,6 +15,7 @@
*/
package com.gitblit.wicket.pages;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -23,9 +24,13 @@ import org.apache.wicket.PageParameters;
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;
@@ -35,6 +40,7 @@ import com.gitblit.Keys;
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;
@@ -42,6 +48,7 @@ import com.gitblit.utils.DiffUtils.DiffOutput;
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;
@@ -135,7 +142,6 @@ public class CommitDiffPage extends RepositoryPage {
@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);
@@ -162,7 +168,34 @@ public class CommitDiffPage extends RepositoryPage {
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
@@ -188,8 +221,53 @@ public class CommitDiffPage extends RepositoryPage {
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));
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitPage.java b/src/main/java/com/gitblit/wicket/pages/CommitPage.java
index c8411738..417afe30 100644
--- a/src/main/java/com/gitblit/wicket/pages/CommitPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/CommitPage.java
@@ -15,29 +15,51 @@
*/
package com.gitblit.wicket.pages;
+import java.io.OutputStream;
+import java.sql.Blob;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.Callable;
import org.apache.wicket.PageParameters;
+import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.DownloadLink;
import org.apache.wicket.markup.html.link.ExternalLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.link.ResourceLink;
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.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;
+import org.apache.wicket.request.target.basic.RedirectRequestTarget;
+import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;
+import org.apache.wicket.util.resource.AbstractResourceStream;
+import org.apache.wicket.util.resource.AbstractResourceStreamWriter;
+import org.apache.wicket.util.resource.IResourceStream;
+import org.bouncycastle.jcajce.provider.symmetric.Threefish;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.Constants;
+import com.gitblit.GitBlit;
+import com.gitblit.manager.FilestoreManager;
+import com.gitblit.manager.GitblitManager;
+import com.gitblit.models.FilestoreModel;
import com.gitblit.models.GitNote;
+import com.gitblit.models.RepositoryModel;
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.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;
@@ -198,7 +220,31 @@ public class CommitPage extends RepositoryPage {
}
if (entry.isFilestoreItem()) {
- item.add(new LinkPanel("pathName", "list", entry.path, filestoreItemUrl));
+ 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", displayPath, BlobPage.class,
WicketUtils.newPathParameter(repositoryName, entry.commitId, path)));
@@ -232,8 +278,56 @@ public class CommitPage extends RepositoryPage {
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));
diff --git a/src/main/java/com/gitblit/wicket/pages/TreePage.java b/src/main/java/com/gitblit/wicket/pages/TreePage.java
index f1382147..3961e044 100644
--- a/src/main/java/com/gitblit/wicket/pages/TreePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/TreePage.java
@@ -15,26 +15,33 @@
*/
package com.gitblit.wicket.pages;
+import java.io.OutputStream;
import java.util.List;
import org.apache.wicket.PageParameters;
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.html.panel.Fragment;
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.lib.FileMode;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.models.PathModel;
import com.gitblit.models.SubmoduleModel;
+import com.gitblit.models.UserModel;
import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.ByteFormat;
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;
@@ -88,7 +95,7 @@ public class TreePage extends RepositoryPage {
@Override
public void populateItem(final Item<PathModel> item) {
- PathModel entry = item.getModelObject();
+ final PathModel entry = item.getModelObject();
item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));
@@ -170,11 +177,77 @@ public class TreePage extends RepositoryPage {
if (entry.isFilestoreItem()) {
item.add(new Label("filestore", getString("gb.filestore")).setVisible(true));
- final String filestoreItemUrl = JGitUtils.getLfsRepositoryUrl(getContextUrl(), repositoryName, entry.getFilestoreOid());
+ item.add(new LinkPanel("pathName", "list", displayPath, 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));
+ }}));
- item.add(new LinkPanel("pathName", "list", displayPath, filestoreItemUrl));
- links.add(new ExternalLink("view", filestoreItemUrl));
- links.add(new ExternalLink("raw", filestoreItemUrl));
+ links.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));
+ }});
+
+ links.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));
diff --git a/src/main/java/com/gitblit/wicket/panels/LinkPanel.java b/src/main/java/com/gitblit/wicket/panels/LinkPanel.java
index 06159ac3..aa09be09 100644
--- a/src/main/java/com/gitblit/wicket/panels/LinkPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/LinkPanel.java
@@ -15,6 +15,9 @@
*/
package com.gitblit.wicket.panels;
+import java.io.OutputStream;
+import java.util.concurrent.Callable;
+
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.behavior.SimpleAttributeModifier;
@@ -26,8 +29,13 @@ import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
+import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget;
+import org.apache.wicket.util.resource.AbstractResourceStreamWriter;
+import org.apache.wicket.util.resource.IResourceStream;
+import com.gitblit.models.UserModel;
import com.gitblit.utils.StringUtils;
+import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
public class LinkPanel extends Panel {
@@ -108,6 +116,20 @@ public class LinkPanel extends Panel {
add(link);
}
+ public LinkPanel(String wicketId, String linkCssClass, String label, Link<?> link) {
+ super(wicketId);
+
+ this.labelModel = new Model<String>(label);
+
+ if (linkCssClass != null) {
+ link.add(new SimpleAttributeModifier("class", linkCssClass));
+ }
+
+ link.add(new Label("icon").setVisible(false));
+ link.add(new Label("label", labelModel));
+ add(link);
+ }
+
public void setNoFollow() {
Component c = get("link");
c.add(new SimpleAttributeModifier("rel", "nofollow"));