diff options
author | James Moger <james.moger@gitblit.com> | 2014-05-05 09:53:24 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-05-05 09:53:24 -0400 |
commit | ff17f7bac432b4ba8310ba3ea335748a34859d50 (patch) | |
tree | 58278b648975c83e5af80cb79f3cf6f0bf78759c | |
parent | 1946fe76331b37c5a3be97268f0e3b0e58f3bb00 (diff) | |
download | gitblit-ff17f7bac432b4ba8310ba3ea335748a34859d50.tar.gz gitblit-ff17f7bac432b4ba8310ba3ea335748a34859d50.zip |
Replace RawPage with RawServlet
17 files changed, 76 insertions, 66 deletions
diff --git a/src/main/java/WEB-INF/web.xml b/src/main/java/WEB-INF/web.xml index d60992dd..cb483af4 100644 --- a/src/main/java/WEB-INF/web.xml +++ b/src/main/java/WEB-INF/web.xml @@ -134,18 +134,18 @@ </servlet-mapping>
- <!-- Branch Servlet
+ <!-- Raw Servlet
<url-pattern> MUST match:
- * BranchFilter
- * com.gitblit.Constants.BRANCH_PATH
+ * RawFilter
+ * com.gitblit.Constants.RAW_PATH
* Wicket Filter ignorePaths parameter -->
<servlet>
- <servlet-name>BranchServlet</servlet-name>
- <servlet-class>com.gitblit.servlet.BranchServlet</servlet-class>
+ <servlet-name>RawServlet</servlet-name>
+ <servlet-class>com.gitblit.servlet.RawServlet</servlet-class>
</servlet>
<servlet-mapping>
- <servlet-name>BranchServlet</servlet-name>
- <url-pattern>/branch/*</url-pattern>
+ <servlet-name>RawServlet</servlet-name>
+ <url-pattern>/raw/*</url-pattern>
</servlet-mapping>
@@ -280,16 +280,16 @@ <!-- Branch Restriction Filter
<url-pattern> MUST match:
- * BranchServlet
+ * RawServlet
* com.gitblit.Constants.BRANCH_PATH
* Wicket Filter ignorePaths parameter -->
<filter>
- <filter-name>BranchFilter</filter-name>
- <filter-class>com.gitblit.servlet.BranchFilter</filter-class>
+ <filter-name>RawFilter</filter-name>
+ <filter-class>com.gitblit.servlet.RawFilter</filter-class>
</filter>
<filter-mapping>
- <filter-name>BranchFilter</filter-name>
- <url-pattern>/branch/*</url-pattern>
+ <filter-name>RawFilter</filter-name>
+ <url-pattern>/raw/*</url-pattern>
</filter-mapping>
@@ -340,12 +340,12 @@ * FederationServlet <url-pattern>
* RpcFilter <url-pattern>
* RpcServlet <url-pattern>
- * BranchFilter <url-pattern>
- * BranchServlet <url-pattern>
+ * RawFilter <url-pattern>
+ * RawServlet <url-pattern>
* PagesFilter <url-pattern>
* PagesServlet <url-pattern>
* com.gitblit.Constants.PAGES_PATH -->
- <param-value>r/,git/,pt,feed/,zip/,federation/,rpc/,branch/,pages/,robots.txt,logo.png,graph/,sparkleshare/</param-value>
+ <param-value>r/,git/,pt,feed/,zip/,federation/,rpc/,raw/,pages/,robots.txt,logo.png,graph/,sparkleshare/</param-value>
</init-param>
</filter>
<filter-mapping>
diff --git a/src/main/java/com/gitblit/Constants.java b/src/main/java/com/gitblit/Constants.java index 96f13c89..4b9755f3 100644 --- a/src/main/java/com/gitblit/Constants.java +++ b/src/main/java/com/gitblit/Constants.java @@ -68,7 +68,7 @@ public class Constants { public static final String SPARKLESHARE_INVITE_PATH = "/sparkleshare/";
- public static final String BRANCH = "/branch/";
+ public static final String RAW_PATH = "/raw/";
public static final String BRANCH_GRAPH_PATH = "/graph/";
diff --git a/src/main/java/com/gitblit/servlet/PagesFilter.java b/src/main/java/com/gitblit/servlet/PagesFilter.java index 0535ea06..e07d9b3b 100644 --- a/src/main/java/com/gitblit/servlet/PagesFilter.java +++ b/src/main/java/com/gitblit/servlet/PagesFilter.java @@ -23,7 +23,7 @@ package com.gitblit.servlet; * @author James Moger
*
*/
-public class PagesFilter extends BranchFilter {
+public class PagesFilter extends RawFilter {
}
diff --git a/src/main/java/com/gitblit/servlet/PagesServlet.java b/src/main/java/com/gitblit/servlet/PagesServlet.java index 7919e442..f578f86f 100644 --- a/src/main/java/com/gitblit/servlet/PagesServlet.java +++ b/src/main/java/com/gitblit/servlet/PagesServlet.java @@ -26,7 +26,7 @@ import com.gitblit.Constants; * @author James Moger
*
*/
-public class PagesServlet extends BranchServlet {
+public class PagesServlet extends RawServlet {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/com/gitblit/servlet/BranchFilter.java b/src/main/java/com/gitblit/servlet/RawFilter.java index 58b8f433..34989c98 100644 --- a/src/main/java/com/gitblit/servlet/BranchFilter.java +++ b/src/main/java/com/gitblit/servlet/RawFilter.java @@ -22,13 +22,13 @@ import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel;
/**
- * The BranchFilter is an AccessRestrictionFilter which ensures http branch
+ * The RawFilter is an AccessRestrictionFilter which ensures http branch
* requests for a view-restricted repository are authenticated and authorized.
*
* @author James Moger
*
*/
-public class BranchFilter extends AccessRestrictionFilter {
+public class RawFilter extends AccessRestrictionFilter {
/**
* Extract the repository name from the url.
diff --git a/src/main/java/com/gitblit/servlet/BranchServlet.java b/src/main/java/com/gitblit/servlet/RawServlet.java index 33808961..cde7b2e1 100644 --- a/src/main/java/com/gitblit/servlet/BranchServlet.java +++ b/src/main/java/com/gitblit/servlet/RawServlet.java @@ -65,11 +65,11 @@ import dagger.ObjectGraph; * @author James Moger * */ -public class BranchServlet extends DaggerServlet { +public class RawServlet extends DaggerServlet { private static final long serialVersionUID = 1L; - private transient Logger logger = LoggerFactory.getLogger(BranchServlet.class); + private transient Logger logger = LoggerFactory.getLogger(RawServlet.class); private IRuntimeManager runtimeManager; @@ -99,7 +99,7 @@ public class BranchServlet extends DaggerServlet { encodedPath = URLEncoder.encode(encodedPath, "UTF-8"); } catch (UnsupportedEncodingException e) { } - return baseURL + Constants.BRANCH + repository + "/" + (branch == null ? "" : (branch + "/" + (path == null ? "" : (encodedPath + "/")))); + return baseURL + Constants.RAW_PATH + repository + "/" + (branch == null ? "" : (branch + "/" + (path == null ? "" : encodedPath))); } protected String getBranch(String repository, HttpServletRequest request) { @@ -333,18 +333,9 @@ public class BranchServlet extends DaggerServlet { String str = MessageFormat.format( "# Error\nSorry, the requested resource **{0}** was not found.", requestedPath); - String content = MarkdownUtils.transformMarkdown(str); - - try { - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - - byte [] bytes = content.getBytes(Constants.ENCODING); - ByteArrayInputStream is = new ByteArrayInputStream(bytes); - sendContent(response, new Date(), is); - return; - } catch (Throwable t) { - logger.error("Failed to write page to client", t); - } + response.setStatus(HttpServletResponse.SC_NOT_FOUND); + error(response, str); + return; } else { // // directory list @@ -373,7 +364,8 @@ public class BranchServlet extends DaggerServlet { for (PathModel entry : pathEntries) { String pp = URLEncoder.encode(entry.name, Constants.ENCODING); response.getWriter().append(MessageFormat.format(pattern, basePath, pp, - JGitUtils.getPermissionsFromMode(entry.mode), byteFormat.format(entry.size))); + JGitUtils.getPermissionsFromMode(entry.mode), + entry.isFile() ? byteFormat.format(entry.size) : "")); } response.getWriter().append("</tbody>"); response.getWriter().append("</table>"); diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java index 9f002d2b..dc79af26 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java @@ -64,13 +64,13 @@ import com.gitblit.wicket.pages.LogoutPage; import com.gitblit.wicket.pages.LuceneSearchPage; import com.gitblit.wicket.pages.MetricsPage; import com.gitblit.wicket.pages.MyDashboardPage; +import com.gitblit.wicket.pages.MyTicketsPage; import com.gitblit.wicket.pages.NewMilestonePage; import com.gitblit.wicket.pages.NewTicketPage; import com.gitblit.wicket.pages.OverviewPage; import com.gitblit.wicket.pages.PatchPage; import com.gitblit.wicket.pages.ProjectPage; import com.gitblit.wicket.pages.ProjectsPage; -import com.gitblit.wicket.pages.RawPage; import com.gitblit.wicket.pages.ReflogPage; import com.gitblit.wicket.pages.RepositoriesPage; import com.gitblit.wicket.pages.ReviewProposalPage; @@ -81,7 +81,6 @@ import com.gitblit.wicket.pages.TicketsPage; import com.gitblit.wicket.pages.TreePage; import com.gitblit.wicket.pages.UserPage; import com.gitblit.wicket.pages.UsersPage; -import com.gitblit.wicket.pages.MyTicketsPage; public class GitBlitWebApp extends WebApplication { @@ -173,7 +172,6 @@ public class GitBlitWebApp extends WebApplication { mount("/tag", TagPage.class, "r", "h"); mount("/tree", TreePage.class, "r", "h", "f"); mount("/blob", BlobPage.class, "r", "h", "f"); - mount("/raw", RawPage.class, "r", "h", "f"); mount("/blobdiff", BlobDiffPage.class, "r", "h", "f"); mount("/commitdiff", CommitDiffPage.class, "r", "h"); mount("/compare", ComparePage.class, "r", "h"); diff --git a/src/main/java/com/gitblit/wicket/MarkupProcessor.java b/src/main/java/com/gitblit/wicket/MarkupProcessor.java index ff6fbce2..e7681f2c 100644 --- a/src/main/java/com/gitblit/wicket/MarkupProcessor.java +++ b/src/main/java/com/gitblit/wicket/MarkupProcessor.java @@ -56,11 +56,11 @@ import org.slf4j.LoggerFactory; import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
import com.gitblit.models.PathModel;
+import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.pages.DocPage;
-import com.gitblit.wicket.pages.RawPage;
import com.google.common.base.Joiner;
/**
@@ -260,7 +260,8 @@ public class MarkupProcessor { if (imagePath.indexOf("://") == -1) {
// relative image
String path = doc.getRelativePath(imagePath);
- url = getWicketUrl(RawPage.class, repositoryName, commitId, path);
+ String contextUrl = RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot();
+ url = RawServlet.asLink(contextUrl, repositoryName, commitId, path);
} else {
// absolute image
url = imagePath;
@@ -312,7 +313,8 @@ public class MarkupProcessor { if (node.url.indexOf("://") == -1) {
// repository-relative image link
String path = doc.getRelativePath(node.url);
- String url = getWicketUrl(RawPage.class, repositoryName, commitId, path);
+ String contextUrl = RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot();
+ String url = RawServlet.asLink(contextUrl, repositoryName, commitId, path);
return new Rendering(url, text);
}
// absolute image link
@@ -325,7 +327,8 @@ public class MarkupProcessor { if (url.indexOf("://") == -1) {
// repository-relative image link
String path = doc.getRelativePath(url);
- String wurl = getWicketUrl(RawPage.class, repositoryName, commitId, path);
+ String contextUrl = RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot();
+ String wurl = RawServlet.asLink(contextUrl, repositoryName, commitId, path);
rendering = new Rendering(wurl, alt);
} else {
// absolute image link
diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java index 7d3d3a24..49710397 100644 --- a/src/main/java/com/gitblit/wicket/pages/BasePage.java +++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java @@ -98,6 +98,10 @@ public abstract class BasePage extends SessionPage { }
}
+ protected String getContextUrl() {
+ return getRequest().getRelativePathPrefixToContextRoot();
+ }
+
protected String getCanonicalUrl() {
return getCanonicalUrl(getClass(), getPageParameters());
}
diff --git a/src/main/java/com/gitblit/wicket/pages/BlobPage.java b/src/main/java/com/gitblit/wicket/pages/BlobPage.java index 299d8dbc..f3d0bc92 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlobPage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlobPage.java @@ -24,10 +24,12 @@ import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.ExternalLink;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.Keys;
+import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
@@ -57,8 +59,8 @@ public class BlobPage extends RepositoryPage { WicketUtils.newPathParameter(repositoryName, objectId, blobPath))
.setEnabled(false));
add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class).setEnabled(false));
- add(new BookmarkablePageLink<Void>("rawLink", RawPage.class,
- WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, objectId, blobPath);
+ add(new ExternalLink("rawLink", rawUrl));
add(new CommitHeaderPanel("commitHeader", objectId));
add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));
Component c = new Label("blobText", JGitUtils.getStringContent(r, objectId, encodings));
@@ -87,8 +89,8 @@ public class BlobPage extends RepositoryPage { WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,
WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
- add(new BookmarkablePageLink<Void>("rawLink", RawPage.class,
- WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, objectId, blobPath);
+ add(new ExternalLink("rawLink", rawUrl));
add(new CommitHeaderPanel("commitHeader", repositoryName, commit));
@@ -115,7 +117,7 @@ public class BlobPage extends RepositoryPage { case 2:
// image blobs
add(new Label("blobText").setVisible(false));
- add(new ExternalImage("blobImage", urlFor(RawPage.class, WicketUtils.newPathParameter(repositoryName, objectId, blobPath)).toString()));
+ add(new ExternalImage("blobImage", rawUrl));
break;
case 3:
// binary blobs
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java index 7f2a8a61..71a5ea67 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java @@ -34,6 +34,7 @@ import com.gitblit.Constants; import com.gitblit.models.GitNote; import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.SubmoduleModel; +import com.gitblit.servlet.RawServlet; import com.gitblit.utils.DiffUtils; import com.gitblit.utils.DiffUtils.DiffOutput; import com.gitblit.utils.DiffUtils.DiffOutputType; @@ -170,8 +171,8 @@ public class CommitDiffPage extends RepositoryPage { item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils .newPathParameter(repositoryName, entry.commitId, entry.path)) .setEnabled(!entry.changeType.equals(ChangeType.DELETE))); - item.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils - .newPathParameter(repositoryName, entry.commitId, entry.path)) + String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, entry.commitId, entry.path); + item.add(new ExternalLink("raw", rawUrl) .setEnabled(!entry.changeType.equals(ChangeType.DELETE))); item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils .newPathParameter(repositoryName, entry.commitId, entry.path)) diff --git a/src/main/java/com/gitblit/wicket/pages/CommitPage.java b/src/main/java/com/gitblit/wicket/pages/CommitPage.java index 8bc98489..6fadec5b 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitPage.java @@ -35,6 +35,7 @@ import com.gitblit.Constants; import com.gitblit.models.GitNote;
import com.gitblit.models.PathModel.PathChangeModel;
import com.gitblit.models.SubmoduleModel;
+import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.CacheControl;
import com.gitblit.wicket.CacheControl.LastModified;
@@ -222,8 +223,8 @@ public class CommitPage extends RepositoryPage { item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils
.newPathParameter(repositoryName, entry.commitId, entry.path))
.setEnabled(!entry.changeType.equals(ChangeType.DELETE)));
- item.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
- .newPathParameter(repositoryName, entry.commitId, entry.path))
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, entry.commitId, entry.path);
+ item.add(new ExternalLink("raw", rawUrl)
.setEnabled(!entry.changeType.equals(ChangeType.DELETE)));
item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils
.newPathParameter(repositoryName, entry.commitId, entry.path))
diff --git a/src/main/java/com/gitblit/wicket/pages/ComparePage.java b/src/main/java/com/gitblit/wicket/pages/ComparePage.java index 2024bf17..1ec66133 100644 --- a/src/main/java/com/gitblit/wicket/pages/ComparePage.java +++ b/src/main/java/com/gitblit/wicket/pages/ComparePage.java @@ -41,6 +41,7 @@ import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.RefModel; import com.gitblit.models.RepositoryModel; import com.gitblit.models.SubmoduleModel; +import com.gitblit.servlet.RawServlet; import com.gitblit.utils.DiffUtils; import com.gitblit.utils.DiffUtils.DiffOutput; import com.gitblit.utils.DiffUtils.DiffOutputType; @@ -184,8 +185,8 @@ public class ComparePage extends RepositoryPage { item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils .newPathParameter(repositoryName, endId, entry.path)) .setEnabled(!entry.changeType.equals(ChangeType.DELETE))); - item.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils - .newPathParameter(repositoryName, endId, entry.path)) + String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, endId, entry.path); + item.add(new ExternalLink("raw", rawUrl) .setEnabled(!entry.changeType.equals(ChangeType.DELETE))); item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils .newPathParameter(repositoryName, endId, entry.path)) diff --git a/src/main/java/com/gitblit/wicket/pages/DocPage.java b/src/main/java/com/gitblit/wicket/pages/DocPage.java index bf99978c..c06d8065 100644 --- a/src/main/java/com/gitblit/wicket/pages/DocPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DocPage.java @@ -20,10 +20,12 @@ 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.panel.Fragment;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.BugtraqProcessor;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
@@ -87,8 +89,8 @@ public class DocPage extends RepositoryPage { WicketUtils.newPathParameter(repositoryName, objectId, documentPath)));
fragment.add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,
WicketUtils.newPathParameter(repositoryName, objectId, documentPath)));
- fragment.add(new BookmarkablePageLink<Void>("rawLink", RawPage.class, WicketUtils.newPathParameter(
- repositoryName, objectId, documentPath)));
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, objectId, documentPath);
+ fragment.add(new ExternalLink("rawLink", rawUrl));
fragment.add(new Label("content", markupDoc.html).setEscapeModelStrings(false));
add(fragment);
diff --git a/src/main/java/com/gitblit/wicket/pages/DocsPage.java b/src/main/java/com/gitblit/wicket/pages/DocsPage.java index 907dd6e2..fc56ee07 100644 --- a/src/main/java/com/gitblit/wicket/pages/DocsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DocsPage.java @@ -31,6 +31,7 @@ import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.models.PathModel;
+import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.ByteFormat;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
@@ -103,8 +104,8 @@ public class DocsPage extends RepositoryPage { WicketUtils.newPathParameter(repositoryName, commitId, doc.documentPath)));
item.add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,
WicketUtils.newPathParameter(repositoryName, commitId, doc.documentPath)));
- item.add(new BookmarkablePageLink<Void>("rawLink", RawPage.class, WicketUtils.newPathParameter(
- repositoryName, commitId, doc.documentPath)));
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, commitId, doc.documentPath);
+ item.add(new ExternalLink("rawLink", rawUrl));
// document content
String file = StringUtils.getLastPathElement(doc.documentPath);
@@ -145,8 +146,8 @@ public class DocsPage extends RepositoryPage { // links
item.add(new BookmarkablePageLink<Void>("view", DocPage.class, WicketUtils
.newPathParameter(repositoryName, id, entry.path)));
- item.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
- .newPathParameter(repositoryName, id, entry.path)));
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, id, entry.path);
+ item.add(new ExternalLink("raw", rawUrl));
item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils
.newPathParameter(repositoryName, id, entry.path)));
item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils
diff --git a/src/main/java/com/gitblit/wicket/pages/TreePage.java b/src/main/java/com/gitblit/wicket/pages/TreePage.java index d6bf1fe1..722b824f 100644 --- a/src/main/java/com/gitblit/wicket/pages/TreePage.java +++ b/src/main/java/com/gitblit/wicket/pages/TreePage.java @@ -20,6 +20,7 @@ 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.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
@@ -30,6 +31,7 @@ import org.eclipse.jgit.revwalk.RevCommit; import com.gitblit.models.PathModel;
import com.gitblit.models.SubmoduleModel;
+import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.ByteFormat;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.CacheControl;
@@ -162,8 +164,8 @@ public class TreePage extends RepositoryPage { links.add(new BookmarkablePageLink<Void>("view", BlobPage.class,
WicketUtils.newPathParameter(repositoryName, id,
path)));
- links.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
- .newPathParameter(repositoryName, id, path)));
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, id, path);
+ links.add(new ExternalLink("raw", rawUrl));
links.add(new BookmarkablePageLink<Void>("blame", BlamePage.class,
WicketUtils.newPathParameter(repositoryName, id,
path)));
diff --git a/src/main/java/com/gitblit/wicket/panels/TagsPanel.java b/src/main/java/com/gitblit/wicket/panels/TagsPanel.java index 9f3987be..f1f82739 100644 --- a/src/main/java/com/gitblit/wicket/panels/TagsPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/TagsPanel.java @@ -17,9 +17,11 @@ package com.gitblit.wicket.panels; import java.util.List;
+import org.apache.wicket.RequestCycle;
import org.apache.wicket.markup.html.WebPage;
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.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
@@ -29,13 +31,13 @@ import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository;
import com.gitblit.models.RefModel;
+import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.BlobPage;
import com.gitblit.wicket.pages.CommitPage;
import com.gitblit.wicket.pages.LogPage;
-import com.gitblit.wicket.pages.RawPage;
import com.gitblit.wicket.pages.TagPage;
import com.gitblit.wicket.pages.TagsPage;
import com.gitblit.wicket.pages.TreePage;
@@ -113,9 +115,10 @@ public class TagsPanel extends BasePanel { .newObjectParameter(repositoryName, entry.getReferencedObjectId()
.getName())));
- fragment.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
- .newObjectParameter(repositoryName, entry.getReferencedObjectId()
- .getName())));
+ String contextUrl = RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot();
+ String rawUrl = RawServlet.asLink(contextUrl, repositoryName, entry.displayName,
+ entry.getReferencedObjectId().getName());
+ fragment.add(new ExternalLink("raw", rawUrl));
item.add(fragment);
} else {
// TODO Tree Tag Object
|