Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Quick Start

algesten edited this page · 13 revisions

For the impatient.

Get the jar

Using maven

<dependencies>
  ...
  <dependency>
    <groupId>foodev</groupId>
    <artifactId>fnug</artifactId>
    <version>0.28</version>
  </dependency>
 ...
</dependencies>

<repositories>
 ...
  <repository>
    <id>algesten</id>
    <url>http://algesten.github.com/maven2/releases</url>
  </repository>
 ...
</repositories>

By hand

Download it from here: http://algesten.github.com/maven2/releases/foodev/fnug/

Configure the bundle (example using maven)

Config files and resources MUST be on the classpath

File layout

src/main/resources/bundles.js                             <-- config file
src/main/resources/js/
src/main/resources/js/mypackage/
src/main/resources/js/mypackage/sourcefile1.js
src/main/resources/js/mypackage/sourcefile2.js
src/main/resources/js/mypackage/styles.css
...
src/main/webapp/WEB-INF/web.xml                    <-- servlet pointing to config
src/main/webapp/index.html                                <-- loads js/css bundle

sourcefile1.js

/**
 * @requires mypackage/sourcefile2.js                 <-- depends on sourcefile2.js
 * @requires mypackage/styles.css                     <-- and on styles.css
 */
 function foo() {
    ...
 }

bundles.js

{
    mypackage: {
        basePath: '/js/'   <-- base path of mypackage from classpath root.
        files: [
            'mypackage/sourcefile.js'     <-- array of "entry" files for dependency resolution.
        ],
        // Optional JsLint string. 
        // jsLint: '/*jslint bitwise: true, regexp: true, browser: true, confusion: true, continue: true, sloppy: true, vars: true, plusplus: true, maxerr: 50, maxlen: 120, indent: 4 */',
        // Optional check modified interval (ms). Defaults to 3000.
        // checkModified: 3000
    }
}

web.xml

<servlet>
   <servlet-name>fnug</servlet-name>
   <servlet-class>fnug.ResourceServlet</servlet-class>
   <init-param>
       <param-name>config</param-name>
       <param-value>/bundles.js</param-value>                  <-- points to config file from classpath root.
   </init-param>
   <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>fnug</servlet-name>
    <url-pattern>/rs/*</url-pattern>
</servlet-mapping>

index.html

<head>
  <script type="text/javascript" src="/rs/mypackage.js"></script>  <-- loads all bundle dependencies (and css).
</head>
Something went wrong with that request. Please try again.