]> source.dussan.org Git - gitblit.git/commitdiff
Fix bootstrap and angular resources 1107/head
authorMartin Spielmann <martin.spielmann@pingunaut.com>
Sun, 31 Jul 2016 15:34:17 +0000 (17:34 +0200)
committerMartin Spielmann <martin.spielmann@pingunaut.com>
Sun, 31 Jul 2016 15:34:17 +0000 (17:34 +0200)
.classpath
src/main/java/com/gitblit/wicket/ng/NgController.java
src/main/java/com/gitblit/wicket/pages/BasePage.html
src/main/java/com/gitblit/wicket/pages/BasePage.java
src/main/java/com/gitblit/wicket/resources/bootstrap/Bootstrap.java

index 3b00822337e84641f605a7e6657a0f470e9af0a9..d531303bd3e806ede95953d65a39fa46ccab1e68 100644 (file)
        <classpathentry kind="lib" path="ext/platform-3.4.0.jar" sourcepath="ext/src/platform-3.4.0.jar"/>
        <classpathentry kind="lib" path="ext/mockito-core-1.10.19.jar" sourcepath="ext/src/mockito-core-1.10.19.jar"/>
        <classpathentry kind="lib" path="ext/objenesis-2.1.jar" sourcepath="ext/src/objenesis-2.1.jar"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
                <attributes>
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
index 648a12d91928c85e39596d7c0da8788191a96555..65ba78cd3b078b5222596f7d6ce2ade069bac7d2 100644 (file)
@@ -17,13 +17,16 @@ package com.gitblit.wicket.ng;
 \r
 import java.text.MessageFormat;\r
 import java.util.HashMap;\r
+import java.util.List;\r
 import java.util.Map;\r
 \r
 import org.apache.wicket.Component;\r
 import org.apache.wicket.behavior.Behavior;\r
+import org.apache.wicket.markup.head.HeaderItem;\r
 import org.apache.wicket.markup.head.IHeaderResponse;\r
 import org.apache.wicket.markup.head.JavaScriptHeaderItem;\r
 import org.apache.wicket.request.resource.PackageResourceReference;\r
+import org.apache.wicket.resource.JQueryResourceReference;\r
 \r
 import com.google.gson.Gson;\r
 import com.google.gson.GsonBuilder;\r
@@ -56,7 +59,16 @@ public class NgController extends Behavior {
        @Override\r
        public void renderHead(Component component, IHeaderResponse response) {\r
                // add Google AngularJS reference\r
-               response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(NgController.class, "angular.js")));\r
+               response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(NgController.class, "angular.js"){\r
+                       private static final long serialVersionUID = 1L;\r
+\r
+                       @Override\r
+                       public List<HeaderItem> getDependencies() {\r
+                               List<HeaderItem> deps = super.getDependencies();\r
+                               deps.add(JavaScriptHeaderItem.forReference(JQueryResourceReference.get()));\r
+                               return deps;\r
+                       }\r
+               }));\r
 \r
                Gson gson = new GsonBuilder().create();\r
 \r
@@ -71,7 +83,7 @@ public class NgController extends Behavior {
                }\r
                line(sb, "}");\r
 \r
-               response.render(JavaScriptHeaderItem.forScript(sb.toString(), "angularController"));\r
+               response.render(JavaScriptHeaderItem.forScript(sb.toString(), "angularController-"+name));\r
        }\r
 \r
        private void line(StringBuilder sb, String line) {\r
index fe9cc48192c55b4d7df461a23de8dceec3b68e47..9b026982b34555e2b95ee935aee2c873d974476e 100644 (file)
@@ -10,6 +10,7 @@
                <meta name="viewport" content="width=device-width, initial-scale=1.0" />\r
                <meta http-equiv="X-UA-Compatible" content="IE=Edge" />\r
                <title wicket:id="title">[page title]</title>\r
+               \r
                <link rel="icon" href="gitblt-favicon.png" type="image/png" />\r
                <link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>\r
                <link rel="stylesheet" href="bootstrap/css/iconic.css"/>\r
@@ -48,7 +49,6 @@
                </style>\r
                \r
                <!-- Include scripts at end for faster page loading -->\r
-<!--           <script type="text/javascript" src="bootstrap/js/jquery.js"></script> -->\r
                <script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>                \r
                <wicket:container wicket:id="bottomScripts"></wicket:container>\r
        </body>\r
index 0c35bb4b0e63bac58e4be1284071e27e5e70992f..51e671c8eae14684fcb678b4d61ce654fc51eb21 100644 (file)
@@ -40,8 +40,10 @@ import org.apache.wicket.request.http.handler.RedirectRequestHandler;
 import org.apache.wicket.request.mapper.parameter.PageParameters;\r
 import org.apache.wicket.request.resource.ContextRelativeResourceReference;\r
 import org.apache.wicket.request.resource.JavaScriptResourceReference;\r
+import org.apache.wicket.resource.JQueryResourceReference;\r
 import org.apache.wicket.markup.head.CssHeaderItem;\r
 import org.apache.wicket.markup.head.IHeaderResponse;\r
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;\r
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.link.ExternalLink;\r
 import org.apache.wicket.markup.html.panel.FeedbackPanel;\r
@@ -67,6 +69,7 @@ import com.gitblit.wicket.CacheControl;
 import com.gitblit.wicket.GitBlitWebApp;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.resources.bootstrap.Bootstrap;\r
 \r
 public abstract class BasePage extends SessionPage {\r
 \r
@@ -96,9 +99,10 @@ public abstract class BasePage extends SessionPage {
        @Override\r
        public void renderHead(IHeaderResponse response) {\r
                super.renderHead(response);\r
+               response.render(JavaScriptHeaderItem.forReference(JQueryResourceReference.get()));\r
+               \r
                if (app().settings().getBoolean(Keys.web.useResponsiveLayout, true)) {\r
-                       response.render(CssHeaderItem.forReference(\r
-                                       new ContextRelativeResourceReference("/bootstrap/css/bootstrap-responsive.css", false)));\r
+                       response.render(CssHeaderItem.forReference(Application.get().getSharedResources().get(Bootstrap.BOOTSTRAP_RESPONSIVE_CSS_RESOURCE)));\r
                }\r
                if (app().settings().getBoolean(Keys.web.hideHeader, false)) {\r
                        response.render(CssHeaderItem.forReference(new ContextRelativeResourceReference("/hideheader.css", false)));\r
index f675af667c87085a702edd47829af363c3420ae7..0d0778d204ee3287a7b7c947b36ddf04f7bc1242 100644 (file)
@@ -1,14 +1,27 @@
 package com.gitblit.wicket.resources.bootstrap;
 
+import java.util.List;
+
+import org.apache.wicket.markup.head.HeaderItem;
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;
 import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.request.resource.CssPackageResource;
+import org.apache.wicket.request.resource.IResource;
 import org.apache.wicket.request.resource.PackageResourceReference;
+import org.apache.wicket.request.resource.SharedResourceReference;
+import org.apache.wicket.resource.JQueryResourceReference;
 
 
 public class Bootstrap {
+       
+       public static final String BOOTSTRAP_RESPONSIVE_CSS_RESOURCE = "bootstrap:responsiveCss";
 
        public static void install(WebApplication app) {
                app.mountResource("/bootstrap/css/bootstrap.css", new PackageResourceReference(Bootstrap.class, "css/bootstrap.css"));
-               app.mountResource("/bootstrap/css/bootstrap-responsive.css", new PackageResourceReference(Bootstrap.class, "css/bootstrap-responsive.css"));
+
+               app.getSharedResources().add(BOOTSTRAP_RESPONSIVE_CSS_RESOURCE, new CssPackageResource(Bootstrap.class, "css/bootstrap-responsive.css", null, null, null));
+               app.mountResource("/bootstrap/css/bootstrap-responsive.css", app.getSharedResources().get(BOOTSTRAP_RESPONSIVE_CSS_RESOURCE));
+
                app.mountResource("/bootstrap/css/iconic.css", new PackageResourceReference(Bootstrap.class, "css/iconic.css"));
 
                app.mountResource("/bootstrap/font/iconic_fill.afm", new PackageResourceReference(Bootstrap.class, "font/iconic_fill.afm"));
@@ -30,7 +43,16 @@ public class Bootstrap {
                app.mountResource("/bootstrap/img/glyphicons-halflings-white.png", new PackageResourceReference(Bootstrap.class, "img/glyphicons-halflings-white.png"));
                app.mountResource("/bootstrap/img/glyphicons-halflings.png", new PackageResourceReference(Bootstrap.class, "img/glyphicons-halflings.png"));
 
-               app.mountResource("/bootstrap/js/bootstrap.js", new PackageResourceReference(Bootstrap.class, "js/bootstrap.js"));
+               app.mountResource("/bootstrap/js/bootstrap.js", new PackageResourceReference(Bootstrap.class, "js/bootstrap.js"){
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       public List<HeaderItem> getDependencies() {
+                               List<HeaderItem> deps = super.getDependencies();
+                               deps.add(JavaScriptHeaderItem.forReference(JQueryResourceReference.get()));
+                               return deps;
+                       }
+               });
        }
 
 }