Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

made the external configuration work

  • Loading branch information...
commit 54cfe6baabd885cb8b63b7091186ca2158febc22 1 parent a80b3f6
@jettro authored
View
7 app.js
@@ -2,14 +2,19 @@ function App() {
}
var chat;
+var properties = require('./properties');
+
+
App.prototype.start = function(chat) {
var pub = __dirname + '/public';
var express = require('express')
, app = express.createServer()
- , site = require('./site')
, blog = require('./blog');
+ var site = require('./site');
+ site.init(properties);
+
app.configure(function() {
app.set('view engine', 'jade');
app.set('views', __dirname + '/views');
View
6 config/template-config.json
@@ -0,0 +1,6 @@
+{
+ "consumer" : {
+ "key":"YOUR KEY",
+ "secret":"YOUR SECRET"
+ }
+}
View
17 properties.js
@@ -0,0 +1,17 @@
+// Based on: https://github.com/theteam/node-properties/blob/master/lib/properties.js
+var fs = require('fs');
+
+var properties_file = process.cwd() + '/config/config.json';
+var properties = {};
+
+try {
+ properties = JSON.parse(fs.readFileSync(properties_file, 'utf8'));
+} catch (err){
+ console.log(err);
+}
+
+for (attrname in properties) {
+ properties[attrname] = properties[attrname];
+}
+
+module.exports = properties;
View
22 site.js
@@ -1,8 +1,17 @@
-var consumer_key = "gD4vivMJ2QxeECPr50CGA";
-var consumer_secret = "E2090oHPThSwdVSPDyMfvhFW6styfDRtA9qCDZwle4";
+var consumer_key
+var consumer_secret
+
+exports.init = function(properties) {
+ consumer_key = properties.consumer.key;
+ consumer_secret = properties.consumer.secret;
+};
exports.index = function(req, res) {
- res.render('index', {locals: {login:'login to this app'}});
+ var loginName = "login to this app";
+ if (req.session.oauth) {
+ loginName = req.session.user.name;
+ }
+ res.render('index', {locals: {loginName:loginName}});
};
exports.authenticated = function(req, res, next) {
@@ -13,12 +22,13 @@ exports.authenticated = function(req, res, next) {
oa.getOAuthAccessToken(oauth.token, oauth.token_secret, oauth.verifier,
function(error, oauth_access_token, oauth_access_token_secret, results) {
if (error) new Error(error);
- console.log(results.screen_name)
+ req.session.user = {name:results.screen_name};
+ res.redirect("/");
}
);
- } else
+ } else {
next(new Error('No OAuth information stored in the session. How did you get here?'));
- res.render('index');
+ }
};
exports.authenticate = function(req, res) {
View
5 views/layout.jade
@@ -8,10 +8,11 @@ html(lang="en")
div#header
img(src="/images/logo.png")
div#login
- span login
+ span
+ a(href="/authenticate") #{loginName}
div
h1 Gridshore
- p A weblog about software engineering, Architecture, Technology an other things we like.
+ p A weblog about software engineering, Architecture, Technology and other things we like.
div#navigation
ul
li
Please sign in to comment.
Something went wrong with that request. Please try again.