Posts Tagged ‘Caja’

Caja 简易 安装 配置 小结


26 9月
Caja project: http://code.google.com/p/google-caja/ 安装及running方面的细节: http://code.google.com/p/google-caja/wiki/RunningCaja http://code.google.com/p/google-caja/wiki/CajaCajole 大概小结一下步骤: 先确认自己环境是否都具备: Caja requires * JDK 6 * The subversion version manager * The Apache Ant build system. * The JUnit testing framework. Just drop junit.jar in the $ANT_HOME/lib directory you set up for Ant. 之后按照 http://code.google.com/p/google-caja/source/checkout 的方法 svn checkout http://google-caja.googlecode.com/svn/trunk/ google-caja Then, from the command line:
$ cd google-caja
$ ant
If Ant is properly installed, you should see the following:
Buildfile: build.xml

dirs:
    [mkdir] Created dir: ...
...

docs:
  [javadoc] Generating javadoc
...

BUILD SUCCESSFUL
Total time: 5 seconds
如出现问题,可参考上面原文链接中的细节,里面有一些解决方案,反正我没碰到问题。 下面说下running,caja有2种方式来玩,一种是直接command-line,另外一种是web service。 Anyway,run these first:
cd google-caja/src
ant jars
Command-line的官网说明还蛮清楚的,直接贴了:

Command-line cajoling

OpenSocial. To cajole an OpenSocial gadget, do the following:
bin/cajole_gadget -i <sourceGadgetUrl> -o <targetGadgetFile>
where:
<sourcegadgeturl>
- The absolute URL of a gadget spec, such as http://example.com/listfriends.xml or file:/Users/example/listfriends.xml.
<targetgadgetfile>
- The file path where you want your Cajoled gadget spec to be stored, such as ./listfriends-cajoled.xml.
Plain 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. 如果你是要让第三方来嵌入的话,那基本webservice是唯一的选择了。 貌似玩webservice的话,只要下载完以后,直接跑一句: ant playground 然后,以后运行直接: ant runserver 就可以了。然后可以访问 http://localhost:8080/ 初试下效果。(官网说是http://localhost:8080/cajole,但貌似我试了是没有"cajole"的,可能配置问题? Ok, 下面有2个不错的示例可以看一下的,配合着学一下怎么实时地在代码container里面玩这个webservice。 http://localhost/google-caja/src/com/google/caja/demos/container/container-trivial.html http://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/demos/container/container-interaction.html 细节不多说了(其实我也没怎么细看,随手改了一点实验了下而已 - -),大家自己在自己机器上玩吧。 下面是一些资料型的供查阅: caja 可以防哪些attack:http://code.google.com/p/google-caja/wiki/AttackVectors 关于caja这个语言的资料(有空从这章开始一直把后面的章节也看到底吧,我还没看 = =):http://code.google.com/p/google-caja/wiki/CajaOverview HostTool的具体用法说明:http://code.google.com/p/google-caja/wiki/HostTools 嗯,暂时小结到这边,其他还有很多资料我还没有看过的,所以就不列了。 因其他事务缠身,caja研究暂时至此,有时间再继续钻研细节代码相关了。 P.S. Oh, BTW, 我试了在contrainer里面嵌入mootools,之后基本就是杯具了,跑了3分钟,期间我这台公司的破机器的风扇狂转得像直升机一样的。。。无敌了。。。之后试了用nginx做了反向代理,貌似还是有用的,不过就无法动态了,所以要做缓存还是另某他路吧,I have no idea,呵呵,只是随便玩玩,估计如果真要用这个东东,框架就不要想了,加载了没法用的,基本功能都被caja切掉了哈。官方貌似在做集成jquery到caja的架构中,不过仍然是实验阶段。Anyway,good luck。

貓熊寶寶幼齒園

姜經緯的博客