├── assets
└── screen.png
├── src
├── yeoman-generators
│ └── generator-cean
│ │ ├── app
│ │ ├── templates
│ │ │ ├── client
│ │ │ │ ├── _robots.txt
│ │ │ │ ├── views
│ │ │ │ │ ├── _footer.html
│ │ │ │ │ ├── _header.html
│ │ │ │ │ └── _main.html
│ │ │ │ ├── .DS_Store
│ │ │ │ ├── _favicon.ico
│ │ │ │ ├── images
│ │ │ │ │ ├── _cb.png
│ │ │ │ │ └── _yeoman.png
│ │ │ │ ├── scripts
│ │ │ │ │ ├── services
│ │ │ │ │ │ ├── _main.js
│ │ │ │ │ │ └── _myservice.js
│ │ │ │ │ ├── controllers
│ │ │ │ │ │ ├── _main.js
│ │ │ │ │ │ └── _mycontroller.js
│ │ │ │ │ └── _app.js
│ │ │ │ ├── _index.html
│ │ │ │ ├── styles
│ │ │ │ │ └── _main.css
│ │ │ │ └── _404.html
│ │ │ ├── .DS_Store
│ │ │ ├── server
│ │ │ │ ├── _helper.js
│ │ │ │ ├── _app.js
│ │ │ │ ├── _cb.js
│ │ │ │ └── _route_demo.js
│ │ │ ├── _bower.json
│ │ │ ├── _package.json
│ │ │ └── _Gruntfile.js
│ │ ├── helper.js
│ │ └── index.js
│ │ ├── package.json
│ │ ├── angular-view
│ │ ├── templates
│ │ │ └── _view.html
│ │ └── index.js
│ │ ├── angular-service
│ │ ├── templates
│ │ │ └── _service.js
│ │ └── index.js
│ │ ├── angular-controller
│ │ ├── templates
│ │ │ └── _controller.js
│ │ └── index.js
│ │ ├── express-route
│ │ ├── templates
│ │ │ └── _route.js
│ │ └── index.js
│ │ ├── angular-route
│ │ └── index.js
│ │ └── README.md
└── node-modules
│ └── cean-cli
│ ├── package.json
│ ├── cean-cli
│ └── README.md
├── releases
├── cean-cli-0.0.1.tar.gz
├── cean-cli-0.0.2.tar.gz
└── generator-cean-0.1.0.tar.gz
├── .gitignore
└── README.md
/assets/screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/assets/screen.png
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/_robots.txt:
--------------------------------------------------------------------------------
1 | # robotstxt.org
2 |
3 | User-agent: *
4 |
--------------------------------------------------------------------------------
/releases/cean-cli-0.0.1.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/releases/cean-cli-0.0.1.tar.gz
--------------------------------------------------------------------------------
/releases/cean-cli-0.0.2.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/releases/cean-cli-0.0.2.tar.gz
--------------------------------------------------------------------------------
/releases/generator-cean-0.1.0.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/releases/generator-cean-0.1.0.tar.gz
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/views/_footer.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/src/yeoman-generators/generator-cean/app/templates/.DS_Store
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/src/yeoman-generators/generator-cean/app/templates/client/.DS_Store
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/_favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/src/yeoman-generators/generator-cean/app/templates/client/_favicon.ico
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/images/_cb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/src/yeoman-generators/generator-cean/app/templates/client/images/_cb.png
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/images/_yeoman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dmaier-couchbase/cean/HEAD/src/yeoman-generators/generator-cean/app/templates/client/images/_yeoman.png
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-cean",
3 | "version": "0.1.0",
4 | "description": "The CEAN stack generator",
5 | "keywords": ["yeoman-generator", "angularjs", "CEAN"],
6 | "dependencies": {
7 | "yeoman-generator": "^0.18.10"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/angular-view/templates/_view.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
<%= name %>
8 | <%= subtitle %>
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/scripts/services/_main.js:
--------------------------------------------------------------------------------
1 | var services = angular.module('<%= _.slugify(_.humanize(appname)) %>');
2 |
3 | // DON'T REMOVE OR MODIFY THE FOLLOWING LINE
4 | //-- cean: Services
5 |
6 | services.factory('MyService', function($http) {
7 |
8 | var myService = new TMyService($http);
9 |
10 | return myService;
11 | });
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/angular-service/templates/_service.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Constructor
3 | */
4 | function T<%= _.camelize(name) %>(httpService)
5 | {
6 | this.httpService = httpService;
7 | }
8 |
9 | /**
10 | * Service client function
11 | */
12 | T<%= _.camelize(name) %>.prototype.yourcall = function(id)
13 | {
14 | //Your service code here
15 | //...
16 | }
17 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/views/_header.html:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/angular-controller/templates/_controller.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name <%= _.slugify(_.humanize(appname)) %>.controller:<%= name %>
6 | * @description
7 | * # <%= name %>
8 | */
9 | var app = angular.module('<%= _.slugify(_.humanize(appname)) %>');
10 |
11 | app.controller('<%= name %>', function($scope) {
12 |
13 | //Your controller code here
14 | //...
15 |
16 | });
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile '~/.gitignore_global'
6 |
7 | # Ignore bundler config.
8 | /.bundle
9 | /.idea
10 | /node_modules
11 |
12 | # Ignore all logfiles and tempfiles.
13 | /log/*.log
14 | /tmp
15 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/server/_helper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Helper to check if the variable is defined
3 | */
4 | function _isDefined(obj)
5 | {
6 | if (typeof obj == 'undefined' || obj == 'undefined' || obj == null)
7 | {
8 | return false;
9 | }
10 |
11 | return true;
12 | }
13 |
14 | //Module exports
15 | module.exports = {
16 |
17 | isDefined : function(obj) {
18 |
19 | return _isDefined(obj);
20 | }
21 |
22 | };
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/express-route/templates/_route.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var helper = require('../helper.js');
3 | var cb = require('../cb.js');
4 |
5 | var router = express.Router();
6 | var bucket = cb.bucket();
7 |
8 | /**
9 | * Service method
10 | */
11 | router.get('<%= path %>', function (req, res) {
12 |
13 | //Your router code here
14 | //...
15 |
16 | //e.g.:
17 | //bucket.get(key, function(err, cbres) { ... });
18 | });
19 |
20 | module.exports = router;
21 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/_bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= _.slugify(_.humanize(appname)) %>",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "angular": "1.3.x",
6 | "json3": "^3.3.0",
7 | "es5-shim": "^4.0.0",
8 | "bootstrap": "^3.2.0",
9 | "angular-cookies": "1.3.x",
10 | "angular-resource": "1.3.x",
11 | "angular-route": "1.3.x"
12 | },
13 | "devDependencies": {
14 | "angular-mocks": "1.3.x",
15 | "angular-scenario": "1.3.x"
16 | },
17 | "appPath": "app"
18 | }
19 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/scripts/controllers/_main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name <%= _.slugify(_.humanize(appname)) %>.controller:MainCtrl
6 | * @description
7 | * # MainCtrl
8 | * Controller of the cbDemoQaApp
9 | */
10 | var app = angular.module('<%= _.slugify(_.humanize(appname)) %>');
11 |
12 | app.controller('MainCtrl', function ($scope) {
13 | $scope.awesomeThings = [
14 | 'HTML5 Boilerplate',
15 | 'AngularJS',
16 | 'Karma'
17 | ];
18 | });
19 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/views/_main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
Welcome!
8 |
9 |
10 | {{msg}}
11 |
12 |
13 |
14 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/scripts/_app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc overview
5 | * @name cbDemoQaApp
6 | * @description
7 | * # '<%= _.slugify(_.humanize(appname)) %>
8 | *
9 | * Main module of the application.
10 | */
11 | var app = angular.module('<%= _.slugify(_.humanize(appname)) %>', [
12 | 'ngCookies',
13 | 'ngResource',
14 | 'ngRoute'
15 | ]);
16 |
17 | app.config(function($routeProvider) {
18 |
19 |
20 | $routeProvider
21 | //-- cean: Routes
22 | .when('/', {
23 | templateUrl : 'views/main.html',
24 | controller : 'MyCtrl'
25 | })
26 | .otherwise({
27 | redirectTo: '/'
28 | });
29 | });
30 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/scripts/services/_myservice.js:
--------------------------------------------------------------------------------
1 | /**
2 | * TMyService
3 | */
4 |
5 | /*
6 | * Constructor
7 | */
8 | function TMyService(httpService)
9 | {
10 | this.httpService = httpService;
11 | }
12 |
13 |
14 | TMyService.prototype.get = function(id)
15 | {
16 | var url = "/service/get?id=" + id;
17 |
18 | var promise = this.httpService.get(url, {}).success(function (data) { /*Allows to handle the result and errors */ });
19 |
20 | return promise;
21 | }
22 |
23 | TMyService.prototype.add = function(id, msg)
24 | {
25 | var url = "/service/add?id=" + id + "&msg=" + msg;
26 |
27 | var promise = this.httpService.post(url, {}).success(function (data) { /*Allows to handle the result and errors */ });
28 |
29 | return promise;
30 | }
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/server/_app.js:
--------------------------------------------------------------------------------
1 | //Basic express requirements
2 | var express = require('express');
3 | var bodyParser = require('body-parser');
4 | var http = require('http');
5 |
6 | //The express application initialization
7 | var app = express();
8 |
9 | //The static resources
10 | app.use('/',express.static(__dirname + '/public'));
11 | app.use('/bower_components',express.static(__dirname + '/bower_components'));
12 |
13 | //Couchbase
14 | var cb = require('./cb.js');
15 | var con = cb.connect();
16 |
17 | //The service's base URL
18 | var SERVICE_URL = '/service/';
19 |
20 | //-- cean: Routers
21 | var demos = require('./routes/demo.js');
22 | app.use(SERVICE_URL, demos);
23 |
24 |
25 | //Web server
26 | server = app.listen(9000, function () {
27 |
28 | var host = server.address().address
29 | var port = server.address().port
30 |
31 | console.log('Example app listening at http://%s:%s', host, port)
32 |
33 | });
34 |
--------------------------------------------------------------------------------
/src/node-modules/cean-cli/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cean-cli",
3 | "version": "0.0.2",
4 | "description": "A command line interface for CEAN",
5 | "main": "cean-cli",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/dmaier-couchbase/cean.git"
12 | },
13 | "keywords": [
14 | "cli", "CEAN"
15 | ],
16 | "author": "david.maier@couchbase.com",
17 | "license": "Apache-2.0",
18 | "bugs": {
19 | "url": "https://github.com/dmaier-couchbase/cean/issues"
20 | },
21 | "homepage": "https://github.com/dmaier-couchbase/cean#readme",
22 | "dependencies": {
23 | "generator-cean" : "http://github.com/dmaier-couchbase/cean/raw/master/releases/generator-cean-0.1.0.tar.gz",
24 | "yeoman-generator": "^0.18.10",
25 | "yo": "^1.4.7",
26 | "bower" : "^1.4.1",
27 | "grunt-cli" : "^0.1.13",
28 | "grunt" : "^0.4.5"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/helper.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var fs = require('fs');
5 |
6 | function _replace(fileName, match , repl) {
7 |
8 | fs.readFile(fileName, 'utf8', function (err,data) {
9 |
10 | if (err) return console.log(err);
11 |
12 | var regexp = new RegExp(_escape(match),"g");
13 | var result = data.replace(regexp, repl);
14 |
15 | fs.writeFile(fileName, result, 'utf8', function (err) {
16 | if (err) return console.log(err);
17 | });
18 | });
19 | }
20 |
21 | function _escape(string) {
22 |
23 | return string.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
24 | }
25 |
26 |
27 | module.exports = {
28 |
29 | /**
30 | * Connect to Couchbase
31 | */
32 | replace : function(fileName, match, repl) {
33 |
34 | return _replace(fileName, match, repl);
35 | },
36 |
37 | escape : function(string) {
38 |
39 | return _escape(string);
40 | }
41 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CEAN = /kiːn/ = Couchbase + Express + AngularJS + Node.js
2 |
3 | This source code repository contains useful stuff regarding the subject 'Scaffolding modern JavaScript based web applications by using the C(ouchbase) + E(xpress) + A(ngularJS) + N(ode.js) stack'.
4 |
5 | The CEAN stack is based on the following components:
6 |
7 | * Couchbase Server / Couchbase Node.js module: A highly scalable distributed KV-Store and Document Database System
8 | * Express: A web application framework for Node.js
9 | * AngularJS: A client side JavaScript MVC web application framework
10 | * Node.js: A JavaScript oriented web service/application platform which is designed to build scalable network application
11 |
12 | # How to use
13 |
14 | There are two ways to use it.
15 |
16 | * Via the command line interface: [cean-cli](src/node-modules/cean-cli/README.md)
17 | * Via the Yeoman generator directly: [generator-cean](src/yeoman-generators/generator-cean/README.md)
18 |
19 | # Screenshots
20 | 
21 |
22 | # TODO-s
23 |
24 | Please have a look here: https://github.com/dmaier-couchbase/cean/issues
25 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/_package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= _.slugify(_.humanize(appname)) %>",
3 | "version": "0.0.0",
4 | "dependencies": {
5 | "express": "~4.9.0",
6 | "body-parser": "~1.8.1",
7 | "serve-favicon": "~2.1.3",
8 | "couchbase":"~2.1.2",
9 | "ottoman" : "~1.0.2"
10 | },
11 | "devDependencies": {
12 | "grunt": "^0.4.1",
13 | "grunt-autoprefixer": "^0.7.3",
14 | "grunt-concurrent": "^0.5.0",
15 | "grunt-contrib-clean": "^0.5.0",
16 | "grunt-contrib-concat": "^0.4.0",
17 | "grunt-contrib-connect": "^0.7.1",
18 | "grunt-contrib-copy": "^0.5.0",
19 | "grunt-contrib-cssmin": "^0.9.0",
20 | "grunt-contrib-htmlmin": "^0.3.0",
21 | "grunt-contrib-imagemin": "^0.8.1",
22 | "grunt-contrib-jshint": "^0.10.0",
23 | "grunt-contrib-uglify": "^0.4.0",
24 | "grunt-contrib-watch": "^0.6.1",
25 | "grunt-express-server": "^0.5.0",
26 | "grunt-filerev": "^0.2.1",
27 | "grunt-google-cdn": "^0.4.0",
28 | "grunt-newer": "^0.7.0",
29 | "grunt-ng-annotate": "^0.4.0",
30 | "grunt-parallel": "^0.4.1",
31 | "grunt-svgmin": "^0.4.0",
32 | "grunt-usemin": "^2.1.1",
33 | "grunt-wiredep": "^1.7.0",
34 | "jshint-stylish": "^0.2.0",
35 | "load-grunt-tasks": "^3.2.0",
36 | "time-grunt": "^0.3.1"
37 | },
38 | "engines": {
39 | "node": ">=0.10.0"
40 | },
41 | "scripts": {
42 | "test": "grunt test"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/_index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/_Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | // load all grunt tasks
3 | require('load-grunt-tasks')(grunt);
4 | grunt.initConfig({
5 | pkg: grunt.file.readJSON('package.json'),
6 | express: {
7 | options: {},
8 | web: {options: {script: 'app.js'}}
9 | },
10 | watch: {
11 | frontend: {
12 | options: {livereload: true},
13 | files: [
14 | 'public/*.html',
15 | 'public/views/*.html',
16 | 'public/styles/*.css',
17 | 'public/scripts/*.js',
18 | 'public/images/*.{png,jpg,jpeg}'
19 | ]
20 | },
21 | web: {
22 | files: [
23 | '*.js',
24 | 'routes/*.js'],
25 | tasks: ['express:web'],
26 | options: {
27 | nospawn: true,
28 | atBegin: true,
29 | }
30 | }
31 | },
32 | parallel: {
33 | web: {
34 | options: {stream: true},
35 | tasks: [
36 | {
37 | grunt: true,
38 | args: ['watch:frontend']
39 | },
40 | {
41 | grunt: true,
42 | args: ['watch:web']
43 | }
44 | ]
45 | }
46 | }
47 | });
48 | grunt.registerTask('web', ['parallel:web']);
49 | grunt.registerTask('default', ['web']);
50 | }
51 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/server/_cb.js:
--------------------------------------------------------------------------------
1 | //Deps
2 | var couchbase = require('couchbase');
3 |
4 | //Connection params
5 | var CB_HOST = '<%= host %>';
6 | var CB_BUCKET = '<%= bucket %>';
7 | var CB_PWD = '<%= password %>';
8 |
9 | //Global variables
10 | var _bucket;
11 | var _viewQuery;
12 |
13 |
14 | /**
15 | * A function to connect to Couchbase
16 | */
17 | function _connect(host, bckt, password)
18 | {
19 | var cluster = new couchbase.Cluster('couchbase://' + host);
20 | _bucket = cluster.openBucket(bckt, password);
21 | _viewQuery = new couchbase.ViewQuery();
22 |
23 | if (cluster && _bucket && _viewQuery)
24 | {
25 | console.log("cluster = " + JSON.stringify(cluster));
26 | console.log("bucket = " + JSON.stringify(_bucket));
27 |
28 | //Export the module variables
29 | var result = {};
30 | result.bucket = _bucket;
31 | result.viewQuery = _viewQuery;
32 | return result;
33 | }
34 | else
35 | {
36 | console.log("ERROR: Could not initialize Couchbase");
37 | }
38 | }
39 |
40 | //Module exports
41 | module.exports = {
42 |
43 | /**
44 | * Connect to Couchbase
45 | */
46 | connect : function() {
47 |
48 | return _connect(CB_HOST, CB_BUCKET, CB_PWD);
49 | },
50 |
51 | /**
52 | * Connect to Couchbase
53 | */
54 | connectOther : function(host, bckt, password) {
55 |
56 | return _connect(host, bckt, password);
57 | },
58 |
59 | /**
60 | * Get the bucket
61 | */
62 | bucket : function() {
63 |
64 | return _bucket;
65 | },
66 |
67 | /**
68 | * Get the viewQuery
69 | */
70 | viewQuery : function() {
71 |
72 | return _viewQuery;
73 | }
74 | };
75 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/scripts/controllers/_mycontroller.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * @ngdoc function
5 | * @name <%= _.slugify(_.humanize(appname)) %>.controller:MainCtrl
6 | * @description
7 | * # MyCtrl
8 | */
9 | var app = angular.module('<%= _.slugify(_.humanize(appname)) %>');
10 |
11 | app.controller('MyCtrl', function($scope, MyService) {
12 |
13 | //Get the message from Couchbase
14 | var id = "hello";
15 |
16 | $scope.msg = "This is the CEAN stack application skeleton!";
17 |
18 | MyService.get(id).then(
19 |
20 | function(ctx) {
21 |
22 | var result = ctx.data;
23 |
24 | if (!result.error)
25 | {
26 | var value = result.value;
27 |
28 | //Set the model
29 | if (value.msg) $scope.msg = value.msg;
30 | }
31 | }
32 | );
33 |
34 |
35 | //Execute when add is clicked
36 | $scope.onAddClicked = function () {
37 |
38 | var id = "hello";
39 | var msg = "Hello Couchbase!";
40 |
41 | MyService.add(id, msg).then(
42 |
43 | function(ctx) {
44 |
45 | var result = ctx.data;
46 |
47 | if (result.error)
48 | {
49 | $scope.msg = result.error;
50 | }
51 | else
52 | {
53 | $scope.msg = "Successfully added a document to your Couchbase bucket!";
54 | }
55 | },
56 |
57 | function(error) {
58 |
59 | $scope.msg = "Please configure your Couchbase connection!";
60 | }
61 |
62 | );
63 | }
64 | });
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/styles/_main.css:
--------------------------------------------------------------------------------
1 | /* Space out content a bit */
2 | body {
3 | padding-top: 20px;
4 | padding-bottom: 20px;
5 | }
6 |
7 | /* Everything but the jumbotron gets side spacing for mobile first views */
8 | .header,
9 | .marketing,
10 | .footer {
11 | padding-left: 15px;
12 | padding-right: 15px;
13 | }
14 |
15 | /* Custom page header */
16 | .header {
17 | border-bottom: 1px solid #e5e5e5;
18 | }
19 | /* Make the masthead heading the same height as the navigation */
20 | .header h3 {
21 | margin-top: 0;
22 | margin-bottom: 0;
23 | line-height: 40px;
24 | padding-bottom: 19px;
25 | }
26 |
27 | /* Custom page footer */
28 | .footer {
29 | padding-top: 19px;
30 | color: #777;
31 | border-top: 1px solid #e5e5e5;
32 | }
33 |
34 | /* Customize container */
35 | @media (min-width: 768px) {
36 | .container {
37 | max-width: 730px;
38 | }
39 | }
40 | .container-narrow > hr {
41 | margin: 30px 0;
42 | }
43 |
44 | /* Main marketing message and sign up button */
45 | .jumbotron {
46 | text-align: center;
47 | border-bottom: 1px solid #e5e5e5;
48 | }
49 | .jumbotron .btn {
50 | font-size: 21px;
51 | padding: 14px 24px;
52 | }
53 |
54 | /* Supporting marketing content */
55 | .marketing {
56 | margin: 40px 0;
57 | }
58 | .marketing p + h4 {
59 | margin-top: 28px;
60 | }
61 |
62 | /* Responsive: Portrait tablets and up */
63 | @media screen and (min-width: 768px) {
64 | /* Remove the padding we set earlier */
65 | .header,
66 | .marketing,
67 | .footer {
68 | padding-left: 0;
69 | padding-right: 0;
70 | }
71 | /* Space out the masthead */
72 | .header {
73 | margin-bottom: 30px;
74 | }
75 | /* Remove the bottom border on the jumbotron for visual effect */
76 | .jumbotron {
77 | border-bottom: 0;
78 | }
79 | }
80 |
81 | .hidden {
82 | visibility: hidden;
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/src/node-modules/cean-cli/cean-cli:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys')
3 | var spawn = require('child_process').spawn;
4 |
5 | //Commands
6 | var PATH = __dirname + "/node_modules/.bin"
7 | var COMMANDS = { "start" : PATH + "/grunt", "create" : PATH + "/yo cean", "add" : PATH + "/yo cean", "install" : "npm install" };
8 |
9 | /**
10 | * Usage details
11 | */
12 | function usage() {
13 |
14 | console.log("Use: cean-cli {install|run|create|add} {args}");
15 | }
16 |
17 | /**
18 | * Entry point of the CLI
19 | */
20 | function main() {
21 |
22 | //console.log("Execution envirnment is " + PATH + " .");
23 | var args = process.argv;
24 | //console.log( "Args are: " + args);
25 |
26 | if (args.length >= 3) {
27 |
28 | cmd = args[2];
29 |
30 | if ( cmd !== "--help" ) {
31 |
32 | mcmd = COMMANDS[cmd];
33 |
34 | if (typeof mcmd !== "undefined")
35 | {
36 |
37 | cargs = args.slice(3).join(' ');
38 |
39 | //console.log("args = " + cargs);
40 |
41 | strcmd = mcmd;
42 |
43 | //Pass the arguments and construct the execution command
44 | if ( cargs !== "" ) {
45 |
46 | //Default argument delimitter
47 | delim = " ";
48 |
49 | //For sub generators use ':' as delim
50 | if (cmd == "add") {
51 |
52 | delim = ":";
53 | }
54 |
55 | strcmd = strcmd + delim + cargs;
56 |
57 | //For create append the bower init command
58 | if ( cmd == "create") {
59 |
60 | strcmd = strcmd + ";" + PATH + "/bower install";
61 | }
62 | }
63 |
64 | console.log("cean-cli - Executing: " + strcmd);
65 |
66 | spawn('sh', ['-c', strcmd], { stdio: 'inherit' });
67 | }
68 | else {
69 | console.error("This subcommand is not supported.");
70 | usage();
71 | }
72 |
73 | } else {
74 |
75 | usage();
76 |
77 | }
78 | } else {
79 |
80 | console.error("You have to pass a subcommand!");
81 | usage();
82 | }
83 | }
84 |
85 | main();
86 |
--------------------------------------------------------------------------------
/src/node-modules/cean-cli/README.md:
--------------------------------------------------------------------------------
1 | # A Command Line Interface for CEAN
2 |
3 | This provides you a simple command line interface for application scaffolding. One of the advantages of using the CLI is that all the dependencie are installed locally with the CLI tool instead installing them globally to your Node.js installation.
4 |
5 | ## Reqirements
6 |
7 | A Linux/Unix/MacOS environment with Node.js, Npm, Make, Git and GCC has to be installed, e.g.:
8 |
9 | ```
10 | sudo apt-get install gcc
11 | sudo apt-get install git
12 | sudo apt-get make
13 | sudo apt-get nodejs
14 | sudo apt-get nodejs-legacy
15 | sudo apt-get npm
16 | ```
17 |
18 | ## Installation
19 |
20 | ### From a release
21 |
22 | ```
23 | npm install cean-cli
24 | ```
25 |
26 | This installs 'cean-cli' to the folder '$HOME/node_modules/cean-cli'.
27 |
28 | ### Via the source code
29 |
30 | Check out the code:
31 |
32 | ```
33 | git clone https://github.com/dmaier-couchbase/cean.git
34 |
35 | ```
36 |
37 | Change the directory to:
38 |
39 | ```
40 | cd /src/node-modules/cean-cli
41 | ```
42 |
43 | Run the installation script:
44 |
45 | ```
46 | ./cean-cli install
47 | ```
48 |
49 | ## How to use
50 |
51 | The Cean CLI is bypassing specific commands. More details can be found here [generator-cean](src/yeoman-generators/generator-cean/README.md).
52 |
53 | The command 'start' is referring to 'grunt'. The commands 'create' and 'add' are referring to 'yo'.
54 |
55 | The following examples assume that you have added the 'cean-cli' folder to your execution PATH
56 |
57 | ```
58 | #Add to the end of your $HOME/.profile
59 | export PATH=$HOME/node_modules/cean-cli:$PATH
60 | ```
61 |
62 | and that you are in an application directory of your choice:
63 |
64 | ```
65 | cd $APP_DIR
66 | ```
67 |
68 |
69 | ### Create a new application
70 |
71 | The following command can be used to create a new application:
72 |
73 | ```
74 | cean-cli create myapp
75 | ```
76 |
77 | ### Sub-Generators
78 |
79 | The following shows how to use sub-generators:
80 |
81 | ```
82 | cean-cli add angular-controller TestCtrl myapp
83 | cean-cli add angular-view test
84 | cean-cli add angular-route test.html TestCtrl
85 | ```
86 |
87 | ### Start the application
88 |
89 | ```
90 | cean-cli start
91 | ```
92 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/server/_route_demo.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 |
4 | var helper = require('../helper.js');
5 | var cb = require('../cb.js');
6 |
7 | var bucket = cb.bucket();
8 |
9 |
10 | /**
11 | * Add a document
12 | */
13 | router.post('/add', function (req, res) {
14 |
15 | var id = req.query.id;
16 | var msg = req.query.msg;
17 |
18 | if (helper.isDefined(id) && helper.isDefined(msg))
19 | {
20 | var key = "msg::" + id;
21 | var doc = { 'msg' : msg };
22 |
23 | bucket.insert( key, doc, function(err, cbres) {
24 |
25 | if (err)
26 | {
27 | var emsg = "Could not add the document!";
28 | console.log("ERROR " + emsg);
29 | res.json({ "error" : emsg });
30 |
31 | }
32 | else
33 | {
34 | console.log("Added " + key + " to Couchbase");
35 | res.json({ 'success' : true });
36 | }
37 | });
38 | }
39 | else
40 | {
41 | var emsg = "Did you pass all mandatory parameters?";
42 | console.log("ERROR: " + emsg);
43 | res.json({"error" : emsg});
44 | }
45 | });
46 |
47 |
48 | /**
49 | * Get a document
50 | */
51 | router.get('/get', function (req, res) {
52 |
53 | var id = req.query.id;
54 |
55 | if (helper.isDefined(id))
56 | {
57 | var key = "msg::" + id;
58 |
59 | bucket.get(key, function(err, cbres) {
60 |
61 | if (err)
62 | {
63 | var emsg = "Could not get the document!";
64 | console.log("ERROR" + emsg);
65 | res.json({ "error" : emsg });
66 |
67 | }
68 | else
69 | {
70 | console.log("Got " + JSON.stringify(cbres));
71 | res.json(cbres);
72 | }
73 |
74 | });
75 | }
76 | else
77 | {
78 | var emsg = "Did you pass all mandatory parameters?";
79 | console.log("ERROR: " + emsg);
80 | res.json({"error" : emsg});
81 | }
82 | });
83 |
84 | module.exports = router;
85 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/express-route/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | //Import the base generator module
4 | var gens = require('yeoman-generator');
5 | var helper = require('../app/helper.js');
6 |
7 | //Extend the base generator
8 | module.exports = gens.NamedBase.extend({
9 |
10 | constructor: function () {
11 |
12 | //Call the super constructor
13 | gens.NamedBase.apply(this, arguments);
14 |
15 | //Arguments
16 | this.project = this.destinationRoot();
17 |
18 |
19 | },
20 |
21 | info : function () {
22 |
23 | //Print some info
24 | console.log("== CEAN - Express Router Generator ==");
25 | console.log("project = " + this.project);
26 | console.log("name = " + this.name);
27 | },
28 |
29 | askForFileName : function () {
30 |
31 | var done = this.async();
32 | this.prompt({
33 | type : 'input',
34 | name : 'filename',
35 | message : 'Router File Name',
36 | default : this._.slugify(this._.humanize(this.name)) + ".js"
37 | }, function (answers) {
38 | this.log(answers.filename);
39 | this.filename = answers.filename;
40 | done();
41 | }.bind(this));
42 | },
43 |
44 | askForPath : function () {
45 |
46 | var done = this.async();
47 | this.prompt({
48 | type : 'input',
49 | name : 'path',
50 | message : 'Relative Path',
51 | default : '/' + this._.slugify(this._.humanize(this.name))
52 | }, function (answers) {
53 | this.log(answers.path);
54 | this.path = answers.path;
55 | done();
56 | }.bind(this));
57 | },
58 |
59 | createRouter : function () {
60 |
61 | //Apply templates
62 | this.template('_route.js', 'routes/' + this.filename);
63 | },
64 |
65 | registerRouter : function() {
66 |
67 | console.log("Adding the route to app.js ...");
68 |
69 | //Register the router by adding it to the server side application entry point 'app.js'
70 | var file = this.project + "/app.js";
71 |
72 | helper.replace(file, '//-- cean: Routers',
73 | '//-- cean: Routers\n' +
74 | 'var ' + this._.slugify(this._.humanize(this.name)) + ' = require("./routes/' + this.filename + '");\n' +
75 | 'app.use(SERVICE_URL, ' + this._.slugify(this._.humanize(this.name)) + ');\n'
76 | );
77 | }
78 | });
79 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/angular-controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | //Import the base generator module
4 | var helper = require('../app/helper.js');
5 | var gens = require('yeoman-generator');
6 |
7 | //Extend the base generator
8 | module.exports = gens.NamedBase.extend({
9 |
10 | constructor: function () {
11 |
12 | //Call the super constructor
13 | gens.NamedBase.apply(this, arguments);
14 |
15 | //Arguments
16 | this.argument('appname', { type: String, required: true });
17 | this.appname = this._.camelize(this.appname);
18 | this.project = this.destinationRoot();
19 | },
20 |
21 | info : function () {
22 |
23 | //Print some info
24 | console.log("== CEAN - Angular Controller Generator ==");
25 | console.log("project = " + this.project);
26 | console.log("appname = " + this.appname);
27 | console.log("name = " + this.name);
28 | },
29 |
30 | askForFileName : function () {
31 |
32 | var done = this.async();
33 | this.prompt({
34 | type : 'input',
35 | name : 'filename',
36 | message : 'Controller File Name',
37 | default : this._.slugify(this._.humanize(this.name)) + ".js"
38 | }, function (answers) {
39 | this.log(answers.filename);
40 | this.filename = answers.filename;
41 | done();
42 | }.bind(this));
43 | },
44 |
45 | askForName : function () {
46 |
47 | var done = this.async();
48 | this.prompt({
49 | type : 'input',
50 | name : 'name',
51 | message : 'Controller Name',
52 | default : this._.camelize(this.name)
53 | }, function (answers) {
54 | this.log(answers.name);
55 | this.name = answers.name;
56 | done();
57 | }.bind(this));
58 | },
59 |
60 | createController : function () {
61 |
62 | //Apply templates
63 | this.template('_controller.js', 'public/scripts/controllers/' + this.filename);
64 | },
65 |
66 | registerController : function() {
67 |
68 | console.log("Adding controller to index.html ...");
69 |
70 | //Controller needs to be added to the index.html file after
71 | var file = this.project + "/public/index.html";
72 |
73 | helper.replace(file, '',
74 | ' \n' +
75 | '');
76 | }
77 | });
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/angular-view/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | //Import the base generator module
4 | var gens = require('yeoman-generator');
5 | var helper = require('../app/helper.js');
6 |
7 | //Extend the base generator
8 | module.exports = gens.NamedBase.extend({
9 |
10 | constructor: function () {
11 |
12 | //Call the super constructor
13 | gens.NamedBase.apply(this, arguments);
14 |
15 | //Arguments
16 | this.project = this.destinationRoot();
17 | },
18 |
19 | info : function () {
20 |
21 | //Print some info
22 | console.log("== CEAN - Angular View Generator ==");
23 | console.log("project = " + this.project);
24 | console.log("name = " + this.name);
25 | },
26 |
27 | askForFileName : function () {
28 |
29 | var done = this.async();
30 | this.prompt({
31 | type : 'input',
32 | name : 'filename',
33 | message : 'View File Name',
34 | default : this._.slugify(this._.humanize(this.name)) + ".html"
35 | }, function (answers) {
36 | this.log(answers.filename);
37 | this.filename = answers.filename;
38 | done();
39 | }.bind(this));
40 | },
41 |
42 | askForName : function () {
43 |
44 | var done = this.async();
45 | this.prompt({
46 | type : 'input',
47 | name : 'name',
48 | message : 'View Name',
49 | default : this._.camelize(this.name)
50 | }, function (answers) {
51 | this.log(answers.name);
52 | this.name = answers.name;
53 | done();
54 | }.bind(this));
55 | },
56 |
57 | askForSubtitle : function () {
58 |
59 | var done = this.async();
60 | this.prompt({
61 | type : 'input',
62 | name : 'subtitle',
63 | message : 'Sub title',
64 | default : 'Hello Couchbase!'
65 | }, function (answers) {
66 | this.log(answers.subtitle);
67 | this.subtitle = answers.subtitle;
68 | done();
69 | }.bind(this));
70 | },
71 |
72 | createView : function () {
73 |
74 | //Apply templates
75 | this.template('_view.html', 'public/views/' + this.filename);
76 | },
77 |
78 | registerView : function() {
79 |
80 | console.log("Adding the view to header.html ...");
81 |
82 | //The view needs to be added to the menu and so the header.html file
83 | var file = this.project + "/public/views/header.html";
84 |
85 | helper.replace(file, '',
86 | ' \n' +
87 | ' ' + this.name + ' ');
88 | }
89 | });
90 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/angular-service/index.js:
--------------------------------------------------------------------------------
1 | //TODO!!!
2 |
3 | 'use strict';
4 |
5 | //Import the base generator module
6 | var gens = require('yeoman-generator');
7 | var helper = require('../app/helper.js');
8 |
9 | //Extend the base generator
10 | module.exports = gens.NamedBase.extend({
11 |
12 | constructor: function () {
13 |
14 | //Call the super constructor
15 | gens.NamedBase.apply(this, arguments);
16 |
17 | //Arguments
18 | this.project = this.destinationRoot();
19 | },
20 |
21 | info : function () {
22 |
23 | //Print some info
24 | console.log("== CEAN - Angular Service Generator ==");
25 | console.log("project = " + this.project);
26 | console.log("name = " + this.name);
27 | },
28 |
29 | askForFileName : function () {
30 |
31 | var done = this.async();
32 | this.prompt({
33 | type : 'input',
34 | name : 'filename',
35 | message : 'Service File Name',
36 | default : this._.slugify(this._.humanize(this.name)) + ".js"
37 | }, function (answers) {
38 | this.log(answers.filename);
39 | this.filename = answers.filename;
40 | done();
41 | }.bind(this));
42 | },
43 |
44 | askForName : function () {
45 |
46 | var done = this.async();
47 | this.prompt({
48 | type : 'input',
49 | name : 'name',
50 | message : 'Service Name',
51 | default : this._.camelize(this.name)
52 | }, function (answers) {
53 | this.log(answers.name);
54 | this.name = answers.name;
55 | done();
56 | }.bind(this));
57 | },
58 |
59 | createService : function () {
60 |
61 | //Apply templates
62 | this.template('_service.js', 'public/scripts/services/' + this.filename);
63 | },
64 |
65 | registerService : function() {
66 |
67 | console.log("Adding the service to index.html ...");
68 |
69 | //The view needs to be added to the menu and so the header.html file
70 | var file = this.project + "/public/index.html";
71 |
72 | helper.replace(file, '',
73 | ' \n' +
74 | '');
75 |
76 |
77 | console.log("Adding the service to the main.js ...");
78 |
79 | file = this.project + "/public/scripts/services/main.js";
80 |
81 | helper.replace(file, '//-- cean: Services',
82 | '//-- cean: Services\n' +
83 | 'services.factory("' + this.name + '", function($http) {\n'+
84 | 'var service = new T' + this.name + '($http);\n'+
85 | 'return service;\n'+
86 | '});\n');
87 | }
88 | });
89 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/angular-route/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | //Import the base generator module
4 | var helper = require('../app/helper.js');
5 | var gens = require('yeoman-generator');
6 | var fs = require('fs');
7 |
8 | //Extend the base generator
9 | module.exports = gens.Base.extend({
10 |
11 | constructor: function () {
12 |
13 | //Call the super constructor
14 | gens.Base.apply(this, arguments);
15 |
16 | //Parameters
17 | this.argument('viewfilename', { type: String, required: true });
18 | this.argument('controllername', { type: String, required: true });
19 |
20 | this.project = this.destinationRoot();
21 | },
22 |
23 | info : function () {
24 |
25 | //Print some info
26 | console.log("== CEAN - Angular Route Generator ==");
27 | console.log("project = " + this.project);
28 | console.log("viewfilename = " + this.viewfilename);
29 | console.log("controllername = " + this.controllername);
30 |
31 | //Print a list views
32 | console.log("");
33 | console.log("== Views ==");
34 | var views = fs.readdirSync('public/views');
35 | console.log(JSON.stringify(views));
36 |
37 |
38 | //Print a list controllers
39 | console.log("");
40 | console.log("== Controllers ==");
41 | var controllers = fs.readdirSync('public/scripts/controllers');
42 | console.log(JSON.stringify(controllers));
43 | console.log("");
44 | },
45 |
46 | askForViewFileName : function () {
47 |
48 | var done = this.async();
49 | this.prompt({
50 | type : 'input',
51 | name : 'viewfilename',
52 | message : 'The file name of the View',
53 | default : this._.camelize(this.viewfilename)
54 | }, function (answers) {
55 | this.log(answers.viewfilename);
56 | this.viewfilename = answers.viewfilename;
57 | done();
58 | }.bind(this));
59 | },
60 |
61 | askForControllerName : function () {
62 |
63 | var done = this.async();
64 | this.prompt({
65 | type : 'input',
66 | name : 'controllername',
67 | message : 'Controller Name',
68 | default : this._.camelize(this.controllername)
69 | }, function (answers) {
70 | this.log(answers.controllername);
71 | this.controllername = answers.controllername;
72 | done();
73 | }.bind(this));
74 | },
75 |
76 | register : function() {
77 |
78 | console.log("Adding a route to app.js ...");
79 |
80 | //Route needs to be added to the app.js file after //-- cean: Routes
81 | var file = this.project + "/public/scripts/app.js";
82 |
83 | helper.replace(file, '//-- cean: Routes',
84 | '//-- cean: Routes \n' +
85 | '.when(\'/' + this.viewfilename + '\', { templateUrl : \'views/' +
86 | this.viewfilename + '\', controller : \'' + this.controllername + '\' })\n');
87 | }
88 | });
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/README.md:
--------------------------------------------------------------------------------
1 | # CEAN Yeoman Generator
2 |
3 | The tooling is based on Yeoman ( http://yeoman.io ):
4 |
5 | * Yo: The web's scaffolding tool for modern webapps
6 | * Grunt: The JavaScript Task Runner
7 | * Bower: Dependency management for your client side stuff
8 |
9 | # Requirements
10 |
11 | * Install the following on your development machine. For instance for Ubuntu 14.04:
12 | ```
13 | sudo apt-get install gcc
14 | sudo apt-get make
15 | sudo apt-get git
16 | sudo apt-get nodejs
17 | sudo apt-get nodejs-legacy
18 | sudo apt-get npm
19 | sudo npm install -g yo
20 | sudo npm install -g grunt-cli
21 | sudo npm install -g bower
22 | ```
23 |
24 | * On Mac OSX:
25 | First, install homebrew: http://brew.sh.
26 | * Then, install node.js etc: https://stackoverflow.com/questions/28017374/what-is-the-suggested-way-to-install-brew-node-js-io-js-nvm-npm-on-os-x
27 |
28 | Then:
29 | ```
30 | sudo npm install -g yo
31 | sudo npm install -g grunt-cli
32 | sudo npm install -g bower
33 | ```
34 |
35 |
36 | # How to use
37 |
38 | * Clone this repository
39 | ```
40 | git clone https://github.com/dmaier-couchbase/cean.git
41 | ```
42 | * Change the directory
43 | ```
44 | cd cean/src/yeoman-generators/generator-cean
45 | ```
46 | * Link the Generator by resolving the deps
47 | ```
48 | sudo npm link
49 | ```
50 | * Side note: Double check that you have permissions to $HOME/tmp, if not use 'chown' in order to change the owner of this directory!
51 | * Create a new project directory
52 | ```
53 | cd --
54 | mkdir myapp
55 | cd myapp
56 | ```
57 | * Scaffold a new Couchbase application
58 | ```
59 | yo cean myapp
60 | ```
61 | * Answer the questions regarding 'Couchbase Host', 'Couchbase Bucket', 'Couchbase Password'! Please also make sure that the bucket is existent and accessible with this password. For instance:
62 | ```
63 | == This is the Couchbase CEAN generator ==
64 | appname = myapp
65 | [?] Your Couchbase Host: 192.168.7.160
66 | 192.168.7.160
67 | [?] Your Couchbase Bucket: cean
68 | cean
69 | [?] Your Couchbase Bucket Password: test
70 | test
71 | ...
72 | ```
73 | * Wait until all dependencies are downloaded!
74 | * Start the application
75 | ```
76 | grunt
77 | ```
78 | * Open the example application in your browser, E.G:
79 | ```
80 | http://192.168.7.162:9000/
81 | ```
82 | * Click on the 'Add Test Document' button
83 | * Also inspect the log output of your application
84 | * If everything worked fine then you get a success message:
85 | ```
86 | Successfully added a document to your Couchbase bucket!
87 | ```
88 | * Reload the page and you should see the just inserted message:
89 | ```
90 | Hello Couchbase!
91 | ```
92 |
93 | # Grunt
94 |
95 | Grunt is used to host the application and enjoy automagically LiveReloaded server and client application when you make changes!
96 |
97 | ```
98 | grunt
99 | ```
100 |
101 | If you don't want to use the Grunt script then the application can be also started via:
102 |
103 | ```
104 | node app.js
105 | ```
106 |
107 | # Sub-Generators
108 |
109 | The following sub-generators are currently available
110 |
111 | * angular-controller: Adds an Angular controller to your project
112 | * angular-view: Adds an angular view to your project
113 | * angular-route: Adds a route by glueing the controller and the view together
114 | * angular-service: Adds a service wrapper, which means a client side REST client for an existing Express router
115 | * express-route: Adds an express router. This is used for implementing server side REST services those are bound to specific paths.
116 |
117 | Here an example which adds a controller which is named 'TestCtrl' to the application called 'myapp'. In the next step a new view with the name 'test' is created. Afterwards a route is added in order to make sure that the test controller is used together with the test view.
118 |
119 | ```
120 | yo cean:angular-controller TestCtrl myapp
121 | yo cean:angular-view test
122 | yo cean:angular-route test.html TestCtrl
123 | ```
124 |
125 | Important: Files have CEAN markers in them in order to make this work. Markers are realized as source code comments. So you should not remove something like '--cean: ${Marker}' in your source code. This would basically break some sub-generator funtionality.
126 |
127 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/templates/client/_404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Page Not Found :(
6 |
141 |
142 |
143 |
144 |
Not found :(
145 |
Sorry, but the page you were trying to view does not exist.
146 |
It looks like this was the result of either:
147 |
148 | - a mistyped address
149 | - an out-of-date link
150 |
151 |
154 |
155 |
156 |
157 |
158 |
--------------------------------------------------------------------------------
/src/yeoman-generators/generator-cean/app/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | //Import the base generator module
4 | var path = require('path');
5 | var gens = require('yeoman-generator');
6 |
7 | //Extend the base generator
8 | module.exports = gens.Base.extend({
9 |
10 | constructor: function () {
11 |
12 | //Call the super constructor
13 | gens.Base.apply(this, arguments);
14 |
15 | //Arguments
16 | this.argument('appname', { type: String, required: true });
17 | this.appname = this._.camelize(this.appname);
18 |
19 | this.host = "localhost";
20 | this.bucket = "default";
21 | this.password = "";
22 |
23 | },
24 |
25 | info : function () {
26 |
27 | //Print some info
28 | console.log("== This is the Couchbase CEAN generator ==");
29 | console.log("appname = " + this.appname);
30 | },
31 |
32 | askForHost : function () {
33 |
34 | var done = this.async();
35 | this.prompt({
36 | type : 'input',
37 | name : 'host',
38 | message : 'Your Couchbase Host',
39 | default : this.host
40 | }, function (answers) {
41 | this.log(answers.host);
42 | this.host = answers.host;
43 | done();
44 | }.bind(this));
45 | },
46 |
47 | askForBucket : function () {
48 |
49 | var done = this.async();
50 | this.prompt({
51 | type : 'input',
52 | name : 'bucket',
53 | message : 'Your Couchbase Bucket',
54 | default : this.bucket
55 | }, function (answers) {
56 | this.log(answers.bucket);
57 | this.bucket = answers.bucket;
58 | done();
59 | }.bind(this));
60 | },
61 |
62 | askForPassword : function () {
63 |
64 | var done = this.async();
65 | this.prompt({
66 | type : 'input',
67 | name : 'password',
68 | message : 'Your Couchbase Bucket Password',
69 | default : this.password
70 | }, function (answers) {
71 | this.log(answers.password);
72 | this.password = answers.password;
73 | done();
74 | }.bind(this));
75 | },
76 |
77 | baseapp : function () {
78 |
79 | this.template('_bower.json', 'bower.json');
80 | this.template('_package.json', 'package.json');
81 | this.copy('_Gruntfile.js', 'Gruntfile.js');
82 | },
83 |
84 | serverapp : function () {
85 |
86 | //Create a routes folder
87 | this.mkdir('routes');
88 |
89 | //Copy files
90 | this.copy('server/_app.js', 'app.js');
91 | this.copy('server/_helper.js', 'helper.js');
92 | this.copy('server/_route_demo.js', 'routes/demo.js');
93 |
94 | //Apply templates
95 | this.template('server/_cb.js', 'cb.js');
96 | },
97 |
98 | clientapp : function () {
99 |
100 | //Create the project directory structure
101 | this.mkdir('public');
102 | this.mkdir('public/images');
103 | this.mkdir('public/scripts');
104 | this.mkdir('public/scripts/controllers');
105 | this.mkdir('public/scripts/services');
106 | this.mkdir('public/styles');
107 | this.mkdir('public/views');
108 |
109 | //Copy files
110 | this.copy('client/_404.html', 'public/404.html');
111 | this.copy('client/_favicon.ico', 'public/favicon.ico');
112 | this.copy('client/_robots.txt', 'public/robots.txt');
113 | this.copy('client/images/_cb.png', 'public/images/cb.png');
114 | this.copy('client/images/_yeoman.png', 'public/images/yeoman.png');
115 | this.copy('client/styles/_main.css', 'public/styles/main.css');
116 |
117 |
118 | //Apply templates
119 | this.template('client/_index.html', 'public/index.html');
120 | this.template('client/scripts/_app.js', 'public/scripts/app.js');
121 | this.template('client/scripts/controllers/_main.js', 'public/scripts/controllers/main.js');
122 | this.template('client/scripts/controllers/_mycontroller.js', 'public/scripts/controllers/mycontroller.js');
123 | this.template('client/scripts/services/_main.js', 'public/scripts/services/main.js');
124 | this.template('client/scripts/services/_myservice.js', 'public/scripts/services/myservice.js');
125 | this.template('client/views/_footer.html', 'public/views/footer.html');
126 | this.template('client/views/_header.html', 'public/views/header.html');
127 | this.template('client/views/_main.html', 'public/views/main.html');
128 | },
129 |
130 | writing: function() {
131 | //Gruntfile.js cleverness can go here.
132 | },
133 |
134 | installDeps : function() {
135 |
136 | this.installDependencies();
137 |
138 | }
139 | });
140 |
--------------------------------------------------------------------------------