James Moger
2015-11-22 ed552ba47c02779c270ffd62841d6d1048dade70
src/main/java/com/gitblit/wicket/pages/BasePage.java
@@ -42,6 +42,8 @@
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.resources.JavascriptResourceReference;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.protocol.http.RequestUtils;
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
@@ -242,7 +244,7 @@
   protected void setupPage(String repositoryName, String pageName) {
      add(new Label("title", getPageTitle(repositoryName)));
      getBottomScriptContainer();
      String rootLinkUrl = app().settings().getString(Keys.web.rootLink, urlFor(GitBlitWebApp.get().getHomePage(), null).toString());
      ExternalLink rootLink = new ExternalLink("rootLink", rootLinkUrl);
      WicketUtils.setHtmlTooltip(rootLink, app().settings().getString(Keys.web.siteName, Constants.NAME));
@@ -506,4 +508,40 @@
      return sb.toString();
   }
   private RepeatingView getBottomScriptContainer() {
      RepeatingView bottomScriptContainer = (RepeatingView) get("bottomScripts");
      if (bottomScriptContainer == null) {
         bottomScriptContainer = new RepeatingView("bottomScripts");
         bottomScriptContainer.setRenderBodyOnly(true);
         add(bottomScriptContainer);
      }
      return bottomScriptContainer;
   }
   /**
    * Adds a HTML script element loading the javascript designated by the given path.
    *
    * @param scriptPath
    *            page-relative path to the Javascript resource; normally starts with "scripts/"
    */
   protected void addBottomScript(String scriptPath) {
      RepeatingView bottomScripts = getBottomScriptContainer();
      Label script = new Label(bottomScripts.newChildId(), "<script type='text/javascript' src='"
            + urlFor(new JavascriptResourceReference(this.getClass(), scriptPath)) + "'></script>\n");
      bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true));
   }
   /**
    * Adds a HTML script element containing the given code.
    *
    * @param code
    *            inline script code
    */
   protected void addBottomScriptInline(String code) {
      RepeatingView bottomScripts = getBottomScriptContainer();
      Label script = new Label(bottomScripts.newChildId(),
            "<script type='text/javascript'>/*<![CDATA[*/\n" + code + "\n//]]>\n</script>\n");
      bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true));
   }
}