Skip to content

Instantly share code, notes, and snippets.

@axpro
Forked from dstevensio/rejoice.md
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save axpro/6b023ea219907ce0ee7c to your computer and use it in GitHub Desktop.

Select an option

Save axpro/6b023ea219907ce0ee7c to your computer and use it in GitHub Desktop.

Revisions

  1. @dstevensio dstevensio revised this gist Feb 12, 2015. 1 changed file with 14 additions and 14 deletions.
    28 changes: 14 additions & 14 deletions rejoice.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ exports.register = function (server, options, next) {
    };

    exports.register.attributes = {
    pkg: require('./package.json');
    pkg: require('./package.json')
    };
    ```

    @@ -82,29 +82,29 @@ exports.register.attributes = {

    ## package.json for project

    ### add "start" to scripts:

    ```js
    {
    "name": "example",
    "version": "0.0.1",
    "description": "POC",
    "main": "index",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node node_modules/rejoice/bin/rejoice -c config/manifest.json"
    },
    "author": "Your Name <you@wherever.com>",
    "license": "ISC",
    }
    ```

    ### add home module to dependencies:

    (There will be other dependencies, don't remove them - not listing them here for brevity)

    ```js
    "dependencies": {
    "handlebars": "^2.0.0",
    "rejoice": "^2.0.0",
    "visionary": "^2.0.0",
    "exampleHome": "./lib/modules/home"
    }
    }
    ```

    Note: exampleHome is specifying the local directory that contains the plugin, if you do this you need to npm install each time you make changes to it. This could alternatively be a git repository for true modularization of sections, or an npm published module (private or public NPM, whatever makes sense)

    ## install local home module via npm
    `npm install`

    ## starting the server
    `npm start`

  2. @dstevensio dstevensio revised this gist Feb 12, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions rejoice.md
    Original file line number Diff line number Diff line change
    @@ -74,6 +74,9 @@ exports.register.attributes = {
    }
    ```

    ## initialize npm for project
    `npm init`

    ## install dependencies
    `npm install --save rejoice handlebars visionary`

  3. @dstevensio dstevensio created this gist Feb 12, 2015.
    108 changes: 108 additions & 0 deletions rejoice.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,108 @@
    Brand new project, create dirs "lib/modules", "lib/templates", "config"

    ## lib/modules/home/index.js :

    ```js
    exports.register = function (server, options, next) {

    server.route({
    path: '/',
    method: 'GET',
    handler: function (request, reply) {

    reply.view('home', {title: 'Home Page'});

    }
    });

    next();

    };

    exports.register.attributes = {
    pkg: require('./package.json');
    };
    ```

    ## lib/modules/home/package.json :

    ```js
    {
    "name": "exampleHome",
    "version": "0.0.1"
    }
    ```

    ## lib/templates/layout.html :

    ```html
    <!DOCTYPE html>
    <html>
    <head>
    <title>{{title}}</title>
    </head>
    <body>
    {{{content}}}
    </body>
    </html>
    ```

    ## lib/templates/home.html :

    ```html
    <p>Home Page!</p>
    ```

    ## config/manifest.json :

    ```js
    {
    "connections": [
    {
    "port": 51871,
    "host": "localhost"
    }
    ],
    "plugins": {
    "visionary": {
    "engines": { "html": "handlebars" },
    "path": "./lib/templates",
    "layout": true
    },
    "exampleHome": null
    }
    }
    ```

    ## install dependencies
    `npm install --save rejoice handlebars visionary`

    ## package.json for project

    ```js
    {
    "name": "example",
    "version": "0.0.1",
    "description": "POC",
    "main": "index",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node node_modules/rejoice/bin/rejoice -c config/manifest.json"
    },
    "author": "Your Name <you@wherever.com>",
    "license": "ISC",
    "dependencies": {
    "handlebars": "^2.0.0",
    "rejoice": "^2.0.0",
    "visionary": "^2.0.0",
    "exampleHome": "./lib/modules/home"
    }
    }
    ```

    Note: exampleHome is specifying the local directory that contains the plugin, if you do this you need to npm install each time you make changes to it. This could alternatively be a git repository for true modularization of sections, or an npm published module (private or public NPM, whatever makes sense)

    ## starting the server
    `npm start`

    Fire up http://localhost:51871 and see it in action