Skip to content

Commit 846c4bb

Browse files
committed
Cleanup wrong jade and swagger upgrade via pull request
1 parent 72a35f9 commit 846c4bb

File tree

5 files changed

+42
-46
lines changed

5 files changed

+42
-46
lines changed

doc/doc/jade/jade.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636
```
3737

38-
Templates are loaded from root of classpath: ```/``` and must ends with: ```.jade``` file extension.
38+
Templates are loaded from root of classpath: ```/``` and must ends with: ```.html``` file extension.
3939

4040
## request locals
4141

@@ -60,15 +60,15 @@ Then from template:
6060

6161
## template loader
6262

63-
Templates are loaded from the root of classpath and must ends with ```.jade```. You can change the extensions too:
63+
Templates are loaded from the root of classpath and must ends with ```.html```. Using a custom file extension:
6464

6565
```java
6666
{
67-
use(new Jade(".html"));
67+
use(new Jade(".jade"));
6868
}
6969
```
7070

71-
Keep in mind if you change it file name must ends with: ```.html.jade```.
71+
Default file extension is: `.html`.
7272

7373
## template cache
7474

modules/coverage-report/src/test/java/org/jooby/issues/Issue131.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Issue131 extends ServerFeature {
77

88
{
99

10-
assets("/swagger/ui/**", "/META-INF/resources/webjars/swagger-ui/3.1.6/{0}");
10+
assets("/swagger/ui/**", "/META-INF/resources/webjars/swagger-ui/3.9.3/{0}");
1111

1212
}
1313

@@ -16,6 +16,6 @@ public void largeFileFromInputStream() throws Exception {
1616
request()
1717
.get("/swagger/ui/swagger-ui.js")
1818
.expect(200)
19-
.header("Content-Length", 296283);
19+
.header("Content-Length", 349262);
2020
}
2121
}

modules/jooby-apitool/src/main/java/org/jooby/apitool/ApiTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public Options theme(String theme) {
614614

615615
private static final String RAML_STATIC = "/META-INF/resources/webjars/api-console/3.0.17/dist/";
616616

617-
private static final String SWAGGER_STATIC = "/META-INF/resources/webjars/swagger-ui/3.1.6/";
617+
private static final String SWAGGER_STATIC = "/META-INF/resources/webjars/swagger-ui/3.9.3/";
618618

619619
private static final String SWAGGER_THEME = "/META-INF/resources/webjars/swagger-ui-themes/3.0.0/themes/3.x/";
620620

modules/jooby-jade/src/main/java/org/jooby/jade/Jade.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,16 @@
203203
*/
204204
package org.jooby.jade;
205205

206+
import com.google.inject.Binder;
207+
import com.google.inject.multibindings.Multibinder;
208+
import com.typesafe.config.Config;
209+
import de.neuland.jade4j.JadeConfiguration;
210+
import de.neuland.jade4j.template.ClasspathTemplateLoader;
211+
import de.neuland.jade4j.template.TemplateLoader;
206212
import static java.util.Objects.requireNonNull;
213+
import org.jooby.Env;
214+
import org.jooby.Jooby;
215+
import org.jooby.Renderer;
207216

208217
import java.io.FileNotFoundException;
209218
import java.io.IOException;
@@ -213,18 +222,6 @@
213222
import java.util.function.BiConsumer;
214223
import java.util.function.Consumer;
215224

216-
import org.jooby.Env;
217-
import org.jooby.Jooby;
218-
import org.jooby.Renderer;
219-
220-
import com.google.inject.Binder;
221-
import com.google.inject.multibindings.Multibinder;
222-
import com.typesafe.config.Config;
223-
224-
import de.neuland.jade4j.JadeConfiguration;
225-
import de.neuland.jade4j.template.ClasspathTemplateLoader;
226-
import de.neuland.jade4j.template.TemplateLoader;
227-
228225
/**
229226
* <h1>jade</h1>
230227
* <p>
@@ -251,9 +248,7 @@
251248
* </pre>
252249
*
253250
* <p>
254-
* Templates are loaded from root of classpath: <code>/</code> and must ends with:
255-
* <code>.jade</code>
256-
* file extension.
251+
* Templates are loaded from root of classpath: <code>/</code>.
257252
* </p>
258253
*
259254
* <h2>req locals</h2>
@@ -279,18 +274,17 @@
279274
*
280275
* <h2>template loader</h2>
281276
* <p>
282-
* Templates are loaded from the root of classpath and must ends with <code>.jade</code>. You can
283-
* change the extensions too:
277+
* Templates are loaded from the root of classpath. Using a custom file extension:
284278
* </p>
285279
*
286280
* <pre>
287281
* {
288-
* use(new Jade(".html"));
282+
* use(new Jade(".jade"));
289283
* }
290284
* </pre>
291285
*
292286
* <p>
293-
* Keep in mind if you change it file name must ends with: <code>.html.jade</code>.
287+
* Default file extension is: <code>.html</code>.
294288
* </p>
295289
*
296290
* <h2>template cache</h2>
@@ -326,6 +320,10 @@ public long getLastModified(final String name) throws IOException {
326320
return loader.getLastModified(name);
327321
}
328322

323+
@Override public String getExtension() {
324+
return loader.getExtension();
325+
}
326+
329327
@Override
330328
public Reader getReader(final String name) throws IOException {
331329
try {
@@ -399,7 +397,7 @@ public void configure(final Env env, final Config conf, final Binder binder) {
399397
sharedVariables.put("xss", new XssHelper(env));
400398
jadeconf.setSharedVariables(sharedVariables);
401399

402-
jadeconf.setTemplateLoader(new ClasspathTemplateLoader());
400+
jadeconf.setTemplateLoader(new ClasspathTemplateLoader("UTF-8", suffix));
403401

404402
if (callback != null) {
405403
callback.accept(jadeconf, conf);

modules/jooby-jade/src/test/java/org/jooby/jade/JadeTest.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
package org.jooby.jade;
22

3+
import com.google.inject.Binder;
4+
import com.google.inject.binder.AnnotatedBindingBuilder;
5+
import com.google.inject.binder.LinkedBindingBuilder;
6+
import com.google.inject.multibindings.Multibinder;
7+
import com.typesafe.config.Config;
8+
import de.neuland.jade4j.JadeConfiguration;
9+
import de.neuland.jade4j.template.ClasspathTemplateLoader;
10+
import de.neuland.jade4j.template.TemplateLoader;
311
import static org.easymock.EasyMock.eq;
412
import static org.easymock.EasyMock.expect;
513
import static org.easymock.EasyMock.isA;
6-
import static org.junit.Assert.assertEquals;
7-
import static org.junit.Assert.assertNotNull;
8-
import static org.junit.Assert.fail;
9-
10-
import java.io.FileNotFoundException;
11-
import java.io.Reader;
12-
import java.util.HashMap;
13-
import java.util.Map;
14-
1514
import org.jooby.Env;
1615
import org.jooby.Renderer;
1716
import org.jooby.test.MockUnit;
1817
import org.jooby.test.MockUnit.Block;
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertNotNull;
20+
import static org.junit.Assert.fail;
1921
import org.junit.Test;
2022
import org.junit.runner.RunWith;
2123
import org.powermock.core.classloader.annotations.PrepareForTest;
2224
import org.powermock.modules.junit4.PowerMockRunner;
2325

24-
import com.google.inject.Binder;
25-
import com.google.inject.binder.AnnotatedBindingBuilder;
26-
import com.google.inject.binder.LinkedBindingBuilder;
27-
import com.google.inject.multibindings.Multibinder;
28-
import com.typesafe.config.Config;
29-
30-
import de.neuland.jade4j.JadeConfiguration;
31-
import de.neuland.jade4j.template.ClasspathTemplateLoader;
32-
import de.neuland.jade4j.template.TemplateLoader;
26+
import java.io.FileNotFoundException;
27+
import java.io.Reader;
28+
import java.util.HashMap;
29+
import java.util.Map;
3330

3431
@RunWith(PowerMockRunner.class)
3532
@PrepareForTest({Jade.class, JadeConfiguration.class, Multibinder.class, HashMap.class })
@@ -150,7 +147,8 @@ private Block jade(final String suffix, final boolean caching, final boolean pre
150147
jadeConfiguration.setSharedVariables(sharedVariables);
151148

152149
ClasspathTemplateLoader classpathTemplateLoader = unit
153-
.mockConstructor(ClasspathTemplateLoader.class);
150+
.constructor(ClasspathTemplateLoader.class)
151+
.build("UTF-8", suffix);
154152
jadeConfiguration.setTemplateLoader(classpathTemplateLoader);
155153
expect(jadeConfiguration.getTemplateLoader()).andReturn(classpathTemplateLoader);
156154

0 commit comments

Comments
 (0)