Skip to content

Commit

Permalink
Adding support for Dictum comments and css styles to go along with it
Browse files Browse the repository at this point in the history
  • Loading branch information
distracteddev committed Jul 26, 2012
1 parent 963a296 commit 1568a76
Show file tree
Hide file tree
Showing 8 changed files with 445 additions and 121 deletions.
5 changes: 4 additions & 1 deletion .gitignore
@@ -1,2 +1,5 @@
node_modules node_modules
public/.sass_cache public/.sass_cache/
.DS_store
soapbox.session
.livereload
158 changes: 128 additions & 30 deletions app.js
Expand Up @@ -3,22 +3,28 @@
// appName: 'Soapbox' // appName: 'Soapbox'
// }); // });


process.env.SS_DIRECTORY = '/dictum';


var flatiron = require('flatiron'), var flatiron = require('flatiron'),
connect = require('connect'), connect = require('connect'),
resourceful = require('resourceful'), resourceful = require('resourceful'),
path = require('path'), path = require('path'),
director = require('director'), director = require('director'),
http = require('http'),
httpProxy = require('http-proxy'),
fs = require('fs'), fs = require('fs'),
//qs = require('querystring'), //qs = require('querystring'),
passport = require('passport'), passport = require('passport'),
User = require('./models').User(); User = require('./models').User(),
LocalStrategy = require('passport-local').Strategy, LocalStrategy = require('passport-local').Strategy,
render = require('./no_script'), render = require('./no_script'),
app = flatiron.app; app = flatiron.app;


var routes = require('./routes'); var routes = require('./routes');
var animalRoutes = require('./routes/animals.js') var animalRoutes = require('./routes/animals.js')
var proxy = new httpProxy.RoutingProxy();




function findByUsername(username, done) { function findByUsername(username, done) {
User.find({"username":username}, function(err, user) { User.find({"username":username}, function(err, user) {
Expand All @@ -34,6 +40,10 @@ function findByUsername(username, done) {
}); });
} }






passport.use(new LocalStrategy( passport.use(new LocalStrategy(
function(username, password, done) { function(username, password, done) {
// asynchronous verification, for effect... // asynchronous verification, for effect...
Expand Down Expand Up @@ -67,8 +77,43 @@ passport.deserializeUser(function(username, done) {
}); });
}); });



eventMiddleware = function(req, res, next) {
var initialDir;
initialDir = req.url.split('/')[1];
if (initialDir === '_serveDev') {
req.url = transformURL(req.url);
}
if (staticDirs.indexOf(initialDir) >= 0 || !router.route(req.url, req, res)) {
return next();
}
};

transformURL = function(url) {
var i, x, _i;
i = 0;
for (x = _i = 0; _i <= 1; x = ++_i) {
i = url.indexOf('/', i + 1);
}
if (url[i] === '/') {
url = url.replace('?', '&');
url = url.substr(0, i) + '?' + url.substr(i + 1);
}
return url;
};


app.use(flatiron.plugins.http, { app.use(flatiron.plugins.http, {
before: [ before: [
function(req, res) {
var initialDir;
initialDir = req.url.split('/')[1];
if (initialDir === '_serveDev') {
req.url = transformURL(req.url);
console.log("TRANSFORMED: ", req.url);
}
res.emit('next');
},
function(req, res) { function(req, res) {
if (req.headers['user-agent'].indexOf('Google') > -1 || req.query.no_script === 'true') { if (req.headers['user-agent'].indexOf('Google') > -1 || req.query.no_script === 'true') {
console.log(req.url, req.query, req.headers['user-agent']); console.log(req.url, req.query, req.headers['user-agent']);
Expand All @@ -85,7 +130,7 @@ app.use(flatiron.plugins.http, {
connect.static(__dirname + '/public'), connect.static(__dirname + '/public'),
connect.favicon('./public/favicon.ico'), connect.favicon('./public/favicon.ico'),
connect.cookieParser('lolcats'), connect.cookieParser('lolcats'),
connect.session({secret: "9ajk21mas8"}), // connect.session({secret: "lolcats"}),
connect.methodOverride(), connect.methodOverride(),
passport.initialize(), passport.initialize(),
passport.session() passport.session()
Expand All @@ -95,44 +140,73 @@ app.use(flatiron.plugins.http, {
}); });




process.SS_ROUTER = app.router;
// console.log(process.SS_ROUTER);
ss = require('socketstream'),

ss.client.templateEngine.use(require('ss-hogan'));
ss.client.formatters.add(require('ss-coffee'));
ss.client.formatters.add(require('ss-stylus'));
// ss.client.packAssets();

ss.client.define('main', {
view: 'index.html',
css: [],
code: ['app'],
// tmpl: '*'
});


app.router.path('/', function () { app.router.path('/', function () {
this.get(function () { this.get(function () {
// var self = this;
// fs.readFile('index.html', function(err, data) {
// if(err) {
// self.res.writeHead(404, {'Content-Type': 'text/html'});
// self.res.end("404");
// return;
// }
// self.res.writeHead(200, {'Content-Type': 'text/html'});
// self.res.end(data);
// });
var self = this; var self = this;
fs.readFile('index.html', function(err, data) { var union = require('union');
if(err) { console.log(union.RoutingStream.prototype.serveClient);
self.res.writeHead(404, {'Content-Type': 'text/html'}); union.RoutingStream.prototype.serveClient.call(self.res, 'main');
self.res.end("404");
return;
}
self.res.writeHead(200, {'Content-Type': 'text/html'});
self.res.end(data);
});
}); });


this.get('/:name', function(name) { this.get('/:name', function(name) {
// var self = this;
// fs.readFile('public/index.html', function(err, data) {
// if(err) {
// self.res.writeHead(404, {'Content-Type': 'text/html'});
// self.res.end(__dirname + " 404:\n" + JSON.stringify(err));
// return;
// }
// self.res.writeHead(200, {'Content-Type': 'text/html'});
// self.res.end(data);
// });
var self = this; var self = this;
fs.readFile('public/index.html', function(err, data) { var union = require('union');
if(err) { console.log(union.RoutingStream.prototype.serveClient);
self.res.writeHead(404, {'Content-Type': 'text/html'}); union.RoutingStream.prototype.serveClient.call(self.res, 'main');
self.res.end(__dirname + " 404:\n" + JSON.stringify(err));
return;
}
self.res.writeHead(200, {'Content-Type': 'text/html'});
self.res.end(data);
});
}); });


this.get('blog/:name', function(name) { this.get('blog/:name', function(name) {
// var self = this;
// fs.readFile('public/index.html', function(err, data) {
// if(err) {
// self.res.writeHead(404, {'Content-Type': 'text/html'});
// self.res.end(__dirname + " 404:\n" + JSON.stringify(err));
// return;
// }
// self.res.writeHead(200, {'Content-Type': 'text/html'});
// self.res.end(data);
// });
var self = this; var self = this;
fs.readFile('public/index.html', function(err, data) { var union = require('union');
if(err) { console.log(union.RoutingStream.prototype.serveClient);
self.res.writeHead(404, {'Content-Type': 'text/html'}); union.RoutingStream.prototype.serveClient.call(self.res, 'main');
self.res.end(__dirname + " 404:\n" + JSON.stringify(err));
return;
}
self.res.writeHead(200, {'Content-Type': 'text/html'});
self.res.end(data);
});
}); });


this.get('portfolio/:name', function(name) { this.get('portfolio/:name', function(name) {
Expand Down Expand Up @@ -199,6 +273,27 @@ app.router.path('/services/blog_posts/:id', function() {
this.delete(routes.deleteBP); this.delete(routes.deleteBP);
}); });


app.router.path('/services/comments', function() {
this.get(function() {
var self = this;
var union = require('union');
console.log(union.RoutingStream.prototype.serveClient);
union.RoutingStream.prototype.serveClient.call(self.res, 'main');
});
});


// app.router.path('/(\\w+)', function() {
// this.get(function() {
// var self = this;
// proxy.proxyRequest(self.req, self.res, {
// host: 'localhost',
// port: '3000'
// });
// self.req.end("Hello");
// });
// });

app.router.path('/services/blog_settings', function() { app.router.path('/services/blog_settings', function() {
this.get(routes.getSettings); this.get(routes.getSettings);
this.post(routes.postSettings); this.post(routes.postSettings);
Expand All @@ -218,6 +313,9 @@ var port = process.env.PORT = process.env.PORT || 9000;
app.start(port); app.start(port);
app.log.info("Started at http://localhost:" + port + "/"); app.log.info("Started at http://localhost:" + port + "/");


ss.start(app.server)

// console.log(app.router)


/// Remote REPL /// /// Remote REPL ///
// var net = require("net"), // var net = require("net"),
Expand Down
9 changes: 3 additions & 6 deletions package.json
Expand Up @@ -27,14 +27,11 @@
}, },
"name": "soapbox", "name": "soapbox",
"engines": { "engines": {
"node": "0.6.19", "node": "0.8.3",
"npm": "1.1.9" "npm": "1.1.43"
}, },
"subdomain": "zeus",
"domains": [ "domains": [
"distracteddeveloper.com",
"www.distracteddeveloper.com",
"distracteddev.com", "distracteddev.com",
"www.distracteddev.com" "www.distracteddev.com"
] ]
} }
Binary file modified public/.DS_Store
Binary file not shown.
27 changes: 24 additions & 3 deletions public/app.js
Expand Up @@ -325,11 +325,20 @@ App.PostController = Ember.ArrayController.create({
} }
return this.get('postPreview'); return this.get('postPreview');
}.observes('selectedPost.body_raw') }.observes('selectedPost.body_raw')
});




App.CommentsController = Ember.ArrayController.create({


comments: [],


});
selectedComments: function(post_id) {
post_id = App.PostController.get('selectedPost').get('_id');
return post_id;
}.property('selectedIndex','content.@each')

});




/* /*
Expand Down Expand Up @@ -368,7 +377,8 @@ App.postView = Em.View.create({


App.selectedPostView = Em.View.create({ App.selectedPostView = Em.View.create({
templateName: "single-post", templateName: "single-post",
selectedPostBinding: "App.PostController.selectedPost" selectedPostBinding: "App.PostController.selectedPost",
commentsBinding: "App.CommentsController.selectedComments"
}); });


App.PostButton = Em.Button.extend({ App.PostButton = Em.Button.extend({
Expand Down Expand Up @@ -540,6 +550,13 @@ var bindLinks = function() {
$("#blog-nav").slideUp(); $("#blog-nav").slideUp();
}); });


require('./app').bindSubmit();

var t = setTimeout(function() {
require('./app').getAll();
}, 500)


}); });
} }


Expand All @@ -552,6 +569,10 @@ var updateNav = function(loc) {
}); });
} }


window.insertComments = function() {

}

App.routeManager = Ember.RouteManager.create({ App.routeManager = Ember.RouteManager.create({


enableLogging: true, enableLogging: true,
Expand Down Expand Up @@ -617,7 +638,7 @@ App.routeManager = Ember.RouteManager.create({
//App.layout.set('header', App.portfolioHeaderView); //App.layout.set('header', App.portfolioHeaderView);
updateNav(this.route); updateNav(this.route);
//App.layout.set('content', App.selectedPostView); //App.layout.set('content', App.selectedPostView);
bindLinks(); // bindLinks();
//setTimeout(function() { //setTimeout(function() {
//$("#content").fadeIn(); //$("#content").fadeIn();
//}, 500); //}, 500);
Expand Down

0 comments on commit 1568a76

Please sign in to comment.