|
CajaCajole
"Cajoling" is what we call the process of turning Caja input into JavaScript.
The cajoler is written in Java and can be run either from the command line or a web service (of which the CajaPlayground is an instance). Running the cajoler yourselfObtain a Caja buildTo cajole your input, first build Caja from source. Download. The source is in SVN. We assume you have downloaded it to a directory called: ./google-caja Compile. Ensure you have version 1.7 of Apache Ant. Then compile as follows: cd google-caja/src ant jars You should now have a directory called ant-jars, relative to your current directory. Go back to your google-caja directory: cd .. Command-line cajolingPlain HTML. To cajole a plain HTML+JavaScript snippet, do the following: bin/cajole_html -i <inputHtmlUrl> -o <targetJsFile> where: <inputHtmlFile> - The absolute URL of the input HTML snippet, such as file:/Users/example/test.html. <targetJsFile> - The file path where you want your JavaScript module function to be stored, such as ./test-cajoled.js. cajole_html defaults to generating separate HTML and JavaScript files, which is appropriate if you are going to be embedding the HTML in a host page. If you are dynamically loading modules, or if there is no HTML in the input, then you can pass --only_js_emitted. To see other available options, run bin/cajole_html with no arguments. Cajoler web serviceThe cajoling service is appropriate when you want the client (browser) to request third-party gadgets/modules to be cajoled at runtime (as opposed to choosing the content to be cajoled on your own server). The cajita-module.js library works well with the cajoling service. To start the Cajoler web service, download Caja as above, build it with ant playground, then do ant runserver. You can then use the service at http://localhost:8080/cajole. The parameters to the service are somewhat documented. A sample invocation (line breaks added): http://caja.appspot.com/cajole
?url=http%3A%2F%2Fwww.thinkfu.com%2Ftrivial.html
&input-mime-type=text/html
&output-mime-type=application/javascriptThe url is fetched and used as the input. The input-mime-type specifies what kind of content to expect there; in particular, it is usually either a HTML file possibly with embedded JavaScript, text/html, or a JavaScript file, application/javascript. The output-mime-type specifies what kind of content to return. It may be:
| |
It looks like this page needs to be integrated into the TOC.
in my case, i had to run 'ant jars' in directory 'google-caja', not in 'google-caja/src'
The command "cajole_html" appears to have been renamed "cajole".