Package Exports
- partial.js
- partial.js/builders
- partial.js/utils
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (partial.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
web application framework for node.js
- Async web framework - example
- Simple view system - example
- Simple routing (+ support flags ['ajax', 'post', 'get', 'put', 'delete', 'upload', 'json', 'logged', 'unlogged', 'debug']) - example
- Simple cacheing - http cache example, partial cache example
- Simple directory structure (controllers, modules, public, logs, tmp, templates, views, resources)
- Simple code structure
- Simple error handling
- Simple cookie manipulation - example
- Simple listing via templates - example
- Render controller in controller
- Share controller functions and models over framework - example
- Supports controller sharing between other controllers - example
- Supports debug mode with custom settings without cache - example
- Supports file upload - example
- Supports copy&paste custom code between projects - example
- Supports modules - example
- Supports form data validation - example
- Supports simple log writer - example
- Supports simple restrictions example
- Supports static files
- Supports JavaScript compress
- Supports JavaScript dynamic compress in views - example
- Supports simple LESS CSS (with compress) - example
- Supports Markdown parser - example
- Supports resources (for multilanguage pages) - example
- Supports prefixes for mobile devices - example
- Supports simple SMTP mail sender - example
- Supports simple mail templating - example
- Supports simple ORM (via HTTP-RDBMS)
- Supports custom authorization - example
- Supports HTTP-RDBMS provider (MySQL, SQL Server, OleDB, ODBC), more on https://github.com/petersirka/http-rdbms/
- Supports simple CouchDB provider - example
- Supports simple image processing (resize, crop, blur, sepia, grayscale, etc.) with GraphicsMagick or ImageMagick - example
- Easy adding dynamic META tags in views or controllers - example
- Easy adding dynamic Settings in views or controllers - example
- Simple use paypal payment with node-paypal - example
- Supports simple paging builder - example
- Supports live usage information - example
- Supports dynamic stop server - example
- About 6 500 lines of JavaScript code
- No dependencies
- More examples
Simple eshop example
http://petersirka.sk/partial-js/eshop.zip
Preview node.js eshop: http://nodejs-eshop.eu01.aws.af.cm
Run your website:
- download empty website project
- open terminal and find website directory
- write and run on terminal:
$ node index.js
NPM partial.js
- create on your desktop empty directory with name: website
- create file index.js
- open terminal and find this directory: cd /Desktop/website/
- write and run on terminal:
$ npm install partial.js
Empty website project
http://petersirka.sk/partial-js/new-web-site.zip
Simple documentation
English documentation will be in short time. Look at examples
Plans
I want perfect and stability web application framework. Currently is framework in testing mode and stable version will be in short time.
Tips:
- node.js cluster: http://petersirka.sk/development/spustenie-partial-js-v-module-cluster/
- install nginx: http://www.petersirka.sk/ostatok/instalacia-na-osx-lion-nginx-a-nastavenie-sublime-do-termin/
Sublime 2 Syntax partial.js HTML Highlighter
Download / extract and copy to Sublime Text 2 Packgages
http://petersirka.sk/partial-js/Packages.zip
Simple example
index.js
var framework = require('partial.js');
var http = require('http');
var port = 8004;
var debug = true;
framework.init(http, debug, port);
// Initialize controllers
framework.controller('global');
console.log("http://127.0.0.1:{0}/".format(port));
controllers / global.js
exports.init = function() {
this.route('/', viewHomepage);
this.route('#403', error403);
this.route('#404', error404);
this.route('#431', error431)
this.route('#500', error500);
// this.route('/registration/', viewRegistration, ['ajax', 'post']);
// this.route('/products/{category}/', viewProducts);
// this.route('/products/{category}/{subcategory}/', viewProducts);
// this.route('/user/', viewUser, ['logged']);
};
// Forbidden
function error403() {
this.repository.title = 'Forbidden (403)';
this.view('403');
}
// Not Found
function error404() {
this.repository.title = 'Not Found (404)';
this.view('404');
}
// Request Header Fields Too Large
function error431() {
this.repository.title = 'Request Header Fields Too Large (431)';
this.view('431');
}
// Internal Server Error
function error500() {
this.repository.title = 'Internal Server Error (500)';
this.view('500');
}
function viewHomepage() {
this.repository.title = 'Welcome';
this.view('homepage', { name: 'Peter' });
}
views / _layout.html
<!DOCTYPE html>
<html>
<head>
<title>@{repository.title}</title>
<meta charset="utf-8" />
<meta http-equiv="content-language" content="sk" />
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta name="format-detection" content="telephone=no"/>
<meta name="viewport" content="width=1024, user-scalable=yes" />
<meta name="robots" content="all,follow" />
<link rel="stylesheet" href="@{routeCSS('p.css')}" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="@{routeJS('p.js')}" ></script>
</head>
<body>
<div class="content">
<h1>@{repository.title}</h1>
@{body}
</div>
</body>
</html>
views / homepage.html
Welcome @{model.name}!
RESULT
<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
<meta charset="utf-8" />
<meta http-equiv="content-language" content="sk" />
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta name="format-detection" content="telephone=no"/>
<meta name="viewport" content="width=1024, user-scalable=yes" />
<meta name="robots" content="all,follow" />
<link rel="stylesheet" href="/data/p.css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="/data/p.js" ></script>
</head>
<body>
<div class="content">
<h1>Welcome</h1>
Welcome Peter!
</div>
</body>
</html>
Simple ORM via HTTP-RDBMS
- support parameters (resolve for SQL injection)
- support schema builder
- support query builder
- support order builder
- support paging
var builders = new requiere('partial.js/builders');
var rdbms = new requiere('partial.js/rdbms');
var db = new rdbms.SQLServer('http://myrdbms/sqlserver/', 'Data Source=;Database=;Uid=;Pwd=;');
// or
var db = new rdbms.MySQL('http://myrdbms/mysql/', 'Server=;Database=;Uid=;Pwd=;');
builders.schema('tbl_user', {
Id: 'int',
FirstName: 'string(50)',
LastName: 'string(50)',
Age: 'int'
}, 'Id');
var newUser = {
FirstName: 'Peter',
LastName: 'Sirka',
Age: 28
};
db.insert('tbl_user', newUser, function(data) {
console.log(data.Id);
db.delete('tbl_user', newUser);
});
var where = new builders.QueryBuilder();
var order = new builders.OrderBuilder();
order.asc('Id').desc('FistName');
where.addValue('Id', '>', 10).addOperator('AND').addValue('FistName', '=', 'Peter');
// Query:
// SQL Server: Id > @a AND FirstName = @b
// MySQL: Id > ? AND FirstName = ?
db.findTop(10, 'tbl_user', where, order, function(data) {
console.log(data);
});
db.execute('UPDATE tbl_user SET Price=20 WHERE Id BETWEEN {a} AND {b}', { a: 10, b: 20 });
// Query:
// SQL Server: UPDATE tbl_user SET Price=20 WHERE Id BETWEEN @a AND @b
// MySQL: UPDATE tbl_user SET Price=20 WHERE Id BETWEEN ? AND ?
db.scalar('SELECT COUNT(*) FROM tbl_user', null, null, function(err, data) {
console.log(data);
});
// multiple recordset
db.reader('SELECT Id, LastName FORM tbl_user; SELECT Id, FirstName FROM tbl_user', function(err, data) {
// data[0] == []
// data[1] == []
});
db.count('tbl_user', function(err, data) {
// data.value
});
db.count('tbl_user', where, function(err, data) {
// data.value
});