仅使用静态HTML+JavaScript,如何显示给定CMIS 1.1端点/存储库的给定文件夹的内容?
它可能看起来像这样:
<html>
<head>
<script>
var endpoint = "http://cmis.alfresco.com/cmisbrowser";
var repository = "bb212ecb-122d-47ea-b5c1-128affb9cd8f";
var folder = "/";
</script>
</head>
<body>
<!-- Some magic JavaScript call to the CMIS 1.1 browser binding -->
<!-- Some minimalist formatting of the JSONP reply -->
</body>
</html>
使用JQuery进行查询,使用json2.html进行模板:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="json2html.js"></script>
<script type="text/javascript" src="jquery.json2html.js"></script>
<script>
var endpoint = "http://cmis.alfresco.com/cmisbrowser";
var repository = "bb212ecb-122d-47ea-b5c1-128affb9cd8f";
var folder = "/";
</script>
</head>
<body>
<ul/>
<script>
$.getJSON(
endpoint + "/" + repository + "/root?succinct=true&callback=?",
function(data) {
var transform = [{
"tag": "li",
"html": "${object.succinctProperties.cmis:name}"
}];
$("ul").json2html(data.objects, transform);
});
</script>
</body>
</html>
结果:列表中每个CMIS对象都会填充一个项目,并显示其名称。
我刚刚基于这个想法创建了一个新的开源项目:WebCMIS