JSPM

  • Created
  • Published
  • 0
  • Score
    100M100P100Q68498F

web application framework for node.js

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

partial.js logo

web application framework for node.js

http://partialjs.com

  • Async web framework - example
  • Simple view engine - example
  • Simple routing + support flags ['xhr', '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
  • XSS protection
  • Share controller functions and models over framework - example
  • Assertion Testing - 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
  • Supports render controller in controller
  • 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
  • Supports verification of framework - example
  • About 6 500 lines of JavaScript code
  • No dependencies
  • More examples

I am still improving my english. Please do not hesitate to contact me in any contradictions.


Simple eshop example

http://eshop.partialjs.com

partial.js homepage

http://partialjs.com

partial.js documentation

http://partialjs.com/documentation/


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

Plans

I want perfect and stability web application framework. Currently is framework in testing mode and stable version will be in short time.

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() {
    var self = this;
    self.route('/', viewHomepage);
    self.route('#404', error404);
    self.route('#500', error500);
    // self.route('/registration/', viewRegistration, ['ajax', 'post']);
    // self.route('/products/{category}/', viewProducts);
    // self.route('/products/{category}/{subcategory}/', viewProducts);
    // self.route('/user/', viewUser, ['logged']);
};

// Not Found
function error404() {
    var self = this;
    self.statusCode = 404;
    self.view('404');
}

// Internal Server Error
function error500() {
    var self = this;
    self.statusCode = 500;
    self.view('500');
}

function viewHomepage() {
    var self = this;
    self.repository.title = 'Web application framework';
    self.view('homepage', { name: 'Peter' });
}

views / _layout.html

<!DOCTYPE html>
<html>
<head>
    @{meta}
    <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">
        @{body}
    </div>
</body>
</html>

views / homepage.html

@{meta('My Homepage', 'My Homepage description', 'My Homepage keywords')}

<h1>@{repository.title}</h1>
Welcome @{model.name}!

RESULT

<!DOCTYPE html>
<html>
<head>
    <title>My Homepage</title>
    <meta name="description" content="My Homepage description" />
    <meta name="keywords" content="My Homepage keywords" />
    <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>Web application framework</h1>		
        Welcome Peter!
    </div>
</body>
</html>

Simple ORM via HTTP-RDBMS

  • supports parameters (resolve for SQL injection)
  • supports schema builder
  • supports query builder
  • supports order builder
  • supports 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
});

Contact

http://www.petersirka.sk