diff --git a/public/templates/header.tpl b/public/templates/header.tpl
index 8df622c03f..b46b579ccd 100644
--- a/public/templates/header.tpl
+++ b/public/templates/header.tpl
@@ -47,14 +47,11 @@
-
- Recent
+ Recent
-
Unread
-
-
Users
diff --git a/src/routes/api.js b/src/routes/api.js
new file mode 100644
index 0000000000..2bd750f7b4
--- /dev/null
+++ b/src/routes/api.js
@@ -0,0 +1,150 @@
+var user = require('./../user.js'),
+ auth = require('./authentication.js'),
+ topics = require('./../topics.js'),
+ categories = require('./../categories.js')
+ utils = require('./../../public/src/utils.js'),
+ pkg = require('../../package.json');
+
+
+(function(Api) {
+ Api.create_routes = function(app) {
+ app.get('/api/get_templates_listing', function(req, res) {
+ utils.walk(global.configuration.ROOT_DIRECTORY + '/public/templates', function(err, data) {
+ res.json(data);
+ });
+ });
+
+ app.get('/api/home', function(req, res) {
+ var uid = (req.user) ? req.user.uid : 0;
+ categories.getAllCategories(function(data) {
+
+ function iterator(category, callback) {
+ categories.getRecentReplies(category.cid, 2, function(posts) {
+ category["posts"] = posts;
+ category["post_count"] = posts.length>2 ? 2 : posts.length;
+ callback(null);
+ });
+ }
+
+ require('async').each(data.categories, iterator, function(err) {
+ data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none';
+ data.motd = marked(config.motd || "# NodeBB v" + pkg.version + "\nWelcome to NodeBB, the discussion platform of the future.\n\n Get NodeBB Fork us on Github @dcplabs");
+ res.json(data);
+ });
+
+ }, uid);
+ });
+
+ app.get('/api/login', function(req, res) {
+ var data = {},
+ login_strategies = auth.get_login_strategies(),
+ num_strategies = login_strategies.length;
+
+ if (num_strategies == 0) {
+ data = {
+ 'login_window:spansize': 'span12',
+ 'alternate_logins:display': 'none'
+ };
+ } else {
+ data = {
+ 'login_window:spansize': 'span6',
+ 'alternate_logins:display': 'block'
+ }
+ for (var i=0, ii=num_strategies; i2 ? 2 : posts.length;
- callback(null);
- });
- }
-
- async.each(data.categories, iterator, function(err) {
- data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none';
- data.motd = marked(config.motd || "# NodeBB v" + pkg.version + "\nWelcome to NodeBB, the discussion platform of the future.\n\n Get NodeBB Fork us on Github @dcplabs");
- res.json(data);
- });
-
-
- }, uid);
- break;
- case 'login' :
- var data = {},
- login_strategies = auth.get_login_strategies(),
- num_strategies = login_strategies.length;
-
- if (num_strategies == 0) {
- data = {
- 'login_window:spansize': 'span12',
- 'alternate_logins:display': 'none'
- };
- } else {
- data = {
- 'login_window:spansize': 'span6',
- 'alternate_logins:display': 'block'
- }
- for (var i=0, ii=num_strategies; i