please also add a NOTICE and LICENSE file for this new module. Uli
On 17.05.2013 03:02, [email protected] wrote: > Updated Branches: > refs/heads/master 56a114812 -> 9e76c372b > > > Initial work on enabling CoffeeScript compilation > > > Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo > Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/bd26fb5c > Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/bd26fb5c > Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/bd26fb5c > > Branch: refs/heads/master > Commit: bd26fb5c6164e2027f8cd2bc401b883d463768c2 > Parents: 56a1148 > Author: Howard M. Lewis Ship <[email protected]> > Authored: Thu May 16 17:51:29 2013 -0700 > Committer: Howard M. Lewis Ship <[email protected]> > Committed: Thu May 16 17:51:29 2013 -0700 > > ---------------------------------------------------------------------- > build.gradle | 3 +- > settings.gradle | 2 +- > tapestry-wro4j/build.gradle | 13 ++ > .../wro4j/CoffeeScriptResourceCompiler.java | 98 +++++++++++++++ > .../tapestry5/wro4j/modules/WRO4JModule.java | 35 +++++ > .../src/test/groovy/t5/wro4j/pages/Index.groovy | 9 ++ > .../src/test/java/t5/wro4j/services/AppModule.java | 29 +++++ > .../test/resources/META-INF/modules/index.coffee | 5 + > tapestry-wro4j/src/test/resources/log4j.properties | 12 ++ > .../src/test/resources/t5/wro4j/pages/Index.tml | 24 ++++ > tapestry-wro4j/src/test/webapp/WEB-INF/web.xml | 19 +++ > 11 files changed, 247 insertions(+), 2 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/build.gradle > ---------------------------------------------------------------------- > diff --git a/build.gradle b/build.gradle > index cafec92..85bc99d 100755 > --- a/build.gradle > +++ b/build.gradle > @@ -21,7 +21,8 @@ project.ext.versions = [ > spock: "0.7-groovy-2.0", > hibernate: "4.1.2.Final", > groovy: "2.0.6", > - slf4j: "1.7.2" > + slf4j: "1.7.2", > + wro4j: "1.6.3" > ] > > // Provided so that the CI server can override the normal version number for > nightly builds. > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/settings.gradle > ---------------------------------------------------------------------- > diff --git a/settings.gradle b/settings.gradle > index de2c892..4338dbc 100644 > --- a/settings.gradle > +++ b/settings.gradle > @@ -3,4 +3,4 @@ include "tapestry-hibernate-core", "tapestry-hibernate", > "tapestry-jmx", "tapest > include "tapestry-beanvalidator", "tapestry-yuicompressor", "tapestry-jpa", > "tapestry-kaptcha" > include "tapestry-javadoc", "quickstart", "tapestry-clojure", > "tapestry-mongodb" > include "tapestry-test-data", 'tapestry-internal-test' > - > +include "tapestry-wro4j" > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/build.gradle > ---------------------------------------------------------------------- > diff --git a/tapestry-wro4j/build.gradle b/tapestry-wro4j/build.gradle > new file mode 100644 > index 0000000..f54304d > --- /dev/null > +++ b/tapestry-wro4j/build.gradle > @@ -0,0 +1,13 @@ > +description = "Integration with WRO4J to perform runtime CoffeeScript > compilation, JavaScript minimization, etc." > + > +dependencies { > + compile project(":tapestry-core") > + compile "ro.isdc.wro4j:wro4j-extensions:${versions.wro4j}", { > + exclude group: "org.codehaus.gmaven.runtime" > + exclude group: "com.github.lltyk" > + } > +} > + > +jar.manifest { > + attributes 'Tapestry-Module-Classes': > 'org.apache.tapestry5.wro4j.modules.WRO4JModule' > +} > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/src/main/java/org/apache/tapestry5/internal/wro4j/CoffeeScriptResourceCompiler.java > ---------------------------------------------------------------------- > diff --git > a/tapestry-wro4j/src/main/java/org/apache/tapestry5/internal/wro4j/CoffeeScriptResourceCompiler.java > > b/tapestry-wro4j/src/main/java/org/apache/tapestry5/internal/wro4j/CoffeeScriptResourceCompiler.java > new file mode 100644 > index 0000000..0f691ad > --- /dev/null > +++ > b/tapestry-wro4j/src/main/java/org/apache/tapestry5/internal/wro4j/CoffeeScriptResourceCompiler.java > @@ -0,0 +1,98 @@ > +// Copyright 2013 The Apache Software Foundation > +// > +// Licensed under the Apache License, Version 2.0 (the "License"); > +// you may not use this file except in compliance with the License. > +// You may obtain a copy of the License at > +// > +// http://www.apache.org/licenses/LICENSE-2.0 > +// > +// Unless required by applicable law or agreed to in writing, software > +// distributed under the License is distributed on an "AS IS" BASIS, > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > +// See the License for the specific language governing permissions and > +// limitations under the License. > + > +package org.apache.tapestry5.internal.wro4j; > + > +import org.apache.tapestry5.internal.services.assets.BytestreamCache; > +import org.apache.tapestry5.ioc.IOOperation; > +import org.apache.tapestry5.ioc.OperationTracker; > +import org.apache.tapestry5.ioc.Resource; > +import org.apache.tapestry5.services.assets.ResourceDependencies; > +import org.apache.tapestry5.services.assets.ResourceTransformer; > +import org.slf4j.Logger; > +import ro.isdc.wro.extensions.processor.js.RhinoCoffeeScriptProcessor; > +import ro.isdc.wro.extensions.processor.support.coffeescript.CoffeeScript; > +import ro.isdc.wro.model.resource.ResourceType; > +import ro.isdc.wro.model.resource.processor.ResourcePreProcessor; > + > +import java.io.*; > + > +/** > + * Compiles CoffeeScript to JavaScript, using {@link > RhinoCoffeeScriptProcessor}. > + * > + * @since 5.4 > + */ > +public class CoffeeScriptResourceCompiler implements ResourceTransformer > +{ > + private final Logger logger; > + > + private final OperationTracker tracker; > + > + private static final double NANOS_TO_MILLIS = 1.0d / 1000000.0d; > + > + private final ResourcePreProcessor compiler = > + new RhinoCoffeeScriptProcessor() > + { > + @Override > + protected CoffeeScript newCoffeeScript() > + { > + return new CoffeeScript(); > + } > + }; > + > + public CoffeeScriptResourceCompiler(Logger logger, OperationTracker > tracker) > + { > + this.logger = logger; > + this.tracker = tracker; > + } > + > + public String getTransformedContentType() > + { > + return "text/javascript"; > + } > + > + > + public InputStream transform(final Resource source, ResourceDependencies > dependencies) throws IOException > + { > + > + return tracker.perform(String.format("Compiling %s from CoffeeScript > to JavaScript", source), > + new IOOperation<InputStream>() > + { > + public InputStream perform() throws IOException > + { > + final long startTime = System.nanoTime(); > + > + > + ro.isdc.wro.model.resource.Resource res = > ro.isdc.wro.model.resource.Resource.create( > + source.toURL().toString(), > + ResourceType.JS); > + > + Reader reader = new > InputStreamReader(source.openStream()); > + ByteArrayOutputStream out = new > ByteArrayOutputStream(5000); > + Writer writer = new OutputStreamWriter(out); > + > + compiler.process(res, reader, writer); > + > + final long elapsedTime = System.nanoTime() - > startTime; > + > + > + logger.info(String.format("Compiled %s to JavaScript > in %.2f ms", > + source, > + ((double) elapsedTime) * NANOS_TO_MILLIS)); > + > + return new BytestreamCache(out).openStream(); > + } > + }); > + } > +} > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/src/main/java/org/apache/tapestry5/wro4j/modules/WRO4JModule.java > ---------------------------------------------------------------------- > diff --git > a/tapestry-wro4j/src/main/java/org/apache/tapestry5/wro4j/modules/WRO4JModule.java > > b/tapestry-wro4j/src/main/java/org/apache/tapestry5/wro4j/modules/WRO4JModule.java > new file mode 100644 > index 0000000..006448c > --- /dev/null > +++ > b/tapestry-wro4j/src/main/java/org/apache/tapestry5/wro4j/modules/WRO4JModule.java > @@ -0,0 +1,35 @@ > +// Copyright 2013 The Apache Software Foundation > +// > +// Licensed under the Apache License, Version 2.0 (the "License"); > +// you may not use this file except in compliance with the License. > +// You may obtain a copy of the License at > +// > +// http://www.apache.org/licenses/LICENSE-2.0 > +// > +// Unless required by applicable law or agreed to in writing, software > +// distributed under the License is distributed on an "AS IS" BASIS, > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > +// See the License for the specific language governing permissions and > +// limitations under the License. > + > +package org.apache.tapestry5.wro4j.modules; > + > +import org.apache.tapestry5.internal.wro4j.CoffeeScriptResourceCompiler; > +import org.apache.tapestry5.ioc.MappedConfiguration; > +import org.apache.tapestry5.ioc.annotations.Contribute; > +import org.apache.tapestry5.services.assets.ResourceTransformer; > +import org.apache.tapestry5.services.assets.StreamableResourceSource; > + > +/** > + * Configures CoffeeScript-to-JavaScript compilation. > + * > + * @since 5.4 > + */ > +public class WRO4JModule > +{ > + @Contribute(StreamableResourceSource.class) > + public static void > provideCoffeeScriptCompilation(MappedConfiguration<String, > ResourceTransformer> configuration) > + { > + configuration.addInstance("coffee", > CoffeeScriptResourceCompiler.class); > + } > +} > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/src/test/groovy/t5/wro4j/pages/Index.groovy > ---------------------------------------------------------------------- > diff --git a/tapestry-wro4j/src/test/groovy/t5/wro4j/pages/Index.groovy > b/tapestry-wro4j/src/test/groovy/t5/wro4j/pages/Index.groovy > new file mode 100644 > index 0000000..690577e > --- /dev/null > +++ b/tapestry-wro4j/src/test/groovy/t5/wro4j/pages/Index.groovy > @@ -0,0 +1,9 @@ > +package t5.wro4j.pages > + > +import org.apache.tapestry5.annotations.Import > + > +@Import(stack = "core", module = "index") > +class Index { > + > + > +} > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/src/test/java/t5/wro4j/services/AppModule.java > ---------------------------------------------------------------------- > diff --git a/tapestry-wro4j/src/test/java/t5/wro4j/services/AppModule.java > b/tapestry-wro4j/src/test/java/t5/wro4j/services/AppModule.java > new file mode 100644 > index 0000000..82792e1 > --- /dev/null > +++ b/tapestry-wro4j/src/test/java/t5/wro4j/services/AppModule.java > @@ -0,0 +1,29 @@ > +package t5.wro4j.services; > + > +import org.apache.tapestry5.SymbolConstants; > +import org.apache.tapestry5.ioc.MappedConfiguration; > +import org.apache.tapestry5.ioc.annotations.Contribute; > +import org.apache.tapestry5.ioc.annotations.SubModule; > +import org.apache.tapestry5.ioc.services.ApplicationDefaults; > +import org.apache.tapestry5.ioc.services.SymbolProvider; > +import org.apache.tapestry5.services.compatibility.Compatibility; > +import org.apache.tapestry5.services.compatibility.Trait; > +import org.apache.tapestry5.wro4j.modules.WRO4JModule; > + > +@SubModule(WRO4JModule.class) > +public class AppModule > +{ > + @Contribute(Compatibility.class) > + public static void disableOldStuff(MappedConfiguration<Trait, Boolean> > configuration) > + { > + configuration.add(Trait.INITIALIZERS, false); > + configuration.add(Trait.SCRIPTACULOUS, false); > + } > + > + @Contribute(SymbolProvider.class) > + @ApplicationDefaults > + public static void enableJQuery(MappedConfiguration<String, Object> > configuration) > + { > + > configuration.add(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER, > "jquery"); > + } > +} > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/src/test/resources/META-INF/modules/index.coffee > ---------------------------------------------------------------------- > diff --git a/tapestry-wro4j/src/test/resources/META-INF/modules/index.coffee > b/tapestry-wro4j/src/test/resources/META-INF/modules/index.coffee > new file mode 100644 > index 0000000..d8e9c1d > --- /dev/null > +++ b/tapestry-wro4j/src/test/resources/META-INF/modules/index.coffee > @@ -0,0 +1,5 @@ > +require ["t5/core/dom"], (dom) -> > + > + (dom "banner").update "Index module loaded !!!" > + > + > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/src/test/resources/log4j.properties > ---------------------------------------------------------------------- > diff --git a/tapestry-wro4j/src/test/resources/log4j.properties > b/tapestry-wro4j/src/test/resources/log4j.properties > new file mode 100644 > index 0000000..c69dbf4 > --- /dev/null > +++ b/tapestry-wro4j/src/test/resources/log4j.properties > @@ -0,0 +1,12 @@ > +log4j.rootCategory=INFO, A1 > + > +# A1 is set to be a ConsoleAppender. > +log4j.appender.A1=org.apache.log4j.ConsoleAppender > + > +# A1 uses PatternLayout. > +log4j.appender.A1.layout=org.apache.log4j.PatternLayout > +log4j.appender.A1.layout.ConversionPattern=[%p] %c{1} %m%n > + > +log4j.category.org.apache.tapestry5.modules.AssetsModule.ResourceMinimizer=debug > +log4j.category.org.apache.tapestry5.wro4j=debug > +log4j.category.org.apache.tapestry5.internal.wro4j=debug > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/src/test/resources/t5/wro4j/pages/Index.tml > ---------------------------------------------------------------------- > diff --git a/tapestry-wro4j/src/test/resources/t5/wro4j/pages/Index.tml > b/tapestry-wro4j/src/test/resources/t5/wro4j/pages/Index.tml > new file mode 100644 > index 0000000..026e53d > --- /dev/null > +++ b/tapestry-wro4j/src/test/resources/t5/wro4j/pages/Index.tml > @@ -0,0 +1,24 @@ > +<html> > +<head> > + <title>WRO4J Tests</title> > +</head> > + > + <div class="navbar navbar-inverse"> > + <div class="navbar-inner"> > + <div class="container"> > + > + <a class="brand" href="/">WRO4J Module Tests</a> > + </div> > + </div> > +</div> > + > +<div class="container"> > + > + <p>This page is used to demonstrate the integration of WRO4J.</p> > + > + > + <div class="alert alert-success" id="banner"/> > + > +</div> > + > +</html> > \ No newline at end of file > > http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/bd26fb5c/tapestry-wro4j/src/test/webapp/WEB-INF/web.xml > ---------------------------------------------------------------------- > diff --git a/tapestry-wro4j/src/test/webapp/WEB-INF/web.xml > b/tapestry-wro4j/src/test/webapp/WEB-INF/web.xml > new file mode 100644 > index 0000000..23e3a60 > --- /dev/null > +++ b/tapestry-wro4j/src/test/webapp/WEB-INF/web.xml > @@ -0,0 +1,19 @@ > +<?xml version="1.0" encoding="UTF-8"?> > +<!DOCTYPE web-app > + PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > + "http://java.sun.com/dtd/web-app_2_3.dtd"> > +<web-app> > + <display-name>Tapestry WRO4J Integration</display-name> > + <context-param> > + <param-name>tapestry.app-package</param-name> > + <param-value>t5.wro4j</param-value> > + </context-param> > + <filter> > + <filter-name>app</filter-name> > + <filter-class>org.apache.tapestry5.TapestryFilter</filter-class> > + </filter> > + <filter-mapping> > + <filter-name>app</filter-name> > + <url-pattern>/*</url-pattern> > + </filter-mapping> > +</web-app> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
