Permalink
Browse files

Adding support for Dictum comments and css styles to go along with it

  • Loading branch information...
1 parent 963a296 commit 1568a7673f02461bef91f19a9e166b7d82320bec @distracteddev committed Jul 26, 2012
Showing with 445 additions and 121 deletions.
  1. +4 −1 .gitignore
  2. +128 −30 app.js
  3. +3 −6 package.json
  4. BIN public/.DS_Store
  5. +24 −3 public/app.js
  6. +30 −3 public/index.html
  7. +96 −3 public/sass/app.scss
  8. +160 −75 public/stylesheets/app.css
View
@@ -1,2 +1,5 @@
node_modules
-public/.sass_cache
+public/.sass_cache/
+.DS_store
+soapbox.session
+.livereload
View
158 app.js
@@ -3,22 +3,28 @@
// appName: 'Soapbox'
// });
+process.env.SS_DIRECTORY = '/dictum';
var flatiron = require('flatiron'),
connect = require('connect'),
resourceful = require('resourceful'),
path = require('path'),
director = require('director'),
+ http = require('http'),
+ httpProxy = require('http-proxy'),
fs = require('fs'),
//qs = require('querystring'),
passport = require('passport'),
- User = require('./models').User();
+ User = require('./models').User(),
LocalStrategy = require('passport-local').Strategy,
- render = require('./no_script'),
+ render = require('./no_script'),
app = flatiron.app;
var routes = require('./routes');
var animalRoutes = require('./routes/animals.js')
+var proxy = new httpProxy.RoutingProxy();
+
+
function findByUsername(username, done) {
User.find({"username":username}, function(err, user) {
@@ -34,6 +40,10 @@ function findByUsername(username, done) {
});
}
+
+
+
+
passport.use(new LocalStrategy(
function(username, password, done) {
// asynchronous verification, for effect...
@@ -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, {
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) {
if (req.headers['user-agent'].indexOf('Google') > -1 || req.query.no_script === 'true') {
console.log(req.url, req.query, req.headers['user-agent']);
@@ -85,7 +130,7 @@ app.use(flatiron.plugins.http, {
connect.static(__dirname + '/public'),
connect.favicon('./public/favicon.ico'),
connect.cookieParser('lolcats'),
- connect.session({secret: "9ajk21mas8"}),
+ // connect.session({secret: "lolcats"}),
connect.methodOverride(),
passport.initialize(),
passport.session()
@@ -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 () {
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;
- 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 union = require('union');
+ console.log(union.RoutingStream.prototype.serveClient);
+ union.RoutingStream.prototype.serveClient.call(self.res, 'main');
});
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;
- 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 union = require('union');
+ console.log(union.RoutingStream.prototype.serveClient);
+ union.RoutingStream.prototype.serveClient.call(self.res, 'main');
});
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;
- 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 union = require('union');
+ console.log(union.RoutingStream.prototype.serveClient);
+ union.RoutingStream.prototype.serveClient.call(self.res, 'main');
});
this.get('portfolio/:name', function(name) {
@@ -199,6 +273,27 @@ app.router.path('/services/blog_posts/:id', function() {
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() {
this.get(routes.getSettings);
this.post(routes.postSettings);
@@ -218,6 +313,9 @@ var port = process.env.PORT = process.env.PORT || 9000;
app.start(port);
app.log.info("Started at http://localhost:" + port + "/");
+ss.start(app.server)
+
+// console.log(app.router)
/// Remote REPL ///
// var net = require("net"),
View
@@ -27,14 +27,11 @@
},
"name": "soapbox",
"engines": {
- "node": "0.6.19",
- "npm": "1.1.9"
+ "node": "0.8.3",
+ "npm": "1.1.43"
},
- "subdomain": "zeus",
"domains": [
- "distracteddeveloper.com",
- "www.distracteddeveloper.com",
"distracteddev.com",
"www.distracteddev.com"
]
-}
+}
View
Binary file not shown.
View
@@ -325,11 +325,20 @@ App.PostController = Ember.ArrayController.create({
}
return this.get('postPreview');
}.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')
+
+});
/*
@@ -368,7 +377,8 @@ App.postView = Em.View.create({
App.selectedPostView = Em.View.create({
templateName: "single-post",
- selectedPostBinding: "App.PostController.selectedPost"
+ selectedPostBinding: "App.PostController.selectedPost",
+ commentsBinding: "App.CommentsController.selectedComments"
});
App.PostButton = Em.Button.extend({
@@ -540,6 +550,13 @@ var bindLinks = function() {
$("#blog-nav").slideUp();
});
+ require('./app').bindSubmit();
+
+ var t = setTimeout(function() {
+ require('./app').getAll();
+ }, 500)
+
+
});
}
@@ -552,6 +569,10 @@ var updateNav = function(loc) {
});
}
+window.insertComments = function() {
+
+}
+
App.routeManager = Ember.RouteManager.create({
enableLogging: true,
@@ -617,7 +638,7 @@ App.routeManager = Ember.RouteManager.create({
//App.layout.set('header', App.portfolioHeaderView);
updateNav(this.route);
//App.layout.set('content', App.selectedPostView);
- bindLinks();
+ // bindLinks();
//setTimeout(function() {
//$("#content").fadeIn();
//}, 500);
Oops, something went wrong.

0 comments on commit 1568a76

Please sign in to comment.