Skip to content

Commit

Permalink
separating into modules
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdburn committed Dec 17, 2014
1 parent d979a99 commit c1ec07a
Showing 6 changed files with 141 additions and 90 deletions.
32 changes: 0 additions & 32 deletions app.js

This file was deleted.

87 changes: 87 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
var swig = require('swig');

swig.setFilter('format_tag', function(input, id) {
return input[id];
});

swig.setFilter('format_date', function(input, id) {
return '2014-11-10';
});

swig.setFilter('format_tag', function(input, id) {
return 'tag';
});

module.exports = function(type) {

var global = {
assets: function(location) {
return '/assets/' + location;
},
static: function(location) {
return 'http://postach.io/static/' + location;
},
set_active: function(location) {
return 'active';
},
header_meta: '',
footer_meta: '',
login_form: '',
is_login: false,
is_home: false,
is_tag: false,
site: {
avatar: '',
author: '',
name: '',
analytics: false,
cover_photo: '',
facebook: '',
twitter: '',
googleplus: '',
linkedin: '',
atom_url: '',
disqus: '',
base_url: '/'
},
post: {
title: ''
},
posts: [{
permalink: '',
title: '',
content: '',
created_at: '',
type: 'post',
url: '',
tags: ['tag-one', 'another-tag', 'content']
}],
tag: {
name: ''
},
page: {
permalink: '',
title: ''
},
pages: [{
_id: '',
permalink: '',
title: '',
content: ''
}],
pagination: {
prev: '',
next: ''
}
};

var data = {
page: global,
post: global,
tag: global,
home: global
}

return data[type];

};
42 changes: 0 additions & 42 deletions gulpfile.js

This file was deleted.

26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var express = require('express');
var app = express();
var swig = require('swig');
var http = require('http');
var url = require('url');
var cons = require('consolidate');
var path = require('path');
var bootstrap = require('./routes');

// set swig as templating engine
app.use('/assets', express.static(__dirname + '/../assets'));
app.engine('html', cons.swig);
app.set('view engine', 'html');
app.set('views', __dirname + '/../');

// make routes, add content, etc.
bootstrap(app);

// create server
var server = app.listen(8000, function() {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});

module.exports = server;
16 changes: 0 additions & 16 deletions package.json

This file was deleted.

28 changes: 28 additions & 0 deletions routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var content = require('./content');

module.exports = function(app) {

app.route('/')
.get(function(req, res) {
res.render('index', content('home'));
});

app.route('/:slug')
.get(function(req, res){
console.log('Called post route.');
res.render('index', content('post'));
});

app.route('/tag/:tag')
.get(function(req, res){
console.log('Called /tag/ route.');
res.render('index', content('tag'));
});

app.route('/page/:slug')
.get(function(req, res){
console.log('Called /page/ route.');
res.render('index', content('page'));
});

};

0 comments on commit c1ec07a

Please sign in to comment.