Geddy, Assets Addon
I wrote an assets add-on for Geddy. Basically, ithis add-on allows you to modify the header of the page and add scripts, css files or change the title on the fly.
Installation
Step 1
Copy the Assets.js file to your controllers directory .Step 2
Add two lines to the file app/controllers/Application.js.var Assets = require(process.cwd() + '/app/controllers/Assets').Assets;
var Application = function () {
this.Assets = new Assets();
};
exports.Application = Application;
Step 3
Next you need to modify app/views/layouts/application.html.ejs... <title><%= Assets.title(); %></title> ... <script type="text/javascript" src="/js/bootstrap.min.js"></script> <%- Assets.script(); %> ... <link rel="stylesheet" href="/css/bootstrap.responsive.min.css"> <%- Assets.css(); %> ... </div> <%- Assets.preload(); %> </body>
Step 4
Modify the controller you want to add Assets to. app/controllers/myFile.js...
this.login = function (req, resp, params) {
this.Assets.title('Registration Verification | Login');
this.Assets.script(['myscript.js', 'myscript2.js']);
this.Assets.css('mystyles.css');
this.Assets.preload(['img1.jpg', 'img2.jpg']);
this.respond({params: params, Assets: this.Assets});
}
...
* Take special note of the respond line and how I have added the assets to it.
Optionally you can use the load method
this.Assets.load({
title: 'Registration Verification | Login',
script: ['myscript.js', 'myscript2.js'],
css: ['mystyles.css', 'mystyles2.css'],
preload: ['mystyles.jpg', 'mystyles2.jpg']
})
this.respond({params: params, Assets: this.Assets});
Assets.js (unknown, 295 hits)





