mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 04:21:17 +01:00
Merge branch 'master' of https://github.com/psychobunny/NodeBB
This commit is contained in:
@@ -33,6 +33,8 @@ var socket,
|
||||
|
||||
// use unique alert_id to have multiple alerts visible at a time, use the same alert_id to fade out the current instance
|
||||
// type : error, success, info, warning/notify
|
||||
// title = bolded title text
|
||||
// message = alert message content
|
||||
// timeout default = permanent
|
||||
// location : notification_window (default) or content
|
||||
app.alert = function(params) {
|
||||
@@ -41,7 +43,7 @@ var socket,
|
||||
strong = document.createElement('strong'),
|
||||
p = document.createElement('p');
|
||||
|
||||
var alert_id = 'alert_button_' + ((alert_id) ? alert_id : new Date().getTime());
|
||||
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
|
||||
|
||||
jQuery('#'+alert_id).fadeOut(500, function() {
|
||||
this.remove();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<div class="account-username-box">
|
||||
<span class="account-username">{user.username}</span>
|
||||
<span class="account-links">edit</span>
|
||||
<span class="pull-right"><a href="/users/{user.username}/edit">edit</a></span>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
@@ -35,13 +35,7 @@
|
||||
<span>{user.postcount}</span>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
<label for="email">Email Address</label><input type="text" placeholder="Enter Email Address" id="email" /><br />
|
||||
<button class="btn btn-primary" id="reset" type="submit">Reset Password</button>
|
||||
|
||||
|
||||
26
public/templates/accountedit.tpl
Normal file
26
public/templates/accountedit.tpl
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
<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>
|
||||
|
||||
<!-- BEGIN user -->
|
||||
|
||||
|
||||
|
||||
<label for="email">Email Address</label><input type="text" placeholder="Enter Email Address" id="email" /><br />
|
||||
<button class="btn btn-primary" id="reset" type="submit">Reset Password</button>
|
||||
|
||||
|
||||
<!-- END user -->
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
// ...
|
||||
}());
|
||||
</script>
|
||||
@@ -10,7 +10,7 @@
|
||||
<ul class="topic-container">
|
||||
<!-- BEGIN topics -->
|
||||
<a href="../../topic/{topics.slug}"><li class="topic-row">
|
||||
<h4><i class="{topics.icon}"></i> {topics.title}</h4>
|
||||
<h4><i class="{topics.pin-icon}"></i><i class="{topics.lock-icon}"></i> {topics.title}</h4>
|
||||
<p>Posted {topics.relativeTime} ago by <span class="username">{topics.username}</span>. {topics.post_count} posts.</p>
|
||||
</li></a>
|
||||
<!-- END topics -->
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
gravatar.src = data['picture']+"?s=24";
|
||||
|
||||
|
||||
$('#user_label').attr('href','/users/'+data.uid);
|
||||
$('#user_label').attr('href','/users/'+data['username']);
|
||||
|
||||
user_label.innerHTML = '';
|
||||
user_label.appendChild(gravatar);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<div class="post-block">
|
||||
<div id="content_{posts.pid}" class="post-content">{posts.content}</div>
|
||||
<div class="profile-block">
|
||||
<img class="hidden-desktop" src="{posts.gravatar}10" align="left" /> posted by <strong><a href="/users/{posts.uid}">{posts.username}</a></strong> {posts.relativeTime} ago
|
||||
<img class="hidden-desktop" src="{posts.gravatar}10" align="left" /> posted by <strong><a href="/users/{posts.username}">{posts.username}</a></strong> {posts.relativeTime} ago
|
||||
<span class="post-buttons">
|
||||
<div id="ids_{posts.pid}_{posts.uid}" class="edit {posts.display_moderator_tools} hidden-phone"><i class="icon-pencil"></i></div>
|
||||
<div id="ids_{posts.pid}_{posts.uid}" class="delete {posts.display_moderator_tools} hidden-phone"><i class="icon-trash"></i></div>
|
||||
@@ -38,6 +38,7 @@
|
||||
<div class="btn-group pull-right" id="thread-tools" style="visibility: hidden;">
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">Thread Tools <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" id="pin_thread"><i class="icon-pushpin"></i> Pin Thread</a></li>
|
||||
<li><a href="#" id="lock_thread"><i class="icon-lock"></i> Lock Thread</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#" id="delete_thread"><span class="text-error"><i class="icon-trash"></i> Delete Thread</span></a></li>
|
||||
@@ -51,7 +52,8 @@
|
||||
tid = '{topic_id}',
|
||||
thread_state = {
|
||||
locked: '{locked}',
|
||||
deleted: '{deleted}'
|
||||
deleted: '{deleted}',
|
||||
pinned: '{pinned}'
|
||||
};
|
||||
|
||||
jQuery('document').ready(function() {
|
||||
@@ -63,10 +65,12 @@
|
||||
|
||||
if (thread_state.locked === '1') set_locked_state(true);
|
||||
if (thread_state.deleted === '1') set_delete_state(true);
|
||||
if (thread_state.pinned === '1') set_pinned_state(true);
|
||||
|
||||
if (expose_tools === '1') {
|
||||
var deleteThreadEl = document.getElementById('delete_thread'),
|
||||
lockThreadEl = document.getElementById('lock_thread');
|
||||
lockThreadEl = document.getElementById('lock_thread'),
|
||||
pinThreadEl = document.getElementById('pin_thread');
|
||||
|
||||
adminTools.style.visibility = 'inherit';
|
||||
|
||||
@@ -87,13 +91,18 @@
|
||||
lockThreadEl.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
if (thread_state.locked !== '1') {
|
||||
if (confirm('really lock thread? (THIS DIALOG TO BE REPLACED WITH BOOTBOX)')) {
|
||||
socket.emit('api:topic.lock', { tid: tid });
|
||||
}
|
||||
socket.emit('api:topic.lock', { tid: tid });
|
||||
} else {
|
||||
if (confirm('really unlock thread? (THIS DIALOG TO BE REPLACED WITH BOOTBOX)')) {
|
||||
socket.emit('api:topic.unlock', { tid: tid });
|
||||
}
|
||||
socket.emit('api:topic.unlock', { tid: tid });
|
||||
}
|
||||
});
|
||||
|
||||
pinThreadEl.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
if (thread_state.pinned !== '1') {
|
||||
socket.emit('api:topic.pin', { tid: tid });
|
||||
} else {
|
||||
socket.emit('api:topic.unpin', { tid: tid });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -107,7 +116,7 @@
|
||||
usercount = usernames.length;
|
||||
|
||||
for (var i = 0, ii=usercount; i<ii; i++) {
|
||||
usernames[i] = '<strong>' + '<a href="/users/'+users.uids[i]+'">' + usernames[i] + '</a></strong>';
|
||||
usernames[i] = '<strong>' + '<a href="/users/'+usernames[i]+'">' + usernames[i] + '</a></strong>';
|
||||
}
|
||||
|
||||
// headexplosion.gif for fun, to see if I could do this in one line of code. feel free to refactor haha
|
||||
@@ -154,13 +163,25 @@
|
||||
|
||||
socket.on('event:topic_locked', function(data) {
|
||||
if (data.tid === tid && data.status === 'ok') {
|
||||
set_locked_state(true);
|
||||
set_locked_state(true, 1);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:topic_unlocked', function(data) {
|
||||
if (data.tid === tid && data.status === 'ok') {
|
||||
set_locked_state(false);
|
||||
set_locked_state(false, 1);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:topic_pinned', function(data) {
|
||||
if (data.tid === tid && data.status === 'ok') {
|
||||
set_pinned_state(true, 1);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:topic_unpinned', function(data) {
|
||||
if (data.tid === tid && data.status === 'ok') {
|
||||
set_pinned_state(false, 1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -220,7 +241,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
function set_locked_state(locked) {
|
||||
function set_locked_state(locked, alert) {
|
||||
var threadReplyBtn = document.getElementById('post_reply'),
|
||||
postReplyBtns = document.querySelectorAll('#post-container .post_reply'),
|
||||
quoteBtns = document.querySelectorAll('#post-container .quote'),
|
||||
@@ -229,6 +250,7 @@
|
||||
numReplyBtns = postReplyBtns.length,
|
||||
lockThreadEl = document.getElementById('lock_thread'),
|
||||
x;
|
||||
|
||||
if (locked === true) {
|
||||
lockThreadEl.innerHTML = '<i class="icon-unlock"></i> Unlock Thread';
|
||||
threadReplyBtn.disabled = true;
|
||||
@@ -240,6 +262,16 @@
|
||||
deleteBtns[x].style.display = 'none';
|
||||
}
|
||||
|
||||
if (alert) {
|
||||
app.alert({
|
||||
'alert_id': 'thread_lock',
|
||||
type: 'success',
|
||||
title: 'Thread Locked',
|
||||
message: 'Thread has been successfully locked',
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
|
||||
thread_state.locked = '1';
|
||||
} else {
|
||||
lockThreadEl.innerHTML = '<i class="icon-lock"></i> Lock Thread';
|
||||
@@ -252,6 +284,16 @@
|
||||
deleteBtns[x].style.display = 'inline-block';
|
||||
}
|
||||
|
||||
if (alert) {
|
||||
app.alert({
|
||||
'alert_id': 'thread_lock',
|
||||
type: 'success',
|
||||
title: 'Thread Unlocked',
|
||||
message: 'Thread has been successfully unlocked',
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
|
||||
thread_state.locked = '0';
|
||||
}
|
||||
}
|
||||
@@ -281,5 +323,37 @@
|
||||
thread_state.deleted = '0';
|
||||
}
|
||||
}
|
||||
|
||||
function set_pinned_state(pinned, alert) {
|
||||
var pinEl = document.getElementById('pin_thread');
|
||||
|
||||
if (pinned) {
|
||||
pinEl.innerHTML = '<i class="icon-pushpin"></i> Unpin Thread';
|
||||
if (alert) {
|
||||
app.alert({
|
||||
'alert_id': 'thread_pin',
|
||||
type: 'success',
|
||||
title: 'Thread Pinned',
|
||||
message: 'Thread has been successfully pinned',
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
|
||||
thread_state.pinned = '1';
|
||||
} else {
|
||||
pinEl.innerHTML = '<i class="icon-pushpin"></i> Pin Thread';
|
||||
if (alert) {
|
||||
app.alert({
|
||||
'alert_id': 'thread_pin',
|
||||
type: 'success',
|
||||
title: 'Thread Unpinned',
|
||||
message: 'Thread has been successfully unpinned',
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
|
||||
thread_state.pinned = '0';
|
||||
}
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
@@ -44,6 +44,7 @@ var RDB = require('./redis.js'),
|
||||
'category_slug':thread_data.category_slug,
|
||||
'locked': parseInt(thread_data.locked) || 0,
|
||||
'deleted': parseInt(thread_data.deleted) || 0,
|
||||
'pinned': parseInt(thread_data.pinned) || 0,
|
||||
'topic_id': tid,
|
||||
'expose_tools': viewer_data.reputation >= config.privilege_thresholds.manage_thread ? 1 : 0,
|
||||
'posts': posts
|
||||
@@ -80,6 +81,7 @@ var RDB = require('./redis.js'),
|
||||
.get('tid:' + tid + ':category_name')
|
||||
.get('tid:' + tid + ':category_slug')
|
||||
.get('tid:' + tid + ':deleted')
|
||||
.get('tid:' + tid + ':pinned')
|
||||
.exec(function(err, replies) {
|
||||
post_data = {
|
||||
pid: pids,
|
||||
@@ -91,10 +93,11 @@ var RDB = require('./redis.js'),
|
||||
|
||||
thread_data = {
|
||||
topic_name: replies[4],
|
||||
locked: replies[5],
|
||||
locked: replies[5] || 0,
|
||||
category_name: replies[6],
|
||||
category_slug: replies[7],
|
||||
deleted: replies[8] || 0
|
||||
deleted: replies[8] || 0,
|
||||
pinned: replies[9] || 0
|
||||
};
|
||||
|
||||
user.getMultipleUserFields(post_data.uid, ['username','reputation','picture'], function(user_details){
|
||||
|
||||
@@ -27,16 +27,18 @@ var RDB = require('./redis.js'),
|
||||
slug = [],
|
||||
postcount = [],
|
||||
locked = [],
|
||||
deleted = [];
|
||||
deleted = [],
|
||||
pinned = [];
|
||||
|
||||
for (var i=0, ii=tids.length; i<ii; i++) {
|
||||
title.push('tid:' + tids[i] + ':title');
|
||||
uid.push('tid:' + tids[i] + ':uid');
|
||||
timestamp.push('tid:' + tids[i] + ':timestamp');
|
||||
slug.push('tid:' + tids[i] + ':slug');
|
||||
postcount.push('tid:' + tids[i] + ':postcount'),
|
||||
locked.push('tid:' + tids[i] + ':locked'),
|
||||
postcount.push('tid:' + tids[i] + ':postcount');
|
||||
locked.push('tid:' + tids[i] + ':locked');
|
||||
deleted.push('tid:' + tids[i] + ':deleted');
|
||||
pinned.push('tid:' + tids[i] + ':pinned');
|
||||
}
|
||||
|
||||
var multi = RDB.multi()
|
||||
@@ -51,6 +53,7 @@ var RDB = require('./redis.js'),
|
||||
.mget(postcount)
|
||||
.mget(locked)
|
||||
.mget(deleted)
|
||||
.mget(pinned)
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +69,7 @@ var RDB = require('./redis.js'),
|
||||
postcount = replies[5];
|
||||
locked = replies[6];
|
||||
deleted = replies[7];
|
||||
pinned = replies[8];
|
||||
|
||||
user.get_usernames_by_uids(uid, function(userNames) {
|
||||
|
||||
@@ -79,11 +83,18 @@ var RDB = require('./redis.js'),
|
||||
'relativeTime': utils.relativeTime(timestamp[i]),
|
||||
'slug' : slug[i],
|
||||
'post_count' : postcount[i],
|
||||
'icon': locked[i] === '1' ? 'icon-lock' : 'hide',
|
||||
'deleted': deleted[i]
|
||||
'lock-icon': locked[i] === '1' ? 'icon-lock' : 'hide',
|
||||
'deleted': deleted[i],
|
||||
'pinned': parseInt(pinned[i] || 0), // For sorting purposes
|
||||
'pin-icon': pinned[i] === '1' ? 'icon-pushpin' : 'hide'
|
||||
});
|
||||
}
|
||||
|
||||
// Float pinned topics to the top
|
||||
topics = topics.sort(function(a, b) {
|
||||
return b.pinned - a.pinned;
|
||||
});
|
||||
|
||||
callback({
|
||||
'category_name' : category_id ? category_name : 'Recent',
|
||||
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||
@@ -244,4 +255,36 @@ var RDB = require('./redis.js'),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Topics.pin = function(tid, uid, socket) {
|
||||
user.getUserField(uid, 'reputation', function(rep) {
|
||||
if (rep >= configs.privilege_thresholds.manage_thread) {
|
||||
// Mark thread as deleted
|
||||
RDB.set('tid:' + tid + ':pinned', 1);
|
||||
|
||||
if (socket) {
|
||||
io.sockets.in('topic_' + tid).emit('event:topic_pinned', {
|
||||
tid: tid,
|
||||
status: 'ok'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Topics.unpin = function(tid, uid, socket) {
|
||||
user.getUserField(uid, 'reputation', function(rep) {
|
||||
if (rep >= configs.privilege_thresholds.manage_thread) {
|
||||
// Mark thread as deleted
|
||||
RDB.del('tid:' + tid + ':pinned');
|
||||
|
||||
if (socket) {
|
||||
io.sockets.in('topic_' + tid).emit('event:topic_unpinned', {
|
||||
tid: tid,
|
||||
status: 'ok'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}(exports));
|
||||
@@ -299,14 +299,12 @@ var config = require('../config.js'),
|
||||
}
|
||||
|
||||
|
||||
User.exists = function(socket, username, callback) {
|
||||
User.exists = function(username, callback) {
|
||||
User.get_uid_by_username(username, function(exists) {
|
||||
exists = !!exists;
|
||||
|
||||
if (callback)
|
||||
callback(exists);
|
||||
else
|
||||
socket.emit('user.exists', {exists: exists});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -160,6 +160,9 @@ passport.deserializeUser(function(uid, done) {
|
||||
|
||||
// These functions are called via ajax once the initial page is loaded to populate templates with data
|
||||
function api_method(req, res) {
|
||||
|
||||
|
||||
|
||||
switch(req.params.method) {
|
||||
case 'home' :
|
||||
global.modules.categories.get(function(data) {
|
||||
@@ -213,6 +216,7 @@ passport.deserializeUser(function(uid, done) {
|
||||
});
|
||||
break;
|
||||
case 'users' :
|
||||
|
||||
get_account_fn(req, res, function(userData) {
|
||||
res.send(JSON.stringify(userData));
|
||||
});
|
||||
@@ -335,20 +339,29 @@ passport.deserializeUser(function(uid, done) {
|
||||
return res.redirect('/403');
|
||||
|
||||
var requestedUserId = req.user.uid;
|
||||
|
||||
if(req.params.id != req.user.uid)
|
||||
requestedUserId = req.params.id;
|
||||
|
||||
user.getUserData(requestedUserId, function(data) {
|
||||
if(data)
|
||||
{
|
||||
data.joindate = utils.relativeTime(data.joindate);
|
||||
|
||||
callback({user:data});
|
||||
}
|
||||
else
|
||||
callback({user:{}});
|
||||
|
||||
var username = req.params.id;
|
||||
|
||||
user.get_uid_by_username(username, function(uid) {
|
||||
|
||||
if(uid != req.user.uid)
|
||||
requestedUserId = uid;
|
||||
|
||||
user.getUserData(requestedUserId, function(data) {
|
||||
if(data)
|
||||
{
|
||||
data.joindate = utils.relativeTime(data.joindate);
|
||||
data.uid = requestedUserId;
|
||||
callback({user:data});
|
||||
}
|
||||
else
|
||||
callback({user:{}});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -371,29 +384,43 @@ passport.deserializeUser(function(uid, done) {
|
||||
res.send('User list');
|
||||
});
|
||||
|
||||
app.get('/users/:uid', handleUserProfile);
|
||||
app.get('/users/:uid/:username*', handleUserProfile);
|
||||
app.get('/users/:uid/edit', function(req, res){
|
||||
console.log("OPPA");
|
||||
|
||||
if(req.user && req.params.uid)
|
||||
{
|
||||
//res.send("editing user");
|
||||
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/' + req.params.uid+'/edit");});</script>' + templates['footer']);
|
||||
}
|
||||
else
|
||||
return res.redirect('/403');
|
||||
});
|
||||
|
||||
|
||||
app.get('/users/:username*', handleUserProfile);
|
||||
|
||||
|
||||
function handleUserProfile(req, res) {
|
||||
|
||||
if(req.params.uid == 0) {
|
||||
if(!req.params.username) {
|
||||
res.send("User doesn't exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
user.getUserData(req.params.uid, function(data) {
|
||||
if(data) {
|
||||
if(req.url.indexOf(data.username) == -1)
|
||||
res.redirect(301, '/users/'+req.params.uid+'/'+data.username);
|
||||
else
|
||||
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/' + req.params.uid +'/'+data.username + '");});</script>' + templates['footer']);
|
||||
}
|
||||
else
|
||||
res.send("User doesn't exist!");
|
||||
user.get_uid_by_username(req.params.username, function(uid) {
|
||||
|
||||
user.getUserData(uid, function(data) {
|
||||
if(data) {
|
||||
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/'+data.username + '");});</script>' + templates['footer']);
|
||||
}
|
||||
else {
|
||||
res.send("User doesn't exist! /users/"+req.params.username);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
app.get('/test', function(req, res) {
|
||||
global.modules.topics.delete(1, 1);
|
||||
res.send();
|
||||
|
||||
@@ -124,7 +124,9 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
|
||||
});
|
||||
|
||||
socket.on('user.exists', function(data) {
|
||||
modules.user.exists(socket, data.username);
|
||||
modules.user.exists(data.username, function(exists){
|
||||
socket.emit('user.exists', {exists: exists});
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('user.count', function(data) {
|
||||
@@ -190,6 +192,14 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
|
||||
socket.on('api:topic.unlock', function(data) {
|
||||
modules.topics.unlock(data.tid, uid, socket);
|
||||
});
|
||||
|
||||
socket.on('api:topic.pin', function(data) {
|
||||
modules.topics.pin(data.tid, uid, socket);
|
||||
});
|
||||
|
||||
socket.on('api:topic.unpin', function(data) {
|
||||
modules.topics.unpin(data.tid, uid, socket);
|
||||
});
|
||||
});
|
||||
|
||||
}(SocketIO));
|
||||
|
||||
Reference in New Issue
Block a user