コード例 #1
0
ファイル: app.js プロジェクト: johndrinkwater/pump.io
        app.configure(function() {

            // Templates are in public
            app.set("views", __dirname + "/../public/template");
            app.set("view engine", "utml");
            app.use(requestLogger(log));
            app.use(rawBody);
            app.use(express.bodyParser());
            app.use(express.cookieParser());
            app.use(express.query());
            app.use(express.methodOverride());
            app.use(express.favicon());

            app.provider = new Provider(log);

            app.use(function(req, res, next) { 
                res.local("config", config);
                res.local("data", {});
                res.local("page", {});
                res.local("template", {});
                // Initialize null
                res.local("principalUser", null);
                res.local("principal", null);
                res.local("user", null);
                res.local("client", null);
                res.local("nologin", false);
                next();
            });

            app.use(auth([auth.Oauth({name: "client",
                                      realm: "OAuth",
                                      oauth_provider: app.provider,
                                      oauth_protocol: (useHTTPS) ? 'https' : 'http',
                                      authenticate_provider: null,
                                      authorize_provider: null,
                                      authorization_finished_provider: null
                                     }),
                          auth.Oauth({name: "user",
                                      realm: "OAuth",
                                      oauth_provider: app.provider,
                                      oauth_protocol: (useHTTPS) ? 'https' : 'http',
                                      authenticate_provider: oauth.authenticate,
                                      authorize_provider: oauth.authorize,
                                      authorization_finished_provider: oauth.authorizationFinished
                                     })
                         ]));

            app.use(express["static"](__dirname + "/../public"));

            app.use(app.router);

        });
コード例 #2
0
ファイル: app.js プロジェクト: julien-c/activitypump
        app.configure(function() {

            // Templates are in public
            app.set("views", __dirname + "/../public/template");
            app.set("view engine", "utml");
            if (!_(config).has("nologger") || !config.nologger) {
                app.use(express.logger());
            }
            app.use(express.bodyParser());
            app.use(express.cookieParser());
            app.use(express.query());
            app.use(express.methodOverride());
            app.use(express.session({secret: (config.secret || "activitypump")}));
            app.use(express.favicon());

            var provider = new Provider();

            app.use(function(req, res, next) { 
                res.local("site", (config.site) ? config.site : "ActivityPump");
                res.local("owner", (config.owner) ? config.owner : "Anonymous");
                res.local("ownerurl", (config.ownerURL) ? config.ownerURL : false);
                // Initialize null
                res.local("remoteUser", null);
                res.local("user", null);
                res.local("client", null);
                res.local("nologin", false);
                next();
            });

            app.use(auth([auth.Oauth({name: "client",
                                      oauth_provider: provider,
                                      oauth_protocol: (useHTTPS) ? 'https' : 'http',
                                      authenticate_provider: null,
                                      authorize_provider: null,
                                      authorization_finished_provider: null
                                     }),
                          auth.Oauth({name: "user",
                                      oauth_provider: provider,
                                      oauth_protocol: (useHTTPS) ? 'https' : 'http',
                                      authenticate_provider: oauth.authenticate,
                                      authorize_provider: oauth.authorize,
                                      authorization_finished_provider: oauth.authorizationFinished
                                     })
                         ]));

            app.use(app.router);

            app.use(express["static"](__dirname + "/../public"));

        });
コード例 #3
0
ファイル: app.js プロジェクト: e14n/activityspam
 app.configure(function() {
     app.set('views', __dirname + '/views');
     app.set('view engine', 'utml');
     app.use(requestLogger);
     app.use(auth([auth.Oauth({oauth_provider: new Provider(),
                               oauth_protocol: (useHTTPS) ? 'https' : 'http',
                               authenticate_provider: null,
                               authorize_provider: null,
                               authorization_finished_provider: null
                              })]));
     app.use(express.methodOverride());
     app.use(express.bodyParser());
     app.use(function(req, res, next) { 
         res.local('site', (config.site) ? config.site : "ActivitySpam");
         res.local('owner', (config.owner) ? config.owner : "Anonymous");
         res.local('ownerurl', (config.ownerURL) ? config.ownerURL : false);
         next();
     });
     app.use(app.router);
     app.use(express.static(__dirname + '/public'));
 });
コード例 #4
0
ファイル: app.js プロジェクト: ryanj/pump.io
        app.configure(function() {

            var serverVersion = 'pump.io/'+version + ' express/'+express.version + ' node.js/'+process.version,
                versionStamp = function(req, res, next) {
                    res.setHeader('Server', serverVersion);
                    next();
                },
                canonicalHost = function(req, res, next) {
                    var host = req.header('Host'),
                        urlHost,
                        addressHost;

                    if (!config.redirectToCanonical || !host) {
                        next();
                        return;
                    }

                    urlHost = URLMaker.makeHost();

                    if (host == urlHost) {
                        next();
                        return;
                    }

                    if (!config.redirectAddressToCanonical) {

                        addressHost = URLMaker.makeHost(address, port);

                        if (host == addressHost) {
                            next();
                            return;
                        }
                    }

                    res.redirect(URLMaker.makeURL(req.url), 301);
                };

            // Templates are in public
            app.set("views", __dirname + "/../public/template");
            app.set("view engine", "utml");

            app.use(requestLogger(log));

            if (config.redirectToCanonical) {
                app.use(canonicalHost);
            }

            app.use(rawBody);

            app.use(express.bodyParser());
            app.use(express.cookieParser());
            app.use(express.query());
            app.use(express.methodOverride());
            app.use(express.favicon());

            if (config.compress) {
                app.use(express.compress());
            }

            app.use(versionStamp);

            app.provider = new Provider(log);

            app.use(function(req, res, next) {
                res.local("config", config);
                res.local("data", {});
                res.local("page", {url: req.originalUrl});
                res.local("template", {});
                // Initialize null
                res.local("principalUser", null);
                res.local("principal", null);
                res.local("user", null);
                res.local("client", null);
                res.local("nologin", false);
                res.local("version", version);
                res.local("messages", {items: []});
                res.local("notifications", {items: []});
                next();
            });

            app.use(auth([auth.Oauth({name: "client",
                                      realm: "OAuth",
                                      oauth_provider: app.provider,
                                      oauth_protocol: (useHTTPS) ? 'https' : 'http',
                                      authenticate_provider: null,
                                      authorize_provider: null,
                                      authorization_finished_provider: null
                                     }),
                          auth.Oauth({name: "user",
                                      realm: "OAuth",
                                      oauth_provider: app.provider,
                                      oauth_protocol: (useHTTPS) ? 'https' : 'http',
                                      authenticate_provider: oauth.authenticate,
                                      authorize_provider: oauth.authorize,
                                      authorization_finished_provider: oauth.authorizationFinished
                                     })
                         ]));

            app.use(express["static"](__dirname + "/../public"));

            app.use(app.router);

        });
コード例 #5
0
ファイル: app.js プロジェクト: deuxpi/pump.io
        app.configure(function() {

            var serverVersion = "pump.io/"+version + " express/"+express.version + " node.js/"+process.version,
                versionStamp = function(req, res, next) {
                    res.setHeader("Server", serverVersion);
                    next();
                },
                canonicalHost = function(req, res, next) {
                    var host = req.header("Host"),
                        urlHost,
                        addressHost;

                    if (!config.redirectToCanonical || !host) {
                        next();
                        return;
                    }

                    urlHost = URLMaker.makeHost();

                    if (host == urlHost) {
                        next();
                        return;
                    }

                    if (!config.redirectAddressToCanonical) {

                        addressHost = URLMaker.makeHost(address, port);

                        if (host == addressHost) {
                            next();
                            return;
                        }
                    }

                    res.redirect(URLMaker.makeURL(req.url), 301);
                };

            // Templates are in public
            app.set("views", path.resolve(__dirname, "../public/template"));
            app.set("view engine", "utml");

            app.use(requestLogger(log));

            if (config.redirectToCanonical) {
                app.use(canonicalHost);
            }

            app.use(rawBody);

            app.use(express.bodyParser());
            app.use(express.cookieParser());
            app.use(express.query());
            app.use(express.methodOverride());

            // ^ INPUTTY
            // v OUTPUTTY

            if (config.compress) {
                app.use(express.compress());
            }

            app.use(versionStamp);

            app.use(express["static"](path.resolve(__dirname, "../public")));

            // Default is in public/images/favicon.ico
            // Can be overridden by a config setting

            app.use(express.favicon(config.favicon));

            app.provider = new Provider(log, config.clients);

            // Initialize scripts

            _.each(config.plugins, function(pluginName) {
                var script;
                if (_.isFunction(plugins[pluginName].getScript)) {
                    script = plugins[pluginName].getScript();
                    log.debug({plugin: pluginName, script: script}, "Adding script");
                    config.scripts.push(script);
                }
            });

            // defangs interpolated data objects

            var defang = function(obj) {
                var dup = _.clone(obj);
                _.each(dup, function(value, name) {
                    if (name == "displayName" && _.isString(value)) {
                        dup[name] = validator.escape(value);
                    } else if (_.isFunction(value)) {
                        delete dup[name];
                    } else if (_.isObject(value)) {
                        dup[name] = defang(value);
                    }
                });
                return dup;
            };

            app.use(function(req, res, next) {
                res.local("config", config);
                res.local("data", {});
                res.local("page", {url: req.originalUrl});
                res.local("template", {});
                // Initialize null
                res.local("principalUser", null);
                res.local("principal", null);
                res.local("user", null);
                res.local("client", null);
                res.local("nologin", false);
                res.local("version", version);
                res.local("messages", {items: []});
                res.local("notifications", {items: []});
                res.local("defang", defang);
                next();
            });

            app.use(auth([auth.Oauth({name: "client",
                                      realm: "OAuth",
                                      oauth_provider: app.provider,
                                      oauth_protocol: (useHTTPS) ? "https" : "http",
                                      authenticate_provider: null,
                                      authorize_provider: null,
                                      authorization_finished_provider: null
                                     }),
                          auth.Oauth({name: "user",
                                      realm: "OAuth",
                                      oauth_provider: app.provider,
                                      oauth_protocol: (useHTTPS) ? "https" : "http",
                                      authenticate_provider: oauth.authenticate,
                                      authorize_provider: oauth.authorize,
                                      authorization_finished_provider: oauth.authorizationFinished
                                     })
                         ]));

            app.use(app.router);

        });