James Moger
2013-11-26 4fcac9d2cbdafb51e3ee9ca3b3da64fd86103174
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
@@ -16,8 +16,6 @@
package com.gitblit.wicket.pages;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,8 +42,6 @@
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.pegdown.LinkRenderer;
import org.pegdown.ast.WikiLinkNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -200,6 +196,7 @@
      }
      pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));
      pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
      pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
      pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true));
      if (GitBlit.getBoolean(Keys.web.allowForking, true)) {
         pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params, true));
@@ -207,9 +204,6 @@
      // conditional links
      // per-repository extra page links
      if (model.useDocs) {
         pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
      }
      if (JGitUtils.getPagesBranch(r) != null) {
         OtherPageLink pagesLink = new OtherPageLink("gb.pages", PagesServlet.asLink(
               getRequest().getRelativePathPrefixToContextRoot(), repositoryName, null), true);
@@ -264,7 +258,14 @@
      // indicate origin repository
      RepositoryModel model = getRepositoryModel();
      if (StringUtils.isEmpty(model.originRepository)) {
         add(new Label("originRepository").setVisible(false));
         if (model.isMirror) {
            Fragment mirrorFrag = new Fragment("originRepository", "mirrorFragment", this);
            Label lbl = new Label("originRepository", MessageFormat.format(getString("gb.mirrorOf"), "<b>" + model.origin + "</b>"));
            mirrorFrag.add(lbl.setEscapeModelStrings(false));
            add(mirrorFrag);
         } else {
            add(new Label("originRepository").setVisible(false));
         }
      } else {
         RepositoryModel origin = GitBlit.self().getRepositoryModel(model.originRepository);
         if (origin == null) {
@@ -645,47 +646,6 @@
   public boolean isOwner() {
      return isOwner;
   }
   /**
    * Returns a Pegdown/Markdown link renderer which renders WikiLinks.
    *
    * @return a link renderer
    */
   protected LinkRenderer getMarkdownLinkRenderer() {
      RevCommit head = JGitUtils.getCommit(r, "HEAD");
      final String id = getBestCommitId(head);
      LinkRenderer renderer = new LinkRenderer() {
         @Override
         public Rendering render(WikiLinkNode node) {
            try {
               String fsc = GitBlit.getString(Keys.web.forwardSlashCharacter, "/");
               // 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);
            } catch (UnsupportedEncodingException e) {
               throw new IllegalStateException();
            }
         }
      };
      return renderer;
   }
   private class SearchForm extends SessionlessForm<Void> implements Serializable {