Skip to content

Commit

Permalink
added untracked files and updated readme with useful info
Browse files Browse the repository at this point in the history
  • Loading branch information
shimondoodkin committed Oct 30, 2010
1 parent 49b0451 commit faa31d2
Show file tree
Hide file tree
Showing 1,499 changed files with 294,576 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[submodule "deps/node-mongodb-native"]
path = deps/node-mongodb-native
url = http://github.com/christkv/node-mongodb-native.git

[submodule "deps/step"]
path = deps/step
url = http://github.com/creationix/step.git

[submodule "deps/nodejs-autorestart"]
path = deps/nodejs-autorestart
url = http://github.com/shimondoodkin/nodejs-autorestart.git

[submodule "deps/nodejs-clone-extend"]
path = deps/nodejs-clone-extend
url = http://github.com/shimondoodkin/nodejs-clone-extend.git

[submodule "deps/nodejs-meta-templates"]
path = deps/nodejs-meta-templates
url = http://github.com/shimondoodkin/nodejs-meta-templates.git

[submodule "deps/node-formidable"]
path = deps/node-formidable
url = http://github.com/felixge/node-formidable.git

[submodule "deps/node-microseconds"]
path = deps/node-microseconds
url = http://github.com/tmpvar/node-microseconds.git

[submodule "deps/jMediaelement"]
path = deps/jMediaelement
url = http://github.com/aFarkas/jMediaelement.git

[submodule "deps/restler"]
path = deps/restler
url = http://github.com/ashleydev/restler.git
Binary file added Fast Websites.odp
Binary file not shown.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@

it is database managment system for mongo db


in general there is global local variable

app

it is passed in all function

an include file contains one function
function main(app) // app is like dependeny injection
{
this // usualy: this=app, but might be an other object yo like to extend in this function
this.foo=function(){};
}

the app object contation libraries
for example
app.sys
app.phpjs

the objects inside the app object

app.models
app.pages // controllers
app.route_urls

//objects to clonbe and extend:
app.basicmodel // has function that simplify access to mongodb
app.basicfields

it requires some effort to make this work because of many libraries not all of them included in gitmoduls
also the documentation is not ready yet.

how it works:
you define some models inside a module main function.
by cloning and extending app.basicmodel
and cloning and extending app.basicfields.somefiled

then you have a managment interface in http://hostname/admin/
and you can create "page" type controllers in templates/website
to build the website

a page is a templates_object as defined in double templets (meta templates)
a page also contains a path or pathbegins propery it is for the router.

feel free to ask questions I will give you guidence.

---------------------------------------------------------
# old readme:

## The idea:
the idea is to create somthing similar to hkvstore.com's Phpmaker or Aspmaker or Microsoft Dot.NET 3 sp1 DynamicData application.

Expand Down
124 changes: 124 additions & 0 deletions basicapp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
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.phpjs = require('phpjs'); // http://phpjs.org/packages/view/2693/name:806d77a73ce93d851a4620f4a788acd7
app.date = require('date'); // http://phpjs.org/packages/view/2693/name:806d77a73ce93d851a4620f4a788acd7

app.path = require('path');
app.fs = require('fs');
app.doubletemplate = require('deps/nodejs-meta-templates/doubletemplate');;
app.httputils = require('httputils');
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;
});
*/
84 changes: 84 additions & 0 deletions basicapp_extend_request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
this.main=function(app)
{

var cookie = {
req:null,
get:function() {
var req = this.req;
return (req.headers.cookie ? this.parse(req.headers.cookie) : {});
},
parse:function(str) {
var obj = {},
pairs = str.split(/[;,] */);
for (var i = 0, len = pairs.length; i < len; ++i) {
var pair = pairs[i],
eqlIndex = pair.indexOf('='),
key = pair.substr(0, eqlIndex).trim().toLowerCase(),
val = pair.substr(++eqlIndex, pair.length).trim();
// Quoted values
if (val[0] === '"') {
val = val.slice(1, -1);
}
// Only assign once
if (obj[key] === undefined) {
//obj[key] = querystring.unescape(val, true);
obj[key] = val;
}
}
return obj;
}
};


function getuser(callback){
var req = this;
data = req.cookie.get();
if (data.user_id){
data.user_id = app.ObjectID.createFromHexString(data.user_id);
app.models.t2_users.getall({_id:data.user_id} , function(result){
if (result.length>0){
req.user = result[0];
callback(req.user);
} else {
callback(false);
}

});
} else {
callback(false);
}
}

function redirect(res, url, callback, code ) {
res.writeHead( code || 302, {'Location': url } );
res.end();
if(callback)callback();
};

function query_to_string(query){
var query_string = '';
var prefix = '?';
for (var name in query){
query_string+= prefix + name + '=' + query[name];
prefix = '&';
}
return query_string;
}


app.extendrequest=function (req)
{
req.cookie = cookie;
req.cookie.req = req;
req.user = null;
req.getuser = getuser;
req.redirect = redirect;
req.query_to_string = query_to_string;
/*
req.sessions={}
req.sessions.req=req;
req.sessions.save=session.save;
*/
};
}
Loading

0 comments on commit faa31d2

Please sign in to comment.