-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleView.js
More file actions
85 lines (73 loc) · 2.06 KB
/
simpleView.js
File metadata and controls
85 lines (73 loc) · 2.06 KB
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
var jade = require("jade");
function startView (a_params) {
return jade.renderFile('jade_tmpl/views/start.jade',
{
pretty: true,
form_action: "/upload",
submit_text: "Send text"
},
function (err, html) {
if (err) throw err;
return html;
});
}
function uploadView (a_params) {
var params = applyParams(a_params, {sent_text: 'none'});
return jade.renderFile('jade_tmpl/views/upload.jade',
{
pretty: true,
sent_text: params.sent_text,
},
function (err, html) {
if (err) throw err;
return html;
});
}
function inputImgView (a_params) {
return jade.renderFile('jade_tmpl/views/inputimg.jade',
{
pretty: true,
form_action: "/uploadimg",
submit_text: "Upload file"
},
function (err, html) {
if (err) throw err;
return html;
});
}
function uploadedImgView (a_params) {
var params = applyParams(a_params, {img_path: "#"});
return jade.renderFile('jade_tmpl/views/uploadedimg.jade',
{
pretty: true,
img_path: params.img_path
},
function (err, html) {
if (err) throw err;
return html;
});
}
function error404View (a_params) {
var params = applyParams(a_params, {requested_page: ''});
return jade.renderFile('jade_tmpl/views/error404.jade',
{
pretty: true,
page: params.requested_page,
},
function (err, html) {
if (err) throw err;
return html;
});
}
exports.startView = startView;
exports.uploadView = uploadView;
exports.inputImgView = inputImgView;
exports.uploadedImgView = uploadedImgView;
exports.error404View = error404View;
function applyParams (a_params, a_defaults) {
var params = a_params || {};
var defaults = a_defaults || {};
for (key in params)
if (key in defaults) defaults[key] = params[key];
return defaults;
}