More work on the sample extension

git-svn-id: http://google-refine.googlecode.com/svn/trunk@974 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-06-15 23:21:08 +00:00
parent 17f1dc2e6f
commit 7ba97c61ad
8 changed files with 100 additions and 0 deletions

View File

@ -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);
}

View File

@ -0,0 +1,3 @@
description = Gridworks Sample Extension
templating.macros = macros.vm

View File

@ -0,0 +1,21 @@
#*
* Access this page at the URL /extensions/sample/
*#
<html>
<head>
<title>Sample Extension</title>
</head>
<body>
<h1>Sample Extension</h1>
<p>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.
</p>
<p>Here is a sample list using a veloci-macro:</p>
#set( $greatlakes = ["Superior","Michigan","Huron","Erie","Ontario"] )
#makeAList( $greatlakes )
</body>
</html>

View File

@ -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 )
<ul>
#foreach($item in $list)
<li>$item</li>
#end
</ul>
#end

View File

@ -0,0 +1,3 @@
// This file is added to the /project page
var SampleExtension = {};

View File

@ -0,0 +1,5 @@
// LESS styles
// For documentation, see http://lesscss.org/
@color: blue;

View File

@ -21,6 +21,9 @@ butterfly.url = /
butterfly.modules.path = modules
butterfly.modules.path = ../../extensions/
# Add more paths here if your extensions live elsewhere.
# Relative paths are relative to gridworks/main/webapp/
butterfly.modules.wirings = WEB-INF/modules.properties
# ---------- Clustering ----

View File

@ -4,4 +4,9 @@
core = /
# Sample extension's wirings
# client-side resources of this module will be accessible under this URL path
sample-extension = /extensions/sample/
jython = /extensions/jython/