This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1- If a <base> tag exists, use this as the base path, or the "mount point" by default. | |
| The mount point defaults to '' if the base tag isn't there. | |
| 2- If the user calls page.base, override the mount point extracted in point 1. | |
| 3- Always prepend the mount point. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var hogan = require('hogan.js'); | |
| var t = hogan.compile('{{<super}}{{$title}}sub template title{{/title}}{{/super}}'); | |
| var s = hogan.compile('...{{$title}}Default title{{/title}}...'); | |
| var o = t.render({}, {"super": s}); | |
| console.log(o); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var cfg = require('kr-common').config; | |
| var express = require('express'); | |
| var app = express.createServer(); | |
| var fs = require('fs'); | |
| //Html bundler | |
| app.use(require('./server/htmlBundler')({ | |
| dirs : [ __dirname + '/static/templates', | |
| {path: __dirname + '/static/templates/controls', namespace: 'controls'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mongoose = require('mongoose'); | |
| mongoose.connect("yourServerUrlHere", function(err){ | |
| if(err){ | |
| console.log("Error connecting:",err); | |
| } | |
| else{ | |
| console.log('connected!'); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Small upload form --> | |
| <html><body> | |
| <form action="/upload" | |
| enctype="multipart/form-data" method="post"> | |
| Please specify a file, or a set of files:<br> | |
| <input type="file" name="myfile" size="40"> | |
| </p> | |
| <div> | |
| <input type="submit" value="Send"> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //That's your constructor | |
| var BaseObject = function(eventObj){ | |
| this._ev = $(eventObj || {}); | |
| } | |
| //There it's the inheritance | |
| BaseObject.prototype = Object.create(Object.prototype); | |
| //Put your methods there | |
| BaseObject.prototype.on = function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var proxyServer = require('http-proxy').createServer({ | |
| router: { | |
| "mydomain.com/rest" : "targetMachine:port" | |
| } | |
| }); | |
| proxyServer.listen(myPort); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var app = express() | |
| , http = require('http'); | |
| http.createServer(app).listen(80, '127.0.0.1'); | |
| http.createServer(app).listen(80, '::1'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('when the route matches', function(){ | |
| it('should invoke the callback', function(done){ | |
| page('/user', function(ctx){ | |
| done(); | |
| }) | |
| page.show('/user?test=true'); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var EventEmitter = require('events').EventEmitter; | |
| var querystring = require('querystring'); | |
| /** | |
| * Pre-baked error messages | |
| * | |
| */ | |
| var missingInfo = 'Password authentication - Missing Mandatory authentication' + | |
| ' information. A "login" and "password" must be provided.'; |