Skip to content

Commit 48bddd4

Browse files
author
Martin Spielmann
committed
Fix bootstrap and angular resources
1 parent e366f57 commit 48bddd4

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<classpathentry kind="lib" path="ext/platform-3.4.0.jar" sourcepath="ext/src/platform-3.4.0.jar"/>
113113
<classpathentry kind="lib" path="ext/mockito-core-1.10.19.jar" sourcepath="ext/src/mockito-core-1.10.19.jar"/>
114114
<classpathentry kind="lib" path="ext/objenesis-2.1.jar" sourcepath="ext/src/objenesis-2.1.jar"/>
115-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
115+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
116116
<attributes>
117117
<attribute name="maven.pomderived" value="true"/>
118118
</attributes>

src/main/java/com/gitblit/wicket/ng/NgController.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717

1818
import java.text.MessageFormat;
1919
import java.util.HashMap;
20+
import java.util.List;
2021
import java.util.Map;
2122

2223
import org.apache.wicket.Component;
2324
import org.apache.wicket.behavior.Behavior;
25+
import org.apache.wicket.markup.head.HeaderItem;
2426
import org.apache.wicket.markup.head.IHeaderResponse;
2527
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
2628
import org.apache.wicket.request.resource.PackageResourceReference;
29+
import org.apache.wicket.resource.JQueryResourceReference;
2730

2831
import com.google.gson.Gson;
2932
import com.google.gson.GsonBuilder;
@@ -56,7 +59,16 @@ public void addVariable(String name, Object o) {
5659
@Override
5760
public void renderHead(Component component, IHeaderResponse response) {
5861
// add Google AngularJS reference
59-
response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(NgController.class, "angular.js")));
62+
response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(NgController.class, "angular.js"){
63+
private static final long serialVersionUID = 1L;
64+
65+
@Override
66+
public List<HeaderItem> getDependencies() {
67+
List<HeaderItem> deps = super.getDependencies();
68+
deps.add(JavaScriptHeaderItem.forReference(JQueryResourceReference.get()));
69+
return deps;
70+
}
71+
}));
6072

6173
Gson gson = new GsonBuilder().create();
6274

@@ -71,7 +83,7 @@ public void renderHead(Component component, IHeaderResponse response) {
7183
}
7284
line(sb, "}");
7385

74-
response.render(JavaScriptHeaderItem.forScript(sb.toString(), "angularController"));
86+
response.render(JavaScriptHeaderItem.forScript(sb.toString(), "angularController-"+name));
7587
}
7688

7789
private void line(StringBuilder sb, String line) {

src/main/java/com/gitblit/wicket/pages/BasePage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1111
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
1212
<title wicket:id="title">[page title]</title>
13+
1314
<link rel="icon" href="gitblt-favicon.png" type="image/png" />
1415
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
1516
<link rel="stylesheet" href="bootstrap/css/iconic.css"/>
@@ -48,7 +49,6 @@
4849
</style>
4950

5051
<!-- Include scripts at end for faster page loading -->
51-
<!-- <script type="text/javascript" src="bootstrap/js/jquery.js"></script> -->
5252
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
5353
<wicket:container wicket:id="bottomScripts"></wicket:container>
5454
</body>

src/main/java/com/gitblit/wicket/pages/BasePage.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
import org.apache.wicket.request.mapper.parameter.PageParameters;
4141
import org.apache.wicket.request.resource.ContextRelativeResourceReference;
4242
import org.apache.wicket.request.resource.JavaScriptResourceReference;
43+
import org.apache.wicket.resource.JQueryResourceReference;
4344
import org.apache.wicket.markup.head.CssHeaderItem;
4445
import org.apache.wicket.markup.head.IHeaderResponse;
46+
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
4547
import org.apache.wicket.markup.html.basic.Label;
4648
import org.apache.wicket.markup.html.link.ExternalLink;
4749
import org.apache.wicket.markup.html.panel.FeedbackPanel;
@@ -67,6 +69,7 @@
6769
import com.gitblit.wicket.GitBlitWebApp;
6870
import com.gitblit.wicket.GitBlitWebSession;
6971
import com.gitblit.wicket.WicketUtils;
72+
import com.gitblit.wicket.resources.bootstrap.Bootstrap;
7073

7174
public abstract class BasePage extends SessionPage {
7275

@@ -96,9 +99,10 @@ protected Logger logger() {
9699
@Override
97100
public void renderHead(IHeaderResponse response) {
98101
super.renderHead(response);
102+
response.render(JavaScriptHeaderItem.forReference(JQueryResourceReference.get()));
103+
99104
if (app().settings().getBoolean(Keys.web.useResponsiveLayout, true)) {
100-
response.render(CssHeaderItem.forReference(
101-
new ContextRelativeResourceReference("/bootstrap/css/bootstrap-responsive.css", false)));
105+
response.render(CssHeaderItem.forReference(Application.get().getSharedResources().get(Bootstrap.BOOTSTRAP_RESPONSIVE_CSS_RESOURCE)));
102106
}
103107
if (app().settings().getBoolean(Keys.web.hideHeader, false)) {
104108
response.render(CssHeaderItem.forReference(new ContextRelativeResourceReference("/hideheader.css", false)));

src/main/java/com/gitblit/wicket/resources/bootstrap/Bootstrap.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
package com.gitblit.wicket.resources.bootstrap;
22

3+
import java.util.List;
4+
5+
import org.apache.wicket.markup.head.HeaderItem;
6+
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
37
import org.apache.wicket.protocol.http.WebApplication;
8+
import org.apache.wicket.request.resource.CssPackageResource;
9+
import org.apache.wicket.request.resource.IResource;
410
import org.apache.wicket.request.resource.PackageResourceReference;
11+
import org.apache.wicket.request.resource.SharedResourceReference;
12+
import org.apache.wicket.resource.JQueryResourceReference;
513

614

715
public class Bootstrap {
16+
17+
public static final String BOOTSTRAP_RESPONSIVE_CSS_RESOURCE = "bootstrap:responsiveCss";
818

919
public static void install(WebApplication app) {
1020
app.mountResource("/bootstrap/css/bootstrap.css", new PackageResourceReference(Bootstrap.class, "css/bootstrap.css"));
11-
app.mountResource("/bootstrap/css/bootstrap-responsive.css", new PackageResourceReference(Bootstrap.class, "css/bootstrap-responsive.css"));
21+
22+
app.getSharedResources().add(BOOTSTRAP_RESPONSIVE_CSS_RESOURCE, new CssPackageResource(Bootstrap.class, "css/bootstrap-responsive.css", null, null, null));
23+
app.mountResource("/bootstrap/css/bootstrap-responsive.css", app.getSharedResources().get(BOOTSTRAP_RESPONSIVE_CSS_RESOURCE));
24+
1225
app.mountResource("/bootstrap/css/iconic.css", new PackageResourceReference(Bootstrap.class, "css/iconic.css"));
1326

1427
app.mountResource("/bootstrap/font/iconic_fill.afm", new PackageResourceReference(Bootstrap.class, "font/iconic_fill.afm"));
@@ -30,7 +43,16 @@ public static void install(WebApplication app) {
3043
app.mountResource("/bootstrap/img/glyphicons-halflings-white.png", new PackageResourceReference(Bootstrap.class, "img/glyphicons-halflings-white.png"));
3144
app.mountResource("/bootstrap/img/glyphicons-halflings.png", new PackageResourceReference(Bootstrap.class, "img/glyphicons-halflings.png"));
3245

33-
app.mountResource("/bootstrap/js/bootstrap.js", new PackageResourceReference(Bootstrap.class, "js/bootstrap.js"));
46+
app.mountResource("/bootstrap/js/bootstrap.js", new PackageResourceReference(Bootstrap.class, "js/bootstrap.js"){
47+
private static final long serialVersionUID = 1L;
48+
49+
@Override
50+
public List<HeaderItem> getDependencies() {
51+
List<HeaderItem> deps = super.getDependencies();
52+
deps.add(JavaScriptHeaderItem.forReference(JQueryResourceReference.get()));
53+
return deps;
54+
}
55+
});
3456
}
3557

3658
}

0 commit comments

Comments
 (0)