diff --git a/extensions/sample-extension/module/MOD-INF/controller.js b/extensions/sample-extension/module/MOD-INF/controller.js new file mode 100644 index 000000000..5a3b375e3 --- /dev/null +++ b/extensions/sample-extension/module/MOD-INF/controller.js @@ -0,0 +1,46 @@ +var html = "text/html"; +var encoding = "UTF-8"; +var ClientSideResourceManager = Packages.com.metaweb.gridworks.ClientSideResourceManager; + +/* + * Function invoked to initialize the extension. + */ +/* +function init() { + # Packages.java.lang.System.err.println("Initializing sample extension"); + # Packages.java.lang.System.err.println(module.getMountPoint()); + + // Script files to inject into /project page + ClientSideResourceManager.addPaths( + "project/scripts", + module, + [ + "scripts/project-injection.js" + ] + ); + + // Style files to inject into /project page + ClientSideResourceManager.addPaths( + "project/styles", + module, + [ + "styles/project-injection.less" + ] + ); +} +*/ + +/* + * Function invoked to handle each request in a custom way. + */ +function process(path, request, response) { + // Analyze path and handle this request yourself. + + if (path == "/" || path == "") { + send(request, response, "index.vt", context); + } +} + +function send(request, response, template, context) { + butterfly.sendTextFromTemplate(request, response, context, template, encoding, html); +} diff --git a/extensions/sample-extension/module/MOD-INF/module.properties b/extensions/sample-extension/module/MOD-INF/module.properties new file mode 100644 index 000000000..e442fa6e2 --- /dev/null +++ b/extensions/sample-extension/module/MOD-INF/module.properties @@ -0,0 +1,3 @@ +description = Gridworks Sample Extension + +templating.macros = macros.vm diff --git a/extensions/sample-extension/module/index.vt b/extensions/sample-extension/module/index.vt new file mode 100644 index 000000000..f28cae582 --- /dev/null +++ b/extensions/sample-extension/module/index.vt @@ -0,0 +1,21 @@ +#* + * Access this page at the URL /extensions/sample/ + *# + +
+If an extension needs its own page, then this is such an example. + However, mostly, extensions only need to inject their own scripts + and styles into the /project page. +
+ +Here is a sample list using a veloci-macro:
+ + #set( $greatlakes = ["Superior","Michigan","Huron","Erie","Ontario"] ) + #makeAList( $greatlakes ) + + \ No newline at end of file diff --git a/extensions/sample-extension/module/macros.vm b/extensions/sample-extension/module/macros.vm new file mode 100644 index 000000000..18a83bfce --- /dev/null +++ b/extensions/sample-extension/module/macros.vm @@ -0,0 +1,14 @@ +#* + This file contains common velocity macros used in all .vt files. + For Velocity documentation, see: + + http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html +*# + +#macro( makeAList $list ) +