diff --git a/README.md b/README.md index 1553785f39..40485cedae 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,10 @@ The server configuration file (located at `/config.js`) contains default options base_url (Default: 'http://localhost') A web-accessible URL to your app, without the port + + upload_path + (Default: '/public/uploads') A relative path (relative to the application's web root) to the uploads folder. Please ensure that Node.js can write to this folder + use_port (Default: true) Whether or not to include the port number when constructing the url for use in NodeBB. If you are serving NodeBB via a proxy (i.e. nginx), switch this off. diff --git a/app.js b/app.js index 0aa624af0e..5f5d16ac8d 100644 --- a/app.js +++ b/app.js @@ -1,41 +1,30 @@ -var modules = { - user: require('./src/user.js'), - topics: require('./src/topics.js'), - posts: require('./src/posts.js'), - categories: require('./src/categories.js'), - templates: require('./src/templates.js'), - webserver: require('./src/webserver.js'), - websockets: require('./src/websockets.js'), - fs: require('fs') - } - - DEVELOPMENT = true; +var categories = require('./src/categories.js'), + templates = require('./src/templates.js'), + webserver = require('./src/webserver.js'), + websockets = require('./src/websockets.js'), + fs = require('fs'); +DEVELOPMENT = true; global.configuration = {}; -global.modules = modules; - (function(config) { config['ROOT_DIRECTORY'] = __dirname; - modules.templates.init(); - modules.websockets.init(); - - + templates.init(); //setup scripts to be moved outside of the app in future. function setup_categories() { console.log('Checking categories...'); - modules.categories.get(function(data) { + categories.get(function(data) { if (data.categories.length === 0) { console.log('Setting up default categories...'); - modules.fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, categories) { + fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, categories) { categories = JSON.parse(categories); for (var category in categories) { - modules.categories.create(categories[category]); + categories.create(categories[category]); } }); diff --git a/config.default.js b/config.default.js index 69c0d7a9c0..e7a662b76b 100644 --- a/config.default.js +++ b/config.default.js @@ -5,11 +5,8 @@ var config = { // "base_url" is expected to be a publically accessible URL to your NodeBB instance (Default base_url: 'http://localhost', port: '4567') "base_url": "http://localhost", - // public url for uploaded files - "upload_url": "http://dev.domain.com/uploads/", - // relative path for uploads - "upload_path": "/uploads/", + "upload_path": "/public/uploads/", "use_port": true, "port": 4567, @@ -54,5 +51,6 @@ var config = { } config.url = config.base_url + (config.use_port ? ':' + config.port : '') + '/'; +config.upload_url = config.base_url + (config.use_port ? ':' + config.port : '') + '/uploads/'; module.exports = config; \ No newline at end of file diff --git a/public/css/style.less b/public/css/style.less index 93719fcd45..8a39505d37 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -245,6 +245,11 @@ footer.footer { line-height: 18px; padding: 5px; padding-left: 10px; + + img.hidden-desktop { + max-width: 10px; + max-height: 10px; + } } .post-content { min-height: 50px; @@ -371,6 +376,7 @@ footer.footer { .user-profile-picture { width:128px; height:128px; + margin-bottom:10px; } .user-8080-picture { diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index e83d16fbf4..b2941529fc 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -21,11 +21,12 @@ var ajaxify = {}; window.onpopstate = function(event) { - // this breaks reloading and results in ajaxify.go calling twice, believe it messes around with sockets. ill come back for you later bitchez - // ajaxify.go(document.location.href.replace(rootUrl +'/', '')); + console.log('popstate called:', event); + if (event !== null && event.state && event.state.url) ajaxify.go(event.state.url, null, null, true); }; - ajaxify.go = function(url, callback, custom_tpl) { + ajaxify.go = function(url, callback, template, quiet) { + // "quiet": If set to true, will not call pushState // leave room and join global app.enter_room('global'); @@ -41,7 +42,11 @@ var ajaxify = {}; } if (templates[tpl_url]) { - window.history.pushState({}, url, "/" + url); + if (quiet !== true) { + window.history.pushState({ + "url": url + }, url, "/" + url); + } jQuery('#footer').fadeOut(100); jQuery('#content').fadeOut(100); @@ -55,7 +60,7 @@ var ajaxify = {}; } jQuery('#content, #footer').fadeIn(200); - }, custom_tpl); + }, url, template); return true; diff --git a/public/src/templates.js b/public/src/templates.js index 95c7f76566..de538645e8 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -160,14 +160,12 @@ var templates = {}; }()); -function load_template(callback, custom_tpl) { +function load_template(callback, url, template) { var location = document.location || window.location, rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : ''); - var url = location.href.replace(rootUrl +'/', ''); url = (url === '' || url === '/') ? 'home' : url; - jQuery.get(API_URL + url, function(data) { var tpl = templates.get_custom_map(url); diff --git a/public/templates/account.tpl b/public/templates/account.tpl index 5b870e6c59..58c4cad975 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -6,48 +6,47 @@

- - +
- {user.username} - edit + {username} + edit
- +
email - {user.email} + {email}
full name - {user.fullname} + {fullname}
website - {user.website} + {website}
location - {user.location} + {location}
age - {user.age} + {age}
member for - {user.joindate} + {joindate}
reputation - {user.reputation} + {reputation}
posts - {user.postcount} + {postcount}
diff --git a/public/templates/accountedit.tpl b/public/templates/accountedit.tpl index 2b327d8eab..a61c081a67 100644 --- a/public/templates/accountedit.tpl +++ b/public/templates/accountedit.tpl @@ -6,7 +6,6 @@

- - +
Uploaded picture @@ -64,81 +63,76 @@
- - -
- {user.username} - edit + {username} + edit
-
-
- change picture -
- - -
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- - - - - -
-
- - -
{user.picture}
-
{user.gravatarpicture}
-
{user.uploadedpicture}
- - - - +
+
+ +
+ +
+
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + + + +
+
+
+
+ \ No newline at end of file diff --git a/src/routes/admin.js b/src/routes/admin.js index d222a2446a..aeabfc6d48 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -1,4 +1,7 @@ +var user = require('./../user.js'), + topics = require('./../topics.js'); + (function(Admin) { Admin.create_routes = function(app) { @@ -29,7 +32,7 @@ if (req.params.tab == 'search') { res.send(JSON.stringify({search_display: 'block', users: []})) } else { - global.modules.user.getUserList(function(data){ + user.getUserList(function(data){ res.send(JSON.stringify({search_display: 'none', users:data})); }); } @@ -39,13 +42,13 @@ if (req.params.tab == 'disabled') { res.send(JSON.stringify({categories: []})); } else { - global.modules.categories.get(function(data) { + categories.get(function(data) { res.send(JSON.stringify(data)); }); } break; case 'topics' : - global.modules.topics.get(function(data) { + topics.get(function(data) { res.send(JSON.stringify(data)); }); break; diff --git a/src/routes/authentication.js b/src/routes/authentication.js index e6d8a93cfe..e9c17d29ea 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -138,9 +138,8 @@ })); app.post('/register', function(req, res) { - console.log('wtf'); user_module.create(req.body.username, req.body.password, req.body.email, function(err, uid) { - if (err === null) { + if (err === null && uid > 0) { req.login({ uid: uid }, function() { diff --git a/src/routes/user.js b/src/routes/user.js new file mode 100644 index 0000000000..06c9613777 --- /dev/null +++ b/src/routes/user.js @@ -0,0 +1,95 @@ + + +var user = require('./../user.js'); + + +(function(User) { + User.create_routes = function(app) { + + + app.get('/uid/:uid', function(req, res) { + + if(!req.params.uid) + return res.redirect('/403'); + + user.getUserData(req.params.uid, function(data){ + if(data) + res.send(data); + else + res.send("User doesn't exist!"); + }); + + }); + + app.get('/users', function(req, res) { + + user.getUserList(function(data) { + + res.send(templates['header'] + app.create_route("users", "users") + templates['footer']); + + }); + + }); + + app.get('/users/:username*', function(req, res) { + if(!req.params.username) { + res.send("User doesn't exist!"); + return; + } + + user.get_uid_by_username(req.params.username, function(uid) { + + if(!uid) { + res.redirect('/403'); + return; + } + + user.getUserData(uid, function(data) { + if(data) { + res.send(templates['header'] + app.create_route('users/'+data.username, 'account') + templates['footer']); + } + else { + res.redirect('/403'); + } + }); + }); + }); + +/* + function api_method(req, res) { + switch(req.params.method) { + case 'users' : + if (req.params.tab == 'search') { + res.send(JSON.stringify({search_display: 'block', users: []})) + } else { + user.getUserList(function(data){ + res.send(JSON.stringify({search_display: 'none', users:data})); + }); + } + + break; + case 'categories': + if (req.params.tab == 'disabled') { + res.send(JSON.stringify({categories: []})); + } else { + categories.get(function(data) { + res.send(JSON.stringify(data)); + }); + } + break; + case 'topics' : + topics.get(function(data) { + res.send(JSON.stringify(data)); + }); + break; + default : + res.send('{}'); + } + } + + app.get('/api/admin/:method/:tab?*', api_method); + app.get('/api/admin/:method*', api_method);*/ + }; + + +}(exports)); \ No newline at end of file diff --git a/src/templates.js b/src/templates.js index 4fc25a72b1..b9b97571c9 100644 --- a/src/templates.js +++ b/src/templates.js @@ -1,3 +1,6 @@ +var fs = require('fs'); + + // to be deprecated in favour of client-side only templates. (function(Templates) { @@ -7,7 +10,7 @@ function loadTemplates(templatesToLoad) { for (var t in templatesToLoad) { (function(file) { - modules.fs.readFile(global.configuration.ROOT_DIRECTORY + '/public/templates/' + file + '.tpl', function(err, html) { + fs.readFile(global.configuration.ROOT_DIRECTORY + '/public/templates/' + file + '.tpl', function(err, html) { var template = function() { this.toString = function() { return this.html; diff --git a/src/user.js b/src/user.js index a557e97a80..5a2cc51cb7 100644 --- a/src/user.js +++ b/src/user.js @@ -1,4 +1,6 @@ -var config = require('../config.js'), + + +var config = require('../config.js'), utils = require('./utils.js'), RDB = require('./redis.js'), crypto = require('crypto'), @@ -76,8 +78,14 @@ var config = require('../config.js'), for(var i=0,ii=fields.length; i