mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
Merge branch 'master' into edit_delete
This commit is contained in:
@@ -42,9 +42,12 @@ The server configuration file (located at `/config.js`) contains default options
|
||||
<td><b>base_url</b></td>
|
||||
<td><i>(Default: 'http://localhost')</i> A web-accessible URL to your app, without the port</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>use_port</b></td>
|
||||
<td><i>(Default: true)</i> 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.
|
||||
<tr>
|
||||
<td><b>port</b></td>
|
||||
<td><i>(Default: 4567)</i> The default port that NodeBB runs on</td>
|
||||
<td><i>(Default: 4567)</i> The default port that NodeBB runs on. Even if you are running NodeBB behind a proxy server, this port must be set.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>mailer</b></td>
|
||||
|
||||
@@ -4,6 +4,7 @@ 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",
|
||||
"use_port": true,
|
||||
"port": 4567,
|
||||
|
||||
// The host and port to the SMTP server used by NodeBB. The "from" value must be changed.
|
||||
@@ -40,10 +41,11 @@ var config = {
|
||||
|
||||
// Privileged Actions Reputation Thresholds
|
||||
"privilege_thresholds": {
|
||||
"manage_thread": 1000
|
||||
"manage_thread": 1000,
|
||||
"manage_content": 2000
|
||||
}
|
||||
}
|
||||
|
||||
config.url = config.base_url + ':' + config.port + '/';
|
||||
config.url = config.base_url + (config.use_port ? ':' + config.port : '') + '/';
|
||||
|
||||
module.exports = config;
|
||||
@@ -270,6 +270,8 @@ footer.footer {
|
||||
margin-right: 8px;
|
||||
margin-top: -2px;
|
||||
float: left;
|
||||
width:24px;
|
||||
height:24px;
|
||||
}
|
||||
|
||||
span {
|
||||
@@ -348,6 +350,20 @@ footer.footer {
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
.user-profile-picture {
|
||||
width:128px;
|
||||
height:128px;
|
||||
}
|
||||
|
||||
.user-header-profile-picture {
|
||||
width:24px;
|
||||
height:24px;
|
||||
}
|
||||
|
||||
.user-picture-label {
|
||||
font-size:20px;
|
||||
}
|
||||
|
||||
.account-bio-block{
|
||||
display:inline-block;
|
||||
vertical-align:top;
|
||||
|
||||
1174
public/src/jquery.form.js
Normal file
1174
public/src/jquery.form.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
|
||||
<div class="account-picture-block">
|
||||
<img src="{user.picture}?s=128" />
|
||||
<img src="{user.picture}?s=128" class="user-profile-picture"/>
|
||||
</div>
|
||||
|
||||
<div class="account-bio-block">
|
||||
|
||||
@@ -1,11 +1,65 @@
|
||||
|
||||
<div class="well">
|
||||
|
||||
<div class="alert" id="message" style="display:none">
|
||||
<button type="button" class="close" data-dismiss="message">×</button>
|
||||
<strong></strong>
|
||||
<p></p>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Change Picture Modal -->
|
||||
<div id="change-picture-modal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">Change Picture</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div id="gravatar-box">
|
||||
<img id="user-gravatar-picture" src="" class="img-polaroid user-profile-picture">
|
||||
<span class="user-picture-label">Gravatar</span>
|
||||
<i class='icon-ok'></i>
|
||||
</div>
|
||||
|
||||
<div id="uploaded-box">
|
||||
<img id="user-uploaded-picture" src="" class="img-polaroid user-profile-picture">
|
||||
<span class="user-picture-label">Uploaded picture</span>
|
||||
<i class='icon-ok'></i>
|
||||
</div>
|
||||
|
||||
<a id="uploadPictureBtn" href="#">Upload new picture</a>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
<button id="savePictureChangesBtn" class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Upload picture modal-->
|
||||
<div id="upload-picture-modal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">Upload Picture</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form id="uploadForm" action="/pictureupload" method="post" enctype="multipart/form-data">
|
||||
<input id="userPhotoInput" type="file" name="userPhoto" >
|
||||
</form>
|
||||
|
||||
<span id="status" />
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
<button id="pictureUploadSubmitBtn" class="btn btn-primary">Upload Picture</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- BEGIN user -->
|
||||
|
||||
<div class="account-username-box">
|
||||
@@ -13,10 +67,9 @@
|
||||
<span class="pull-right"><a href="/users/{user.username}/edit">edit</a></span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="account-picture-block">
|
||||
<img src="{user.picture}?s=128" />
|
||||
<div class="account-picture-block text-center">
|
||||
<img id="user-current-picture" class="user-profile-picture" src="{user.picture}" /><br/>
|
||||
<a id="changePictureBtn" href="#">change picture</a>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -66,17 +119,64 @@
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- how to pass data to the script ?? -->
|
||||
<div id="user-data-picture" class="hide">{user.picture}</div>
|
||||
<div id="user-data-gravatarpicture" class="hide">{user.gravatarpicture}</div>
|
||||
<div id="user-data-uploadedpicture" class="hide">{user.uploadedpicture}</div>
|
||||
|
||||
|
||||
<!-- END user -->
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#uploadForm').submit(function() {
|
||||
status('uploading the file ...');
|
||||
|
||||
$(this).ajaxSubmit({
|
||||
|
||||
error: function(xhr) {
|
||||
status('Error: ' + xhr.status);
|
||||
},
|
||||
|
||||
success: function(response) {
|
||||
if(response.error) {
|
||||
status('Opps, something bad happened');
|
||||
return;
|
||||
}
|
||||
|
||||
var imageUrlOnServer = response.path;
|
||||
|
||||
$('#user-current-picture').attr('src', imageUrlOnServer);
|
||||
$('#user-uploaded-picture').attr('src', imageUrlOnServer);
|
||||
|
||||
$('#user-data-uploadedpicture').html(imageUrlOnServer);
|
||||
|
||||
$('#upload-picture-modal').modal('hide');
|
||||
|
||||
socket.emit('api:updateHeader', { fields: ['username', 'picture'] });
|
||||
status('');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
function status(message) {
|
||||
$('#status').text(message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
(function() {
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#submitBtn').on('click',function(){
|
||||
|
||||
function submitUserData() {
|
||||
var userData = {
|
||||
uid:$('#inputUID').val(),
|
||||
email:$('#inputEmail').val(),
|
||||
@@ -92,7 +192,112 @@
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function changeUserPicture(type) {
|
||||
var userData = {
|
||||
uid: $('#inputUID').val(),
|
||||
type: type
|
||||
};
|
||||
|
||||
$.post('/changeuserpicture',
|
||||
userData,
|
||||
function(data) {
|
||||
socket.emit('api:updateHeader', { fields: ['username', 'picture'] });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var selectedImageType = '';
|
||||
|
||||
$('#submitBtn').on('click',function(){
|
||||
|
||||
submitUserData();
|
||||
|
||||
});
|
||||
|
||||
|
||||
function updateImages() {
|
||||
|
||||
var currentPicture = $('#user-current-picture').attr('src');
|
||||
var gravatarPicture = $('#user-data-gravatarpicture').html();
|
||||
var uploadedPicture = $('#user-data-uploadedpicture').html();
|
||||
|
||||
if(gravatarPicture)
|
||||
$('#user-gravatar-picture').attr('src', gravatarPicture);
|
||||
else
|
||||
$('#user-gravatar-picture').addClass('hide');
|
||||
|
||||
if(uploadedPicture)
|
||||
$('#user-uploaded-picture').attr('src', uploadedPicture);
|
||||
else
|
||||
$('#user-uploaded-picture').addClass('hide');
|
||||
|
||||
|
||||
if(currentPicture == gravatarPicture)
|
||||
$('#gravatar-box .icon-ok').show();
|
||||
else
|
||||
$('#gravatar-box .icon-ok').hide();
|
||||
|
||||
if(currentPicture == uploadedPicture)
|
||||
$('#uploaded-box .icon-ok').show();
|
||||
else
|
||||
$('#uploaded-box .icon-ok').hide();
|
||||
}
|
||||
|
||||
|
||||
$('#changePictureBtn').on('click', function() {
|
||||
selectedImageType = '';
|
||||
updateImages();
|
||||
|
||||
$('#change-picture-modal').modal('show');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#gravatar-box').on('click', function(){
|
||||
$('#gravatar-box .icon-ok').show();
|
||||
$('#uploaded-box .icon-ok').hide();
|
||||
selectedImageType = 'gravatar';
|
||||
});
|
||||
|
||||
$('#uploaded-box').on('click', function(){
|
||||
$('#gravatar-box .icon-ok').hide();
|
||||
$('#uploaded-box .icon-ok').show();
|
||||
selectedImageType = 'uploaded';
|
||||
});
|
||||
|
||||
$('#savePictureChangesBtn').on('click', function() {
|
||||
$('#change-picture-modal').modal('hide');
|
||||
|
||||
if(selectedImageType) {
|
||||
changeUserPicture(selectedImageType);
|
||||
|
||||
if(selectedImageType == 'gravatar')
|
||||
$('#user-current-picture').attr('src', $('#user-data-gravatarpicture').html());
|
||||
else if(selectedImageType == 'uploaded')
|
||||
$('#user-current-picture').attr('src', $('#user-data-uploadedpicture').html());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#upload-picture-modal').on('hide', function() {
|
||||
$('#userPhotoInput').val('');
|
||||
});
|
||||
|
||||
$('#uploadPictureBtn').on('click', function(){
|
||||
|
||||
$('#change-picture-modal').modal('hide');
|
||||
$('#upload-picture-modal').modal('show');
|
||||
|
||||
$('#pictureUploadSubmitBtn').on('click', function() {
|
||||
$('#uploadForm').submit();
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -46,24 +46,28 @@
|
||||
|
||||
socket.emit('api:updateHeader', { fields: ['username', 'picture'] });
|
||||
|
||||
socket.once('api:updateHeader', function(data) {
|
||||
|
||||
socket.on('api:updateHeader', function(data) {
|
||||
if (data.uid > 0) {
|
||||
var gravatar = document.createElement('img'),
|
||||
name = document.createElement('span')
|
||||
logoutEl = document.createElement('li');
|
||||
|
||||
right_menu.innerHTML = '';
|
||||
|
||||
logoutEl.innerHTML = '<a href="/logout">Log out</a>';
|
||||
|
||||
name.innerHTML = data['username'];
|
||||
gravatar.src = data['picture']+"?s=24";
|
||||
|
||||
var userLink = $('<a id="user_label" href="/users/'+data['username']+'"></a>');
|
||||
|
||||
$('#user_label').attr('href','/users/'+data['username']);
|
||||
userLink.append(gravatar);
|
||||
userLink.append(name);
|
||||
|
||||
user_label.innerHTML = '';
|
||||
user_label.appendChild(gravatar);
|
||||
user_label.appendChild(name);
|
||||
var userLi = $('<li></li>');
|
||||
userLi.append(userLink);
|
||||
|
||||
$(right_menu).append(userLi);
|
||||
right_menu.appendChild(logoutEl);
|
||||
} else {
|
||||
var registerEl = document.createElement('li'),
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
<script type="text/javascript" src="/src/app.js"></script>
|
||||
<script type="text/javascript" src="/src/templates.js"></script>
|
||||
<script type="text/javascript" src="/src/ajaxify.js"></script>
|
||||
<script type="text/javascript" src="/src/jquery.form.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/css/style.css" />
|
||||
</head>
|
||||
|
||||
@@ -39,7 +41,7 @@
|
||||
</ul>
|
||||
<ul class="nav pull-right" id="right-menu">
|
||||
<!--<li><i class="icon-plus icon-2x" style="color:#999;"></i></li> fail. add this back later -->
|
||||
<li><a href="/users" id="user_label"></a></li>
|
||||
<!--<li><a href="/users" id="user_label"></a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<p>Welcome to NodeBB, the discussion platform of the future.</p>
|
||||
<p>
|
||||
<a target="_blank" href="http://www.nodebb.org" class="btn btn-large"><i class="icon-comment"></i> Get NodeBB</a>
|
||||
<a target="_blank" href="http://www.nodebb.org" class="btn btn-large"><i class="icon-github-alt"></i> Fork us on Github</a>
|
||||
<a target="_blank" href="http://www.nodebb.org" class="btn btn-large"><i class="icon-twitter"></i> dcplabs</a>
|
||||
<a target="_blank" href="https://github.com/psychobunny/NodeBB" class="btn btn-large"><i class="icon-github-alt"></i> Fork us on Github</a>
|
||||
<a target="_blank" href="https://twitter.com/dcplabs" class="btn btn-large"><i class="icon-twitter"></i> @dcplabs</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@ var RDB = require('./redis.js'),
|
||||
topics = require('./topics.js'),
|
||||
config = require('../config.js');
|
||||
|
||||
marked.setOptions({
|
||||
breaks: true
|
||||
});
|
||||
|
||||
(function(Posts) {
|
||||
|
||||
Posts.get = function(callback, tid, current_user, start, end) {
|
||||
@@ -36,7 +40,7 @@ var RDB = require('./redis.js'),
|
||||
'user_rep' : user_data[uid].reputation || 0,
|
||||
'gravatar' : user_data[uid].picture,
|
||||
'fav_star_class' : vote_data[pid] ? 'icon-star' : 'icon-star-empty',
|
||||
'display_moderator_tools' : uid == current_user ? 'show' : 'none',
|
||||
'display_moderator_tools': (uid == current_user || viewer_data.reputation >= config.privilege_thresholds.manage_content) ? 'show' : 'none',
|
||||
'edited-class': post_data.editor[i] !== null ? '' : 'none',
|
||||
'editor': post_data.editor[i] !== null ? user_data[post_data.editor[i]].username : '',
|
||||
'relativeEditTime': post_data.editTime !== null ? utils.relativeTime(post_data.editTime[i]) : ''
|
||||
|
||||
@@ -36,7 +36,6 @@ var config = require('../config.js'),
|
||||
|
||||
// a function I feel should be built in user not sure how baris is tackling this so oppa chicken wrapper here
|
||||
User.getMultipleUserFields = function(uids, fields, callback) {
|
||||
console.log(uids);
|
||||
var uuids = uids.filter(function(value, index, self) {
|
||||
return self.indexOf(value) === index;
|
||||
});
|
||||
@@ -253,6 +252,8 @@ var config = require('../config.js'),
|
||||
|
||||
User.hashPassword(password, function(hash) {
|
||||
|
||||
var gravatar = User.createGravatarURLFromEmail(email);
|
||||
|
||||
RDB.hmset('user:'+uid, {
|
||||
'username' : username,
|
||||
'fullname': '',
|
||||
@@ -262,7 +263,9 @@ var config = require('../config.js'),
|
||||
'email' : email,
|
||||
'joindate' : new Date().getTime(),
|
||||
'password' : hash,
|
||||
'picture' : User.createGravatarURLFromEmail(email),
|
||||
'picture': gravatar,
|
||||
'gravatarpicture' : gravatar,
|
||||
'uploadedpicture': '',
|
||||
'reputation': 0,
|
||||
'postcount': 0
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ var express = require('express'),
|
||||
|
||||
user = require('./user.js'),
|
||||
utils = require('./utils.js'),
|
||||
fs = require('fs'),
|
||||
admin = require('./routes/admin.js'),
|
||||
auth = require('./routes/authentication.js');
|
||||
|
||||
@@ -199,6 +200,82 @@ var express = require('express'),
|
||||
|
||||
// TODO move user related logic into another file vvvvvvvvvvvvvvvvvvvv
|
||||
|
||||
app.post('/pictureupload', function(req, res) {
|
||||
|
||||
if(!req.user)
|
||||
return res.redirect('/403');
|
||||
|
||||
user.getUserField(req.user.uid, 'uploadedpicture', function(uploadedpicture) {
|
||||
|
||||
var index = uploadedpicture.lastIndexOf('/');
|
||||
var filename = uploadedpicture.substr(index+1);
|
||||
|
||||
var absolutePath = global.configuration['ROOT_DIRECTORY'] + config.upload_path + filename;
|
||||
|
||||
fs.unlink(absolutePath, function(err) {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
uploadUserPicture(req.user.uid, req.files.userPhoto.name, req.files.userPhoto.path, res);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function uploadUserPicture(uid, filename, tempPath, res) {
|
||||
var uploadPath = config['upload_path'] + uid + '-' + filename;
|
||||
|
||||
fs.rename(
|
||||
tempPath,
|
||||
global.configuration['ROOT_DIRECTORY']+ uploadPath,
|
||||
function(error) {
|
||||
if(error) {
|
||||
res.send({
|
||||
error: 'Ah crap! Something bad happened'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var imageUrl = config.base_url + config.install_path + uploadPath;
|
||||
|
||||
res.send({
|
||||
path: imageUrl
|
||||
});
|
||||
|
||||
user.setUserField(uid, 'uploadedpicture', imageUrl);
|
||||
user.setUserField(uid, 'picture', imageUrl);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
app.post('/changeuserpicture', function(req, res){
|
||||
if(!req.user)
|
||||
return res.redirect('/403');
|
||||
|
||||
if(req.user.uid != req.body.uid)
|
||||
return res.redirect('/');
|
||||
|
||||
var type = req.body.type;
|
||||
if(type == 'gravatar') {
|
||||
user.getUserField(req.user.uid, 'gravatarpicture', function(gravatar){
|
||||
user.setUserField(req.user.uid, 'picture', gravatar);
|
||||
});
|
||||
}
|
||||
else if(type == 'uploaded') {
|
||||
user.getUserField(req.user.uid, 'uploadedpicture', function(uploadedpicture){
|
||||
user.setUserField(req.user.uid, 'picture', uploadedpicture);
|
||||
});
|
||||
}
|
||||
res.send({});
|
||||
});
|
||||
|
||||
|
||||
app.post('/edituser', function(req, res){
|
||||
|
||||
if(!req.user)
|
||||
|
||||
Reference in New Issue
Block a user