diff options
| author | HumairAK <humair88@hotmail.com> | 2016-07-25 03:29:23 +0000 |
|---|---|---|
| committer | HumairAK <humair88@hotmail.com> | 2016-07-25 03:29:23 +0000 |
| commit | 7c222d2418ba44bd4f2f9ffd844f97f43974029a (patch) | |
| tree | a8282098bea1a18312fda510d8f635f3dd97eee1 /node_modules/express-messages | |
| parent | fc3cc6aee7ce7a28539d332902c0f9923d298c71 (diff) | |
| parent | 3ca0e78b313a1bded021cbb8b2dad241d7cad049 (diff) | |
fixed conflict
Diffstat (limited to 'node_modules/express-messages')
| -rw-r--r-- | node_modules/express-messages/.npmignore | 1 | ||||
| -rw-r--r-- | node_modules/express-messages/History.md | 10 | ||||
| -rw-r--r-- | node_modules/express-messages/Readme.md | 142 | ||||
| -rw-r--r-- | node_modules/express-messages/index.js | 43 | ||||
| -rw-r--r-- | node_modules/express-messages/package.json | 66 |
5 files changed, 262 insertions, 0 deletions
diff --git a/node_modules/express-messages/.npmignore b/node_modules/express-messages/.npmignore new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/node_modules/express-messages/.npmignore @@ -0,0 +1 @@ +test diff --git a/node_modules/express-messages/History.md b/node_modules/express-messages/History.md new file mode 100644 index 0000000..edf8e07 --- /dev/null +++ b/node_modules/express-messages/History.md @@ -0,0 +1,10 @@ + +0.0.2 / 2011-04-25 +================== + + * Fixed clobbering of length var [reported by MIB] + +0.0.1 / 2010-09-06 +================== + + * Initial release diff --git a/node_modules/express-messages/Readme.md b/node_modules/express-messages/Readme.md new file mode 100644 index 0000000..30d7ce7 --- /dev/null +++ b/node_modules/express-messages/Readme.md @@ -0,0 +1,142 @@ +# Express Messages + +The _express-messages_ module provides flash notification rendering. + +## Installation + + $ npm install express-messages + +## Usage + +### Express 2.x + +To use simply assign it to a dynamic helper: + + app.dynamicHelpers({ messages: require('express-messages') }); + +### Express 3+ + +Install [connect-flash](https://github.com/jaredhanson/connect-flash) and add them as middleware: + +``` +app.use(require('connect-flash')()); +app.use(function (req, res, next) { + res.locals.messages = require('express-messages')(req, res); + next(); +}); +``` + +### Adding Messages + +On the server: + + req.flash("info", "Email queued"); + req.flash("info", "Email sent"); + req.flash("error", "Email delivery failed"); + +For further information see [connect-flash](https://github.com/jaredhanson/connect-flash). + +### Rendering Messages + +Call the `messages()` function as specified by your rendering engine: + +[EJS](https://github.com/visionmedia/ejs): + + <%- messages() %> + +[Jade](http://jade-lang.com/): + + != messages() + +Which will output the HTML: + + <div id="messages"> + <ul class="info"> + <li>Email queued</li> + <li>Email sent</li> + </ul> + <ul class="error"> + <li>Email delivery failed</li> + </ul> + </div> + +## Using a custom template + +Alternatively you can specify a custom template (a file in the views directory of your [Express](http://expressjs.com) app). + +### Add a message template + +For example, lets use the below custom message template named `my_message_template`. + +[EJS](https://github.com/visionmedia/ejs) (`my_message_template.ejs`): + + <div id="messages"> + <% Object.keys(messages).forEach(function (type) { %> + <ul class="<%= type %>"> + <% messages[type].forEach(function (message) { %> + <li><%= message %></li> + <% }) %> + </ul> + <% }) %> + </div> + +[Jade](http://jade-lang.com/) (`my_message_template.jade`): + + .messages + each type in Object.keys(messages) + ul(class="#{type}") + each message in messages[type] + li= message + +### Call the message template + +Next, pass the template name, `my_message_template`, as a parameter to the `messages()` function. + +[EJS](https://github.com/visionmedia/ejs): + + <%- messages('my_message_template', locals) %> + +[Jade](http://jade-lang.com/): + + != messages('my_message_template', locals) + +The message template will receive an object called `messages` of the form: + + { + "info" : [ + "Email queued", + "Email sent" + ], + "error": [ + "Email delivery failed" + ] + } + +## Running Tests + + $ npm test + +## License + +(The MIT License) + +Copyright (c) 2010 TJ Holowaychuk <tj@vision-media.ca> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/express-messages/index.js b/node_modules/express-messages/index.js new file mode 100644 index 0000000..099ffa3 --- /dev/null +++ b/node_modules/express-messages/index.js @@ -0,0 +1,43 @@ + +/*! + * Express - Contrib - messages + * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca> + * MIT Licensed + */ + +module.exports = function (req, res) { + return function (template, locals) { + var flash = req.flash() + , types = Object.keys(flash) + , output = ''; + + if (types.length) { + if (template) { + locals = locals || {}; + locals.messages = flash; + res.render(template, locals, function (err, html) { + if (html) { + output = html; + } + }); + } else { + var buf = []; + buf.push('<div id="messages">'); + types.forEach(function (type) { + var msgs = flash[type]; + if (msgs) { + buf.push(' <ul class="' + type + '">'); + msgs.forEach(function (msg) { + buf.push(' <li>' + msg + '</li>'); + }); + buf.push(' </ul>'); + } + }); + buf.push('</div>'); + output = buf.join('\n'); + } + } + + return output; + }; +}; diff --git a/node_modules/express-messages/package.json b/node_modules/express-messages/package.json new file mode 100644 index 0000000..019eb11 --- /dev/null +++ b/node_modules/express-messages/package.json @@ -0,0 +1,66 @@ +{ + "name": "express-messages", + "description": "Express flash notification message rendering", + "version": "1.0.1", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "keywords": [ + "express" + ], + "main": "index.js", + "devDependencies": { + "connect-flash": "^0.1.1", + "ejs": "^2.3.1", + "express": "^4.13.0", + "express-session": "^1.11.3", + "supertest": "^1.0.1", + "tap-spec": "^4.0.2", + "tape": "^4.0.0" + }, + "engines": { + "node": ">= 0.10.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/express-messages.git" + }, + "scripts": { + "test": "tape test/messages.js | node_modules/.bin/tap-spec" + }, + "gitHead": "d1db1cbe95eb32917d5062796b99e9ea9f123ca8", + "bugs": { + "url": "https://github.com/expressjs/express-messages/issues" + }, + "homepage": "https://github.com/expressjs/express-messages#readme", + "_id": "express-messages@1.0.1", + "_shasum": "9981a85a5d2b118c79fc33f52b41834ffee9685a", + "_from": "express-messages@latest", + "_npmVersion": "3.8.3", + "_nodeVersion": "5.10.1", + "_npmUser": { + "name": "artcommacode", + "email": "ryan@graphicalhouse.com" + }, + "dist": { + "shasum": "9981a85a5d2b118c79fc33f52b41834ffee9685a", + "tarball": "https://registry.npmjs.org/express-messages/-/express-messages-1.0.1.tgz" + }, + "maintainers": [ + { + "name": "artcommacode", + "email": "ryan@graphicalhouse.com" + }, + { + "name": "tjholowaychuk", + "email": "tj@vision-media.ca" + } + ], + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/express-messages-1.0.1.tgz_1461573258084_0.4463885903824121" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/express-messages/-/express-messages-1.0.1.tgz" +} |
