Skip to content

Commit 34f028f

Browse files
committed
Added showcase application for the transform module
1 parent 2779c79 commit 34f028f

12 files changed

Lines changed: 6032 additions & 0 deletions

File tree

‎showcase/pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<module>access-control</module>
1717
<module>composite-query</module>
1818
<module>rest-ws</module>
19+
<module>transform</module>
1920
<module>bookstore</module>
2021
</modules>
2122

‎showcase/transform/pom.xml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<artifactId>rewrite-showcase</artifactId>
8+
<groupId>org.ocpsoft.rewrite.showcase</groupId>
9+
<version>2.0.0-SNAPSHOT</version>
10+
<relativePath>../</relativePath>
11+
</parent>
12+
13+
<artifactId>rewrite-showcase-transform</artifactId>
14+
<packaging>war</packaging>
15+
16+
<dependencies>
17+
18+
<dependency>
19+
<groupId>org.jboss.spec</groupId>
20+
<artifactId>jboss-javaee-6.0</artifactId>
21+
<type>pom</type>
22+
<scope>provided</scope>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>org.ocpsoft.rewrite</groupId>
27+
<artifactId>rewrite-servlet</artifactId>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>org.ocpsoft.rewrite</groupId>
32+
<artifactId>rewrite-transform-markup</artifactId>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>org.ocpsoft.rewrite</groupId>
37+
<artifactId>rewrite-transform-less</artifactId>
38+
</dependency>
39+
40+
<dependency>
41+
<groupId>org.ocpsoft.rewrite</groupId>
42+
<artifactId>rewrite-transform-minify</artifactId>
43+
</dependency>
44+
45+
</dependencies>
46+
</project>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2011 <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.ocpsoft.rewrite.showcase.transform;
17+
18+
import javax.servlet.ServletContext;
19+
20+
import org.ocpsoft.rewrite.config.Configuration;
21+
import org.ocpsoft.rewrite.config.ConfigurationBuilder;
22+
import org.ocpsoft.rewrite.config.Direction;
23+
import org.ocpsoft.rewrite.servlet.config.Forward;
24+
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
25+
import org.ocpsoft.rewrite.servlet.config.Path;
26+
import org.ocpsoft.rewrite.servlet.config.Resource;
27+
import org.ocpsoft.rewrite.transform.Transform;
28+
import org.ocpsoft.rewrite.transform.less.Less;
29+
import org.ocpsoft.rewrite.transform.markup.Markdown;
30+
import org.ocpsoft.rewrite.transform.markup.Sass;
31+
import org.ocpsoft.rewrite.transform.markup.Textile;
32+
33+
public class TransformConfigurationProvider extends HttpConfigurationProvider
34+
{
35+
36+
@Override
37+
public Configuration getConfiguration(ServletContext context)
38+
{
39+
return ConfigurationBuilder.begin()
40+
41+
// Markdown
42+
.addRule()
43+
.when(Direction.isInbound()
44+
.and(Path.matches("/markdown/{name}.html"))
45+
.and(Resource.exists("/markdown/{name}.md")))
46+
.perform(Forward.to("/markdown/{name}.md")
47+
.and(Transform.with(Markdown.fullDocument()
48+
.withTitle("Markdown Demo")
49+
.addStylesheet(context.getContextPath() + "/common/bootstrap.css")
50+
.addStylesheet(context.getContextPath() + "/common/common.css"))))
51+
52+
// Textile
53+
.addRule()
54+
.when(Direction.isInbound()
55+
.and(Path.matches("/textile/{name}.html"))
56+
.and(Resource.exists("/textile/{name}.textile")))
57+
.perform(Forward.to("/textile/{name}.textile")
58+
.and(Transform.with(Textile.fullDocument()
59+
.withTitle("Textile Demo")
60+
.addStylesheet(context.getContextPath() + "/common/bootstrap.css")
61+
.addStylesheet(context.getContextPath() + "/common/common.css"))))
62+
63+
// LESS
64+
.addRule()
65+
.when(Direction.isInbound()
66+
.and(Path.matches("/less/{name}.css"))
67+
.and(Resource.exists("/less/{name}.less")))
68+
.perform(Forward.to("/less/{name}.less")
69+
.and(Transform.with(Less.compiler())))
70+
71+
// Sass
72+
.addRule()
73+
.when(Direction.isInbound()
74+
.and(Path.matches("/sass/{name}.css"))
75+
.and(Resource.exists("/sass/{name}.scss")))
76+
.perform(Forward.to("/sass/{name}.scss")
77+
.and(Transform.with(Sass.compiler())));
78+
79+
}
80+
81+
@Override
82+
public int priority()
83+
{
84+
return 0;
85+
}
86+
87+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.ocpsoft.rewrite.showcase.transform.TransformConfigurationProvider
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
4+
5+
</web-app>

0 commit comments

Comments
 (0)