UNPKG

nodulator

Version:

Complete NodeJS Framework for Restfull APIs

77 lines (76 loc) 10.2 kB
{ "_args": [ [ { "name": "nodulator-angular", "raw": "nodulator-angular@file:./src/Modules/Nodulator-Angular", "rawSpec": "file:./src/Modules/Nodulator-Angular", "scope": null, "spec": "/home/fgreiner/prog/js/Nodulator/src/Modules/Nodulator-Angular", "type": "directory" }, "/home/fgreiner/prog/js/Nodulator" ] ], "_from": "src/Modules/Nodulator-Angular", "_id": "nodulator-angular@0.0.10", "_inCache": true, "_installable": true, "_location": "/nodulator-angular", "_phantomChildren": { "character-parser": "1.2.1", "constantinople": "3.0.2", "mkdirp": "0.5.1", "transformers": "2.1.0", "void-elements": "1.0.0", "with": "4.0.3" }, "_requested": { "name": "nodulator-angular", "raw": "nodulator-angular@file:./src/Modules/Nodulator-Angular", "rawSpec": "file:./src/Modules/Nodulator-Angular", "scope": null, "spec": "/home/fgreiner/prog/js/Nodulator/src/Modules/Nodulator-Angular", "type": "directory" }, "_requiredBy": [ "/" ], "_resolved": "file:src/Modules/Nodulator-Angular", "_shasum": "a53ddccee9cc002476d16ff5a75376b657c03996", "_shrinkwrap": null, "_spec": "nodulator-angular@file:./src/Modules/Nodulator-Angular", "_where": "/home/fgreiner/prog/js/Nodulator", "author": { "email": "greine_f@epitech.eu", "name": "Champii" }, "bugs": { "url": "https://github.com/Champii/Nodulator-Angular/issues" }, "dependencies": { "coffee-script": "^1.9.3", "jade": "~1.8.1" }, "description": "Angular module for Nodulator", "devDependencies": {}, "homepage": "https://github.com/Champii/Nodulator-Angular#readme", "keywords": [ "Nodulator", "Angular" ], "license": "0", "main": "index.js", "name": "nodulator-angular", "optionalDependencies": {}, "readme": "Nodulator-Angular\n=================\n\nAngularJS implementation and facilities for Nodulator.\n\nNeeds:\n- [Nodulator](https://github.com/Champii/Nodulator)\n- [Nodulator-Assets](https://github.com/Champii/Nodulator-Assets)\n- [Nodulator-Socket](https://github.com/Champii/Nodulator-Socket)\n\nReleased under [GPLv2](https://github.com/Champii/Nodulator-Angular/blob/master/LICENSE.txt)\n\n## Concept\n\nProvides class for `angular`'s directives, services, controllers and factories.\nAllow inheritance of `angular` behaviour, and automatic link between services and `Nodulator.Resources` thanks to `Nodulator-Socket` (socket-io)\n\n___\n## Features\n\n- Automatic ResourceService instantiated for each Resources on server\n- Automatic directive creation on template\n- Give CoffeeScript style classes for each `angular` functions\n- `Socket-io` implementation for `angular`\n- `Nodulator.ResourceService` to link `Nodulator.Resource` to `angular` as a service\n- Automatic adding of views as templates\n- Automatic link between directives and templates (template file must have same name as directive)\n- Automatic appending of `ng-app=\"app\"` to `body` tag\n\n___\n## JumpTo\n\n- [Installation](#installation)\n- [Basics](#basics)\n- [Client Side](#client Side)\n - [Base](#base)\n - [Services](#services)\n - [Directives](#directives)\n - [Factories](#factories)\n - [Controllers](#controllers)\n - [Extended](#extended)\n - [Socket](#socket)\n - [ResourceService](#resourceservice)\n- [Coding Rules](#codingrules)\n- [Project Generation](#project-generation)\n- [TODO](#todo)\n- [Changelog](#changelog)\n\n___\n## Installation\n\nYou can automaticaly install `Nodulator`, `Nodulator-Angular` and every dependencies by running\n\n```\n$> sudo npm install -g Nodulator\n$> Nodulator install angular\n```\n\nOr you can just run `npm` :\n\n```\n$> npm install nodulator nodulator-assets nodulator-socket nodulator-angular\n```\n___\n## Basics\n\n```coffeescript\n Nodulator = require 'nodulator'\n Socket = require 'nodulator-socket'\n Assets = require 'nodulator-assets'\n Angular = require 'nodulator-angular'\n\n # Default config, can be omited\n Nodulator.Config\n servicesPath: '/client/services'\n directivesPath: '/client/directives'\n controllersPath: '/client/controllers'\n factoriesPath: '/client/factories'\n templatesPath: '/client/views'\n\n # Required for Angular module to work\n Nodulator.Use Socket\n\n Nodulator.Use Assets\n\n Nodulator.Use Angular\n\n Nodulator.Run()\n```\n\nWhen main page is loaded, main `Nodulator` scripts adds `ng-app=\"app\"` to `body` tag in order to initialize `angular` application.\n\n___\n## Client side\n\n### Base\n\n#### Services\n\nServices can be created easely. First `Nodulator.Service()` argument is the service name.\nNodulator will append 'Service' at the end of this name.\nFor a service name 'test', its real name will be 'testService'\nLatter arguments are for dependency injection. Each one will be added to class :\n\n```coffeescript\n class TestService extends Nodulator.Service 'test', '$http'\n\n Test: ->\n console.log 'Test'\n @$http.get(...);\n\n #Init only if you want to actualy create the service.\n #Omit if you only want to inherit from it.\n TestService.Init()\n```\n\n#### Directives\n\nAgain, first argument is the directive name, and the latters are for dependencies injections.\nBy default, every directive is `{restrict: 'E'}`. You can override or add properties by passing an object somewhere in the dependencies list.\n\nFor directive `test`, it will look for template in `config.viewPath` for file of same name (`test.jade` for exemple)\n\nThe context of the class will be attached to `angular` `scope`. This way, the following directive...\n\n```coffeescript\n class TestDirective extends Nodulator.Directive 'test', 'testService'\n\n foo: 'bar'\n\n Foo: ->\n @foo = 'bar2'\n @testService.Test()\n\n TestDirective.Init()\n```\n\n... become ...\n\n```coffeescript\n app.directive 'test', ['testService', (testService) ->\n return {\n\n restrict: 'E'\n\n templateUrl: 'test-tpl'\n\n link: (scope, element, attrs) ->\n\n scope.testService = testService\n\n scope.foo = 'bar'\n\n scope.Foo = ->\n scope.foo = 'bar2'\n scope.testService.Test()\n\n }\n ]\n```\n\nNice uh ?\nBeware, don't put to many things ~~in your sister~~ in the injections, they will all be injected in the scope ! (You probably don't want this, and a solution is currently in the pipe.)\n\nYou can also use `compile` instead of `link` by defining a `@Pre()` and/or a `@Post()` method.\n\n```coffeescript\n class TestDirective extends Nodulator.Directive 'test'\n\n Pre: ->\n @name = 'test'\n\n Post: ->\n @foo = ''\n\n @test = ->\n @foo = 'bar'\n\n TestDirective.Init()\n```\n\n#### Factories\n\nJust as Services, factories are easy to declare :\n\n```coffeescript\n class TestFactory extends Nodulator.Factory 'test', '$http'\n\n Test: ->\n console.log 'Test'\n @$http.get(...);\n\n TestFactory.Init()\n```\n\n#### Controllers\n\nJust like directives, Controllers have their context binded to the $scope.\n\n```coffeescript\n class TestController extends Nodulator.Controller 'test', '$http'\n\n foo: 'bar'\n\n Test: ->\n console.log 'Test'\n @foo = 'bar2'\n\n TestFactory.Init()\n```\n\n___\n### Extended\n\n#### Socket\n\nA socket is a `Nodulator.Factory` implementing `Socket.io`\nFor the moment, a socket is always instanciated in each project. Future configuration will be disponible.\n\nA socket has 2 methods : `@On()` and `@Emit()`, and apply changes to scope automaticaly.\n\n#### ResourceService\n\nA `Nodulator.ResourceService` inherits from `Nodulator.Service` and inject automatically `$http` and `socket`.\nAlso, it binds the socket to listen to the server `Resource` with the same name.\nIt provides 5 methods :\n\n```coffeescript\n class TestService extends Nodulator.ResourceService 'test'\n\n OnNew: (item) ->\n # Called when a new resource instance is created\n\n OnUpdate: (item) ->\n # When a resource instance is updated\n\n OnDelete: (item) ->\n # When a resource is deleted\n\n List: (done) ->\n # Put every records in @list\n\n Fetch: (id, done) ->\n # Fetch particular model and put it in @current\n\n Delete: (id, done) ->\n Add: (blob, done) ->\n Update: (blob, done) ->\n```\n\n___\n### Coding Rules\n\nOne directive by file. This is important for the automatic directive creation based on template.\n\n\n___\n### Project Generation\n\nBy calling `$> Nodulator init` with this module installed,\n\nIt creates the following structure if non-existant:\n```\nclient\n├── controllers\n├── directives\n├── factories\n├── index.coffee\n├── services\n└── views\n```\n\nAnd it gets `AngularJS` from official website and puts it in `/client/public/js`\n\n___\n## TODO\n\n- Nodulator-Backoffice ?\n- Find a way to don't attach `angular` object ($http, $rootScope,...) to local directive `scope`\n- Remove socket.io hard essential link, and make it more modular.\n\n___\n## Changelog\n\nXX/XX/15: current\n - Added capacity to override default Directive parameters\n - Removed reference to UnderscoreJS\n - InjectViews is now called from assets to fit invoked site\n - Adaptation to work with the new 'site' functionality from Assets\n - Auto added missing directive for given template\n - Auto added missing resource service for given resource when invoked\n\n15/02/15: v0.0.10\n - Added Controller\n\n07/01/15: v0.0.9\n - Fixed bug in project generation\n\n03/01/15: v0.0.8\n - Updated README\n\n02/01/15: v0.0.7\n - Updated `exemples/todo`\n\n02/01/15: v0.0.6\n - Improved README\n - Added `ng-app=\"app\"` to `body` tag\n - Adapted to `Nodulator-Assets` change\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/Champii/Nodulator-Angular.git" }, "scripts": { "test": "mocha" }, "version": "0.0.10" }