Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add basic project files, page.js as first control

  • Loading branch information...
commit d16f0e9997cb955c5d1ba94451047a905cfe7565 1 parent 6e7f82e
@ewoudj authored
View
1  README.md
@@ -0,0 +1 @@
+Application framework
View
83 controls/page.js
@@ -0,0 +1,83 @@
+var control = require('./control').control;
+var merge = require('./control').utils.merge;
+
+var page = function(config){
+ merge( this, config || {});
+ var headerItems = [];
+ if(this.title){
+ headerItems.push({
+ tag: 'title',
+ controlValue: this.title
+ });
+ }
+ if(this.viewport){
+ headerItems.push({
+ tag: 'meta',
+ voidElement: true,
+ attributes: {
+ name: 'viewport',
+ content: 'width = device-width'
+ }
+ });
+ }
+ if(this.stylesheets && this.stylesheets.length){
+ this.stylesheets.forEach(function(stylesheet){
+ headerItems.push({
+ tag: 'link',
+ voidElement: true,
+ attributes: {
+ rel: 'stylesheet',
+ href: stylesheet
+ }
+ });
+ });
+ }
+ if(this.scripts && this.scripts.length){
+ this.scripts.forEach(function(script){
+ if(script.src){
+ headerItems.push({
+ tag: 'script',
+ attributes: {
+ type: script.type || "text/javascript",
+ src: script.src
+ }
+ });
+ }
+ else if(script.controlValue){
+ headerItems.push(merge(script ,{tag: 'script'}));
+ }
+ else{
+ headerItems.push({
+ tag: 'script',
+ controlValue: script
+ });
+ }
+ });
+ }
+ var bodyItems = this.body || [];
+// if(config.controlValue){
+// bodyItems.push(config.controlValue);
+// }
+ merge(this,{
+ tag : 'html',
+ isRootControl: true,
+ items : [{
+ tag: 'head',
+ name: 'head',
+ items: headerItems
+ },{
+ tag: 'body',
+ name: 'body',
+ attributes: this.bodyAttributes,
+ items: bodyItems,
+ controlValue: this.controlValue
+ }]
+ });
+ control.call(this);
+};
+
+page.inheritsFrom(control);
+
+exports = module.exports = {
+ page : page
+};
View
19 examples/page_example.js
@@ -0,0 +1,19 @@
+var http = require('http');
+var control = require('./../controls/page').control;
+
+http.createServer(function (req, res) {
+ res.writeHead(200, {'Content-Type': 'text/html'});
+ res.end(
+
+ new control({
+ tag: 'html',
+ isRootControl: true,
+ items : [
+ {tag: 'head', items: [{tag: 'title', controlValue: 'Hello world app.'}]},
+ {tag: 'body', items: [{tag: 'h1', controlValue: 'Hello world!'}]}
+ ]
+ }).render()
+
+ );
+}).listen(1337, "127.0.0.1");
+console.log('Server running at http://127.0.0.1:1337/');
View
0  index.js
No changes.
View
20 package.json
@@ -0,0 +1,20 @@
+{
+ "name": "controljs",
+ "description": "JavaScript control base class for both server and client side GUI development. Control is the opposite of templating.",
+ "version": "0.0.1",
+ "author": "Ewoud van den Boom <ewoudj@gmail.com>",
+ "contributors": [
+ { "name": "Ewoud van den Boom", "email": "ewoudj@gmail.com" }
+ ],
+ "keywords": ["GUI", "HTML", "javascript", "rest", "ajax"],
+ "repository" : {
+ "type" : "git"
+ , "url" : "git://github.com/ewoudj/control.git"
+ },
+ "main": "lib/control.js",
+ "engines": { "node": ">= 0.4.1" },
+ "licenses" : [ { "type" : "MIT"
+ , "url" : "http://github.com/ewoudj/control/raw/master/LICENSE"
+ }
+ ]
+}
Please sign in to comment.
Something went wrong with that request. Please try again.