Giter Club home page Giter Club logo

generator-base-angularjs's Introduction

generator-base-angularjs

npm version Build Status Code Climate Dependency Status Installs License Analytics

Zguillez | Guillermo de la Iglesia

Yeoman generator for AngularJS webapp development. With RequireJS, Bootstrap, Sass, and templating with Jade.

Getting Started

Install Yeoman

npm install -g yo

Yeoman Generators

To install generator-base-angularjs from npm, run:

npm install -g generator-base-angularjs

Finally, initiate the generator:

yo base-angularjs

If you have error on install try to update dependences manually:

sudo npm update
bower update

Requeriments

NodeJS

For update npm

sudo npm install npm -g

Bower

npm install -g bower

Sass

sudo gem install sass

Documentation:

Usage

Develop code on folder /src

/src
    /data
    /images
    /scripts
        /controllers
        /directives
    /styles
    /templates

Compile code

Use grunt task to compile code and deploy webapp

grunt serve

THis will launch server on port 9000

http://localhost:9000/

Distribute code is compileded on forder /dist

/dist
    /css
    /data
    /images
    /js
    /lib
    /templates

Routing

Put the routes for your app into file /script/routes.js.

define(['controllers', 'directives'], function() {
    'use strict';
    window.app.config(['$routeProvider',
        function($routeProvider) {
            $routeProvider.
            when('/', {
                templateUrl: 'templates/index.html',
                controller: 'indexController'
            }).
            otherwise({
                redirectTo: '/'
            });
        }
    ]);
});

Controllers

Controllers are loaded by RequireJS. Put all your neededed controllers into file /scripts/controllers.js.

define(['controllers/index'], function(indexController) {
    'use strict';
    window.app.controller('indexController', indexController);
});

The controllers files should be located into folder /scripts/controllers/

//scripts/controllers/index.js

define([], function() {
    'use strict';

    function indexController($scope, $http) {
        $scope.data = {};
        $scope.data.libs = [];
        $http.get('data/data.json').then(function(result) {
            $scope.data.libs = result.data;
        });
    }
    indexController.$inject = ['$scope', '$http'];
    return indexController;
});

Directives

Directives are loaded by RequireJS. Put all your neededed directives into file /scripts/directives.js.

define(['directives/header', 'directives/footer'], function(headerDirective, footerDirective) {
    'use strict';
    window.app.directive('ngheader', headerDirective);
    window.app.directive('ngfooter', footerDirective);
});

The directive files should be located into folder /scripts/directives/

//scripts/directives/header.js

define(['controllers/header', 'text!../../templates/header.html'], function(controller, template) {
    'use strict';

    function headerDirective() {
        return {
            restrict: 'A',
            controller: controller,
            template: template
        };
    }
    return headerDirective;
});

You can use RequireJS Text plugin to load a tempate file for the directive and inject a controller.

Templating

The NodeJS template engine JADE is implemented. Jade files (*.jade) must be located on /templates folder root.

  • Grunt task jade.js will process the files into HTML files to folder /templates/html.
  • Grunt task copy.js will copy all CSS files into /templates/html to folder /dist/templates for ditribution.
  • You can also create and edit HTML templates files in /templates/html.

You can use combined Jade and Angular directives for templating:

//templates/index.jade

header('ngheader'='')

section(class='content')

header
    img(class='logo', src='images/angularjs.png')

.buttons.row
    a('ng-repeat'='lib in data.libs', 'class'='btn btn-default btn-sm', 'href'='{{lib.url}}', 'target'='_black') {{lib.name}}

footer('ngfooter'='')

Documentation:

Styling

Sass files (*.sass, *.scss) must be located on /src/styles folder root.

  • Grunt task sass.js will process the files into CSS files to folder /src/styles/css.
  • Grunt task copy.js will copy all CSS files into /src/styles/css to folder /dist/css for ditribution.
  • You can also create and edit CSS files in /src/styles/css.

Contributing and issues

Contributors are welcome, please fork and send pull requests! If you have any ideas on how to make this project better then please submit an issue or send me an email.

License

©2016 Zguillez.io

Original code licensed under MIT Open Source projects used within this project retain their original licenses.

Changelog

v1.0.0 (January 12, 2016)

  • Fix yo install version

v0.1.7 (Decenber 21, 2015)

  • Grunt livereload

v0.1.5 (October 21, 2015)

  • Fixed jshint isuses

v0.1.0 (October 20, 2015)

  • Initial AngularJS skeleton

Features:

  • Bootstrap
  • Jquery
  • Sass
  • Jade templating
  • JSHint code chech
  • Grunt tasks

generator-base-angularjs's People

Contributors

zguillez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.