This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
forked from ryanramage/garden
-
Notifications
You must be signed in to change notification settings - Fork 2
/
shows.js
94 lines (79 loc) · 2.65 KB
/
shows.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Show functions to be exported from the design doc.
*/
var _ = require('underscore')._;
var templates = require('handlebars').templates,
jsonp = require('jsonp'),
utils = require('./utils'),
ui = require('./ui');
exports.not_found = function (doc, req) {
return utils.base_template({
code: 404,
app_settings : this.app_settings,
title: 'Not found',
content: templates['404.html']({})
});
};
exports.install_script = function (doc, req) {
return utils.base_template({
code: 200,
app_settings : this.app_settings,
headers: {'Content-Type': 'text/plain'},
body: templates['install.sh']({
app: req.query.name,
app_settings : this.app_settings,
app_url: utils.app_url(req, req.query.name),
open_path: utils.open_path(doc)
})
});
};
exports.upload_app = function (doc, req) {
return utils.base_template({
code: 200,
baseURL : './',
app_settings : this.app_settings,
title: 'Upload your app',
onload : 'ui.upload_page()',
content: templates['upload_app.html']({
upload_url: utils.upload_url(req),
app_settings : this.app_settings,
baseURL : './'
})
});
};
exports.search = function(doc, req) {
return utils.base_template({
code: 200,
baseURL : './',
app_settings : this.app_settings,
title: 'Search Results',
onload : 'ui.perform_search("'+ req.query.q +'")',
content: templates['search.html']({
baseURL : './',
app_settings : this.app_settings,
terms : req.query.q
})
});
}
exports.kanso_details = function(doc, req) {
// check for _rewrite, we assume we are on a vhost. Make the terrible assumption
// that the vhost is the db name
var db_path = req.info.db_name + '/_db';
if(_.indexOf(req.requested_path, '_rewrite') >= 0) {
// we are on the rewrite
db_path = req.info.db_name + '/_design/market/_rewrite/_db';
}
var meta = doc.couchapp || doc.kanso;
return jsonp.response(req.query.callback, {
kanso: meta,
open_path: utils.open_path(doc),
style : 'design-doc', /* option for db to replicate whole db */
db_src : utils.app_db(req, db_path),
doc_id : doc._id,
icon_url : utils.app_db(req, db_path) + '/' + doc._id + '/' + meta.config.icons['96'],
user_url : utils.user_url(req, meta.pushed_by),
user : meta.pushed_by,
db_path : db_path,
requested_path :req.requested_path
});
}