Skip to content
Browse files

Initial functioning version. Basic functionality with all of the comp…

…onents allows building a knockout template from handlebars template files.
  • Loading branch information...
1 parent d85ce18 commit 0570c99b99cb563f357b1335d8a8aafd92cc4ec5 @mvantil committed
Showing with 196 additions and 2 deletions.
  1. +20 −2 README.md
  2. +15 −0 defaults/.luminousrc-server
  3. +10 −0 defaults/template/entity.ko
  4. +8 −0 defaults/template/id.ko
  5. +20 −0 defaults/template/link.ko
  6. +20 −0 defaults/template/name.ko
  7. +20 −0 defaults/template/string.ko
  8. +39 −0 lib/luminous.js
  9. +22 −0 package.json
  10. +22 −0 r.js
View
22 README.md
@@ -1,2 +1,20 @@
-luminous
-========
+##luminous
+========
+
+##Description
+
+This project is in development. It is designed to generate HTML templates from metadata definitions using a very modular packaging structure.
+
+Check back soon for updates.
+
+##Usage
+
+npm install luminous
+
+xcopy /s node_modules/luminous/defaults .
+
+ren .luminousrc-server .luminousrc
+
+node node_modules/luminous/r
+
+npm install -d
View
15 defaults/.luminousrc-server
@@ -0,0 +1,15 @@
+{
+ "mongoConnection": "mongodb://localhost:27017/luminous",
+ "modules": {
+ "metadata": "luminous-mongo-metadata",
+ "typeResource": "luminous-file-resource-type-loader",
+ "template": "luminous-knockout-template"
+ },
+ "typeResource": {
+ "path": "template",
+ "extension": "ko"
+ },
+ "metadata": {
+ "typeCollection": "/type"
+ }
+}
View
10 defaults/template/entity.ko
@@ -0,0 +1,10 @@
+<template context="field">
+ <div>
+ <a data-bind="attr: { href: {{field}} ? '#{{baseType}}' + {{field}} : '#' }"><span data-bind="text: {{displayField}}"></span></a>
+ </div>
+</template>
+<template context="listField">
+ <span>
+ <a data-bind="attr: { href: {{field}} ? '#{{baseType}}' + {{field}} : '#' }"><span data-bind="text: {{displayField}}"></span></a>
+ </span>
+</template>
View
8 defaults/template/id.ko
@@ -0,0 +1,8 @@
+<template context="field">
+</template>
+<template context="field" writable="yes">
+</template>
+<template context="listField">
+</template>
+<template context="listField" writable="yes">
+</template>
View
20 defaults/template/link.ko
@@ -0,0 +1,20 @@
+<template context="field">
+ <div>
+ {{#display}}<b>{{this}}</b>: {{/display}}<span data-bind="text: {{field}}"/>
+ </div>
+</template>
+<template context="field" writable="yes">
+ <div>
+ {{#display}}<b>{{this}}</b>: {{/display}}<input data-bind="value: {{field}}"/>
+ </div>
+</template>
+<template context="listField">
+ <span>
+ {{#display}}<b>{{this}}</b>: {{/display}}<span data-bind="text: {{field}}"/>
+ </span>
+</template>
+<template context="listField" writable="yes">
+ <span>
+ {{#display}}<b>{{this}}</b>: {{/display}}<span data-bind="value: {{field}}"/>
+ </span>
+</template>
View
20 defaults/template/name.ko
@@ -0,0 +1,20 @@
+<template context="field">
+ <div>
+ <h2 data-bind="text: {{field}}"/>
+ </div>
+</template>
+<template context="field" writable="yes">
+ <div>
+ <h2 data-bind="text: {{field}}"/>
+ </div>
+</template>
+<template context="listField">
+ <span>
+ <h2 data-bind="text: {{field}}"/>
+ </span>
+</template>
+<template context="listField" writable="yes">
+ <span>
+ <h2 data-bind="text: {{field}}"/>
+ </span>
+</template>
View
20 defaults/template/string.ko
@@ -0,0 +1,20 @@
+<template context="field">
+ <div>
+ {{#display}}<b>{{this}}</b>: {{/display}}<span data-bind="text: {{field}}"/>
+ </div>
+</template>
+<template context="field" writable="yes">
+ <div>
+ {{#display}}<b>{{this}}</b>: {{/display}}<input data-bind="value: {{field}}"/>
+ </div>
+</template>
+<template context="listField">
+ <span>
+ {{#display}}<b>{{this}}</b>: {{/display}}<span data-bind="text: {{field}}"/>
+ </span>
+</template>
+<template context="listField" writable="yes">
+ <span>
+ {{#display}}<b>{{this}}</b>: {{/display}}<span data-bind="value: {{field}}"/>
+ </span>
+</template>
View
39 lib/luminous.js
@@ -0,0 +1,39 @@
+var LuminousBase = require('luminous-base'),
+ _ = require('underscore');
+
+function resolveModule(config, targetObject) {
+ var moduleName = data.modules.metadata;
+ var newMetadataClass = require(data.modules.metadata);
+ var oldMetadata = me.metadata;
+ me.metadata = new newMetadataClass();
+ oldMetadata.resolve(me.metadata);
+}
+
+function Luminous() {
+ var me = this;
+ this.metadata = new LuminousBase.Metadata();
+ this.typeResource = new LuminousBase.TypeResource();
+ this.template = new LuminousBase.Template();
+
+ var config = new LuminousBase.Config();
+ config.load(function(err, config) {
+ if (err) throw err;
+
+ _.chain(config.modules)
+ .pairs()
+ .map(function(pair) {
+ return {
+ fieldName: pair[0],
+ className: pair[1]
+ };
+ })
+ .each(function(module) {
+ var newClass = require(module.className);
+ var oldObject = me[module.fieldName];
+ me[module.fieldName] = new newClass(me);
+ oldObject.resolve(me[module.fieldName]);
+ });
+ });
+}
+
+module.exports = Luminous;
View
22 package.json
@@ -0,0 +1,22 @@
+{
+ "name": "luminous",
+ "version": "0.0.0",
+ "description": "luminous\r ========",
+ "main": "lib/luminous.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/mvantil/luminous"
+ },
+ "author": "",
+ "license": "BSD",
+ "readmeFilename": "README.md",
+ "gitHead": "d85ce1861c00a37ddf4540c82af7ffdda0491375",
+ "dependencies": {
+ "luminous-base": "~0.0.0",
+ "underscore": "~1.4.4"
+ },
+ "devDependencies": {}
+}
View
22 r.js
@@ -0,0 +1,22 @@
+var fs = require('fs'),
+ _ = require('underscore');
+
+console.log('call with configure to update the package.json from the .luminousrc');
+
+fs.readFile('.luminousrc', function(err, config) {
+ fs.readFile('package.json', function(err, packageJson) {
+ if (err) {
+ console.log('no package.json. Call npm init first.');
+ return;
+ }
+ packageJson = JSON.parse(packageJson);
+
+ config = JSON.parse(config);
+ _.each(config.modules, function(module) {
+ packageJson.dependencies[module] = '~0.0.0';
+ });
+ fs.writeFile('package.json', JSON.stringify(packageJson, null, 2), function(err) {
+ console.log('Updated package');
+ });
+ });
+});

0 comments on commit 0570c99

Please sign in to comment.
Something went wrong with that request. Please try again.