-
Notifications
You must be signed in to change notification settings - Fork 11
/
basicapp.js
executable file
·131 lines (103 loc) · 4.19 KB
/
basicapp.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
there is:
app // application
app.[lib name]=lib // dependency sharing
app.models.[model name]=model object // models
app.pages.[controller name]=controller object // controllers
app.url_routes.[route name]=route object // application routes
templates:
temlates are parts of a templates object:
var tempaltes_object={
load_tempalts:{temaplte_name1:"filename.html"},
prepere_templates:{temaplte_name2:function(vars,callback){var echo=""; if(callback)callback(echo);else return echo;}}, // never used actualy
prepeare_data:function(currenttempaltename,callback){ var template_prepere_data={}; callback(template_prepere_data);}
}
there is a shared function of prepere a templates object.
aftrer it is ran:
the result is a tempaltes object with functions by their names:
var tempaltes_object={
load_tempalts:{temaplte_name1:"filename.html"},
prepere_templates:{temaplte_name2:function(vars,callback){var echo=""; if(callback)callback(echo);else return echo;}}, // never used actualy
prepeare_data:function(currenttempaltename,callback){ var template_prepere_data={}; callback(template_prepere_data);}
}
temaplte_name1:function(...){...}
temaplte_name2:function(...){...}
you use templates like this:
tamplates_object.function(vars,callback);
a template:
structure of a tempaltes function:
function(vars,callback)
{
var echo="";
//my code is here
if(callback)
callback(echo);
else
return echo;
}
example of a tempalte and the result:
template.html:
hello world <?if(vars.name){?><?=vars.name?><?}?>
function(vars,callback)
{
var echo="";
echo +="hello world ";
if(vars.name){
echo +=vars.name;
}
if(callback)
callback(echo);
else
return echo;
}
*/
var app={};this.app = app;
app.libs={};
app.autoreload = require('deps/node-hot-reload'); app.autoreload.path=__dirname;
app._ = require('deps/nodejs-clone-extend/merger'); // lets do: _.extend(same,otherobjexts), _.clone(obj) - creates new reference, see source to understand //
app.jsinc = require('deps/jsinc').jsinc;
app.linq = app.jsinc(__dirname+'/deps/jslinq/scripts/JSLINQ.js').window.JSLINQ;
//app.datejs = app.jsinc(__dirname+'/deps/datejs/build/date-he-IL.js',{"Date":Date});
//console.log(app.datejs.CultureInfo);
app.phpjs = require('phpjs'); // http://phpjs.org/packages/view/2693/name:806d77a73ce93d851a4620f4a788acd7
app.date = app.jsinc(__dirname+'/deps/date/date.js');
//app.date = require('deps/date/date');
app.path = require('path');
app.fs = require('fs');
app.doubletemplate = require('deps/nodejs-meta-templates/doubletemplate');;
app.httputils = require('httputils');
app.httprequest = require('deps/node-utils/request/lib/main');
app.ObjectID = require('deps/node-mongodb-native/lib/mongodb/bson/bson').ObjectID;
app.step = require('deps/step/lib/step');
app.sys = require('sys');
app.inflow = require('deps/node-inflow');
app.url = require('url'); // allaws to parse urls
app.files_path=__dirname+'/files/';
app.root_path=__dirname;
app.templates_path=__dirname+'/templates/'; app.doubletemplate.templates_path=app.templates_path;
app.server={port:8000};
app.websocket={port:8000};
app.database={name:'test',server:'localhost',port:27017};
app.models={};
app.urls_route_before=[];
app.url_routes=[];
app.url_routes_after=[];
app.menus={};
app.collections={};
require('./basicapp_shared_templates').main(app);
require('./basicfields').main(app);
require('./basicmodel').main(app);
require('./basicapp_loaddata').main(app);
require('./basicapp_subitems').main(app);
require('./basicapp_handle_request').main(app);
require('./basicapp_extend_request').main(app);
require('./basicapp_init').main(app);
require('./basicapp_pages').main(app);
require('./dbutil').main(app);
/*
// auto reload httputils modul during development
app.autoreload.watchrel("httputils.js", function (newmodule)
{
app.httputils=newmodule;
});
*/