James Moger
2011-06-14 8c9a2037b5c0fed881a3ad6dd9cff364eed603d9
src/com/gitblit/wicket/pages/RepositoryPage.java
@@ -21,7 +21,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
@@ -30,6 +29,7 @@
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.form.TextField;
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;
@@ -45,10 +45,12 @@
import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.SyndicationServlet;
import com.gitblit.models.RepositoryModel;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.JGitUtils.SearchType;
import com.gitblit.utils.StringUtils;
import com.gitblit.utils.TicgitUtils;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.LinkPanel;
@@ -108,7 +110,7 @@
      List<String> extraPageLinks = new ArrayList<String>();
      // Conditionally add tickets link
      if (model.useTickets && JGitUtils.getTicketsBranch(r) != null) {
      if (model.useTickets && TicgitUtils.getTicketsBranch(r) != null) {
         extraPageLinks.add("tickets");
      }
@@ -157,6 +159,9 @@
      };
      add(extrasView);
      add(new ExternalLink("syndication", SyndicationServlet.asLink(getRequest()
            .getRelativePathPrefixToContextRoot(), repositoryName, null, 0)));
      // disable current page
      disablePageLink(getPageName());
@@ -181,6 +186,12 @@
            break;
         }
      }
   }
   protected void addSyndicationDiscoveryLink() {
      add(WicketUtils.syndicationDiscoveryLink(SyndicationServlet.getTitle(repositoryName,
            objectId), SyndicationServlet.asLink(getRequest()
            .getRelativePathPrefixToContextRoot(), repositoryName, objectId, 0)));
   }
   protected Repository getRepository() {
@@ -217,43 +228,20 @@
      return commit;
   }
   protected String getShortObjectId(String objectId) {
      return objectId.substring(0, 8);
   }
   protected void addRefs(Repository r, RevCommit c) {
      add(new RefsPanel("refsPanel", repositoryName, c, JGitUtils.getAllRefs(r)));
   }
   protected void addFullText(String wicketId, String text, boolean substituteRegex) {
      String html = StringUtils.breakLinesForHtml(text);
      String html;
      if (substituteRegex) {
         Map<String, String> map = new HashMap<String, String>();
         // global regex keys
         if (GitBlit.getBoolean(Keys.regex.global, false)) {
            for (String key : GitBlit.getAllKeys(Keys.regex.global)) {
               if (!key.equals(Keys.regex.global)) {
                  String subKey = key.substring(key.lastIndexOf('.') + 1);
                  map.put(subKey, GitBlit.getString(key, ""));
               }
            }
         }
         // repository-specific regex keys
         List<String> keys = GitBlit.getAllKeys(Keys.regex._ROOT + "."
               + repositoryName.toLowerCase());
         for (String key : keys) {
            String subKey = key.substring(key.lastIndexOf('.') + 1);
            map.put(subKey, GitBlit.getString(key, ""));
         }
         for (Entry<String, String> entry : map.entrySet()) {
            String definition = entry.getValue().trim();
            String[] chunks = definition.split("!!!");
            if (chunks.length == 2) {
               html = html.replaceAll(chunks[0], chunks[1]);
            } else {
               logger.warn(entry.getKey()
                     + " improperly formatted.  Use !!! to separate match from replacement: "
                     + definition);
            }
         }
         html = GitBlit.self().processCommitMessage(repositoryName, text);
      } else {
         html = StringUtils.breakLinesForHtml(text);
      }
      add(new Label(wicketId, html).setEscapeModelStrings(false));
   }