templates for app generate
This commit is contained in:
parent
f13415febe
commit
49148644ea
3 changed files with 44 additions and 0 deletions
8
lib/couchrest/helper/templates/example-map.js
Normal file
8
lib/couchrest/helper/templates/example-map.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// an example map function, emits the doc id
|
||||||
|
// and the list of keys it contains
|
||||||
|
|
||||||
|
function(doc) {
|
||||||
|
var k, keys = []
|
||||||
|
for (k in doc) keys.push(k);
|
||||||
|
emit(doc._id, keys);
|
||||||
|
};
|
10
lib/couchrest/helper/templates/example-reduce.js
Normal file
10
lib/couchrest/helper/templates/example-reduce.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// example reduce function to count the
|
||||||
|
// number of rows in a given key range.
|
||||||
|
|
||||||
|
function(keys, value, rereduce) {
|
||||||
|
if (rereduce) {
|
||||||
|
return sum(values);
|
||||||
|
} else {
|
||||||
|
return values.length;
|
||||||
|
}
|
||||||
|
};
|
26
lib/couchrest/helper/templates/index.html
Normal file
26
lib/couchrest/helper/templates/index.html
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Generated CouchApp</title>
|
||||||
|
<link rel="stylesheet" href="screen.css" type="text/css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Generated CouchApp</h1>
|
||||||
|
<ul id="view"></ul>
|
||||||
|
</body>
|
||||||
|
<script src="/_utils/script/json2.js"></script>
|
||||||
|
<script src="/_utils/script/jquery.js?1.2.6"></script>
|
||||||
|
<script src="/_utils/script/jquery.couch.js?0.8.0"></script>
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
$(function() {
|
||||||
|
var dbname = document.location.href.split('/')[3];
|
||||||
|
var design = unescape(document.location.href.split('/')[4]).split('/')[1];
|
||||||
|
var DB = $.couch.db(dbname);
|
||||||
|
DB.view(design+"/example-map",{success: function(json) {
|
||||||
|
$("#view").html(json.rows.map(function(row) {
|
||||||
|
return '<li>'+row.key+'</li>';
|
||||||
|
}).join(''));
|
||||||
|
}});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue