1.4.11 • Published 9 years ago

generator-bookon v1.4.11

Weekly downloads
6
License
GPL-3.0
Repository
github
Last release
9 years ago

BookOn Generator

A Yeoman generator for scaffolding boilerplate web applications with Material Angular

Goal and Motivation

The goal of generator-bookon is to facilitate modular client-side programming for small front-end projects and prototypes. It illustrates how AngularJS can be used in combination with RequireJs to produce reusable, manageable code.

Table of Contents

  1. Installation
  2. Usage
  3. Web App
    1. Application
    2. Static Application
    3. Feature
  4. Components
  5. Arguments
  6. Options
  7. Notes
  8. License

Installation

npm install -g generator-bookon

Usage

Projects may be scaffolded from the default menu...

yo bookon

.. or directly from the command line.

yo bookon:webapp

Web App

There are 2 types of web app generators:

App TypeGenerator
Dynamicbookon:webapp
Staticbookon:static

Each generator will allow you to create a Single-View or Multi-View web application.

Application

Dynamic applications are served using Node, so after scaffolding be sure to install dependencies and start the web server.

cd <application-name>
npm install
...
node index.js
server listening on port 3000!

After starting the server, visit http://localhost:3000/.

Static Application

Static applications run off the filesystem using the file:// protocol. To run your static application open index.html in a browser.

Note:

Angular uses XHR calls to download template files. Several browsers restrict XHR calls when using the file:// protocol. This will result in an error. The right approach here is to (1) run index.html in another browser such as FireFox, or (2) generate a Dynamic Multi-View application using bookon:webapp.

Feature

By default, when you generate components they are organized by type.

App TypeLocation
Dynamicpublic/app/<component-type>/
Staticapp/<component-type>/

For example:

    cd myDynamicApp
    yo bookon:controller "contactCtrl"
        create public/app/controllers/contactCtrl.js

Use the bookon:feature generator if you want to group related codefiles. You will have an option to name the Feature. After selecting the components you would like to include, the code files will be placed under app/<feature-name>/ (if you are in a Static Application). If you are in a Dynamic Application the components will be placed in public/app/<feature-name>/. More components may be added to the Feature directory also (see Options).

Components

There are 7 component generators:

  1. bookon:controller
  2. bookon:directive
  3. bookon:factory
  4. bookon:filter
  5. bookon:provider
  6. bookon:service
  7. bookon:template

Command:

yo bookon:<component-name>

Arguments

All generators accept a single argument for the name.

Example:

yo bookon:feature "contact"

Options

Each of the 7 component generators have a --path option to specify the component location. You may use this option to add files to a Feature directory.

Example:

yo bookon:template --path "public/app/contact"

Templates

The bookon:template generator has an option for the template type: --controller or --directive. The previous command could be written as:

yo bookon:template --path "public/app/contact" --controller 

Static App

The bookon:static generator has an option for the view type: --single or --multi.

Example:

yo bookon:static "demoApp" --single

Arguments + Options

You may combine Arguments and Options in a single command. Keep in mind that the name argument must come before --option.

yo bookon:<generator> "<name>" --<option> "<value>" --<another-option>

Notes

  • When you generate components the file path is relative to the project root (not the current working directory). This also applies when using the --path option.

  • Each time you generate a component you must also modify app/app.js to load the component script file and inject it as a dependency.

  • Generators create directories and subdirectories if they do not already exist.

  • You may also generate components with bookon:component. This generator accepts the name argument and 3 options:

    OptionTypeDescription
    pathStringpath/to/a/folder
    typeStringComponent type (ex. filter)
    templateTypeStringcontroller or directive
  • Beneath the hood, bookon:webapp calls 2 generators not discussed earlier - these generate Dynamic applications.

    1. bookon:single
    2. bookon:multi

License

Copyright (c) 2016 Stephen Tillman | Licensed under the GPL license.

1.4.11

9 years ago

1.4.9

9 years ago

1.4.8

9 years ago

1.4.7

9 years ago

1.4.6

9 years ago

1.4.5

9 years ago

1.4.4

9 years ago

1.4.3

9 years ago

1.4.2

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago