From f3f08a9c94081439a5879b6649ab36734167ae13 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 9 May 2013 03:33:53 +0000 Subject: [PATCH] more fixes to ajaxify, updated /users blocks to sit flush to the left, started work on the ACP including basic templates, added a method to get active users in all rooms (socket connections), added more routes mostly pointing to admin, added a routing folder to start organizing routes better, starting with admin. --- public/css/style.less | 3 +- public/src/ajaxify.js | 6 +- public/src/templates.js | 17 +++-- public/templates/admin/categories.tpl | 75 ++++++++++++++++++ public/templates/admin/facebook.tpl | 13 ++++ public/templates/admin/footer.tpl | 31 ++++++++ public/templates/admin/gplus.tpl | 13 ++++ public/templates/admin/header.tpl | 106 ++++++++++++++++++++++++++ public/templates/admin/index.tpl | 42 ++++++++++ public/templates/admin/settings.tpl | 24 ++++++ public/templates/admin/themes.tpl | 2 + public/templates/admin/topics.tpl | 55 +++++++++++++ public/templates/admin/twitter.tpl | 14 ++++ public/templates/admin/users.tpl | 55 +++++++++++++ public/templates/config.json | 3 + src/routes/admin.js | 62 +++++++++++++++ src/templates.js | 3 +- src/webserver.js | 6 +- src/websockets.js | 5 +- 19 files changed, 521 insertions(+), 14 deletions(-) create mode 100644 public/templates/admin/categories.tpl create mode 100644 public/templates/admin/facebook.tpl create mode 100644 public/templates/admin/footer.tpl create mode 100644 public/templates/admin/gplus.tpl create mode 100644 public/templates/admin/header.tpl create mode 100644 public/templates/admin/index.tpl create mode 100644 public/templates/admin/settings.tpl create mode 100644 public/templates/admin/themes.tpl create mode 100644 public/templates/admin/topics.tpl create mode 100644 public/templates/admin/twitter.tpl create mode 100644 public/templates/admin/users.tpl create mode 100644 src/routes/admin.js diff --git a/public/css/style.less b/public/css/style.less index acf74e59b9..b4a0f13b44 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -405,7 +405,8 @@ footer.footer { .users-box{ display:inline-block; - margin:20px; + margin-right:20px; + margin-top: 20px; text-align:center; } diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 448c17d363..a7db3bb87a 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -34,9 +34,11 @@ var ajaxify = {}; var tpl_url = templates.get_custom_map(url); - if (tpl_url == false) { + if (tpl_url == false && !templates[url]) { tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0]; - } + } else if (templates[url]) { + tpl_url = url; + } if (templates[tpl_url]) { window.history.pushState({}, url, "/" + url); diff --git a/public/src/templates.js b/public/src/templates.js index a0ead8319a..2b9a9d17d0 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -68,7 +68,8 @@ var templates = {}; 'header', 'footer', 'register', 'home', 'topic','account', 'category', 'users', 'accountedit', 'login', 'reset', 'reset_code', 'account', 'confirm', - 'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext' + 'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext', + 'admin/index', 'admin/categories', 'admin/users', 'admin/topics', 'admin/settings', 'admin/themes', 'admin/twitter', 'admin/facebook', 'admin/gplus' ]); } @@ -168,15 +169,15 @@ function load_template(callback, custom_tpl) { jQuery.get(API_URL + url, function(data) { + var tpl = templates.get_custom_map(url); - if (tpl == false) { - tpl = url.split('/')[0]; + + if (tpl == false && !templates[url]) { + tpl = (url === '' || url === '/') ? 'home' : url.split('/')[0]; + } else if (templates[url]) { + tpl = url; } - - if (custom_tpl && custom_tpl != "undefined") - tpl = custom_tpl; - - + document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data)); if (callback) callback(); }); diff --git a/public/templates/admin/categories.tpl b/public/templates/admin/categories.tpl new file mode 100644 index 0000000000..d86bdbad17 --- /dev/null +++ b/public/templates/admin/categories.tpl @@ -0,0 +1,75 @@ + +

Categories

+ +
+ + + + +
+ +
+ + + \ No newline at end of file diff --git a/public/templates/admin/facebook.tpl b/public/templates/admin/facebook.tpl new file mode 100644 index 0000000000..f229fd7231 --- /dev/null +++ b/public/templates/admin/facebook.tpl @@ -0,0 +1,13 @@ +

Facebook Social Authentication

+
+ +
+
+

Create a Facebook Application and then paste your application details here.


+
+
+
+
+ + + \ No newline at end of file diff --git a/public/templates/admin/footer.tpl b/public/templates/admin/footer.tpl new file mode 100644 index 0000000000..7fdd8d9af2 --- /dev/null +++ b/public/templates/admin/footer.tpl @@ -0,0 +1,31 @@ + + + + + + + + + \ No newline at end of file diff --git a/public/templates/admin/gplus.tpl b/public/templates/admin/gplus.tpl new file mode 100644 index 0000000000..343b82cfdd --- /dev/null +++ b/public/templates/admin/gplus.tpl @@ -0,0 +1,13 @@ +

Google Plus Social Authentication

+
+ +
+
+

Create a Google+ Application and then paste your application details here.


+
+
+
+
+ + + \ No newline at end of file diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl new file mode 100644 index 0000000000..edcf59f843 --- /dev/null +++ b/public/templates/admin/header.tpl @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
\ No newline at end of file diff --git a/public/templates/admin/index.tpl b/public/templates/admin/index.tpl new file mode 100644 index 0000000000..8140753570 --- /dev/null +++ b/public/templates/admin/index.tpl @@ -0,0 +1,42 @@ + +
+

Welcome to NodeBB

+
+

+ NodeBB Forum + Get Plugins + Get Themes + dcplabs +

+

You are running NodeBB v0.0.1. This is where we will check to make sure your NodeBB is latest, etc.

+
+ + +
+

Active Users socket connections

+

+ +

+
+ + \ No newline at end of file diff --git a/public/templates/admin/settings.tpl b/public/templates/admin/settings.tpl new file mode 100644 index 0000000000..e128f80de1 --- /dev/null +++ b/public/templates/admin/settings.tpl @@ -0,0 +1,24 @@ +

Settings

+
+ +
+

Privilege Thresholds

+
+

Use privilege thresholds to manage how much reputation a user must gain to receive moderator access.


+ Manage Thread

+ Moderate Users

+ Create Pinned Topics

+ +
+
+ +
+

Email Settings

+
+ Email Address

+
+
+ + + + \ No newline at end of file diff --git a/public/templates/admin/themes.tpl b/public/templates/admin/themes.tpl new file mode 100644 index 0000000000..b6d2e76bde --- /dev/null +++ b/public/templates/admin/themes.tpl @@ -0,0 +1,2 @@ +

Themes

+
diff --git a/public/templates/admin/topics.tpl b/public/templates/admin/topics.tpl new file mode 100644 index 0000000000..3a1e642e50 --- /dev/null +++ b/public/templates/admin/topics.tpl @@ -0,0 +1,55 @@ +

Topics

+
+ + + + + + + \ No newline at end of file diff --git a/public/templates/admin/twitter.tpl b/public/templates/admin/twitter.tpl new file mode 100644 index 0000000000..527e1ba115 --- /dev/null +++ b/public/templates/admin/twitter.tpl @@ -0,0 +1,14 @@ +

Twitter Social Authentication

+
+ +
+
+

Create a Twitter Application and then paste your application details here.


+
+
+
+
+ + + + \ No newline at end of file diff --git a/public/templates/admin/users.tpl b/public/templates/admin/users.tpl new file mode 100644 index 0000000000..4d8df6ca3e --- /dev/null +++ b/public/templates/admin/users.tpl @@ -0,0 +1,55 @@ +

Users

+
+ + + + + + +
+ + + +
+ {users.username} +
+
+ {users.reputation} + +
+
+ {users.postcount} + +
+ +
+ + + + \ No newline at end of file diff --git a/public/templates/config.json b/public/templates/config.json index 8d23609092..01913a0c0d 100644 --- a/public/templates/config.json +++ b/public/templates/config.json @@ -1,5 +1,8 @@ { "custom_mapping": { + "admin/topics[^]*": "admin/topics", + "admin/categories[^]*": "admin/categories", + "admin/users[^]*": "admin/users", "users[^]*edit": "accountedit", "users": "account", "latest": "category", diff --git a/src/routes/admin.js b/src/routes/admin.js new file mode 100644 index 0000000000..d222a2446a --- /dev/null +++ b/src/routes/admin.js @@ -0,0 +1,62 @@ + +(function(Admin) { + Admin.create_routes = function(app) { + + (function() { + var routes = ['categories', 'users', 'topics', 'settings', 'themes', 'twitter', 'facebook', 'gplus']; + + for (var i=0, ii=routes.length; itemplates.ready(function(){ajaxify.go("' + url + '", null, "' + tpl + '");});'; } + app.create_route = create_route; // Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section) @@ -162,6 +164,8 @@ passport.deserializeUser(function(uid, done) { res.send(templates['header'] + '' + templates['footer']); }); + admin.create_routes(app); + // These functions are called via ajax once the initial page is loaded to populate templates with data function api_method(req, res) { diff --git a/src/websockets.js b/src/websockets.js index 9807fbe145..fdfa5c80fc 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -65,7 +65,10 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}), delete users[hs.sessionID]; }); - + socket.on('api:get_all_rooms', function(data) { + console.log('recieve'); + socket.emit('api:get_all_rooms', io.sockets.manager.rooms); + }) socket.on('event:enter_room', function(data) { if (data.leave !== null) socket.leave (data.leave);