| | |
| | | import org.apache.wicket.markup.html.panel.Fragment;
|
| | | import org.apache.wicket.model.IModel;
|
| | | import org.apache.wicket.model.Model;
|
| | | import org.apache.wicket.protocol.http.RequestUtils;
|
| | | import org.apache.wicket.request.target.basic.RedirectRequestTarget;
|
| | | import org.eclipse.jgit.diff.DiffEntry.ChangeType;
|
| | | import org.eclipse.jgit.lib.PersonIdent;
|
| | |
| | | *
|
| | | * @return a link renderer
|
| | | */
|
| | | protected LinkRenderer getLinkRenderer() {
|
| | | protected LinkRenderer getMarkdownLinkRenderer() {
|
| | | RevCommit head = JGitUtils.getCommit(r, "HEAD");
|
| | | final String id = getBestCommitId(head);
|
| | | LinkRenderer renderer = new LinkRenderer() {
|
| | |
| | | public Rendering render(WikiLinkNode node) {
|
| | | try {
|
| | | String fsc = GitBlit.getString(Keys.web.forwardSlashCharacter, "/");
|
| | | String path = URLEncoder.encode(node.getText().replace(' ', '-'), "UTF-8").replace("%2F", fsc);
|
| | | String name = node.getText();
|
| | | // adjust the request path
|
| | | String path = node.getText().charAt(0) == '/' ? node.getText().substring(1) : node.getText();
|
| | | path = URLEncoder.encode(path.replace(' ', '-'), "UTF-8").replace("%2F", fsc);
|
| | |
|
| | | // extract document name
|
| | | String name = node.getText().replace('_', ' ');
|
| | | if (name.indexOf('/') > -1) {
|
| | | name = name.substring(name.lastIndexOf('/') + 1);
|
| | | }
|
| | |
|
| | | // strip Markdown extension
|
| | | for (String ext : GitBlit.getStrings(Keys.web.markdownExtensions)) {
|
| | | String x = "." + ext;
|
| | | if (name.endsWith(x)) {
|
| | | name = name.substring(0, name.length() - x.length());
|
| | | break;
|
| | | }
|
| | | }
|
| | | String url = urlFor(MarkdownPage.class, WicketUtils.newPathParameter(repositoryName, id, path)).toString();
|
| | | return new Rendering(url, name);
|
| | |
| | | String searchString = searchBoxModel.getObject();
|
| | | if (StringUtils.isEmpty(searchString)) {
|
| | | // redirect to self to avoid wicket page update bug
|
| | | PageParameters params = RepositoryPage.this.getPageParameters();
|
| | | String relativeUrl = urlFor(RepositoryPage.this.getClass(), params).toString();
|
| | | String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
|
| | | String absoluteUrl = getCanonicalUrl();
|
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
|
| | | return;
|
| | | }
|
| | |
| | | // use an absolute url to workaround Wicket-Tomcat problems with
|
| | | // mounted url parameters (issue-111)
|
| | | PageParameters params = WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType);
|
| | | String relativeUrl = urlFor(searchPageClass, params).toString();
|
| | | String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
|
| | | String absoluteUrl = getCanonicalUrl(searchPageClass, params);
|
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
|
| | | }
|
| | | }
|