Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

profile page updates; removed channel listing

  • Loading branch information...
commit 150d5ce91d44c8256d7ecbeb45d0e28ead838621 1 parent d1f4f27
@ednapiranha ednapiranha authored
View
3  Makefile
@@ -1,4 +1,5 @@
test:
- @./node_modules/.bin/mocha
+ @./node_modules/.bin/mocha \
+ --globals const
.PHONY: test
View
7 app.js
@@ -1,4 +1,5 @@
-"use strict";
+'use strict';
+
var noodle = require('./package');
var express = require('express');
var configurations = module.exports;
@@ -19,8 +20,8 @@ client.set('channels:noodletalk', 'noodletalk');
var io = require('socket.io').listen(app);
-io.configure(function() {
- io.set('transports', ['xhr-polling']);
+io.configure(function() {
+ io.set('transports', ['xhr-polling']);
io.set('polling duration', 10);
});
View
17 lib/authenticate.js
@@ -1,4 +1,6 @@
-const GRAVATAR_URL = 'https://secure.gravatar.com/avatar/';
+'use strict';
+
+var GRAVATAR_URL = 'https://secure.gravatar.com/avatar/';
var crypto = require('crypto');
var request = require('request');
@@ -47,10 +49,19 @@ exports.verify = function(req, nconf, callback) {
// Return a hash of the public user metadata
exports.getUserHash = function(req, nickname, channel, isOwner, callback) {
+ var emailHash;
+
if (isOwner) {
- var emailHash = crypto.createHash('md5').update(req.session.email).digest("hex");
+ emailHash = crypto.createHash('md5').update(req.session.email).digest("hex");
} else {
- var emailHash = req.params.email;
+ emailHash = req.params.email;
+
+ // An explicit email was set, so change to the md5 hash
+ if (emailHash.indexOf('@') > -1) {
+ emailHash = crypto.createHash('md5').update(emailHash).digest("hex");
+ nickname = emailHash;
+ channel = 'profile-' + emailHash;
+ }
}
var user = {
View
18 lib/message-maker.js
@@ -1,6 +1,8 @@
-const EPIC_SUFFIXES = ['', 'the Great', 'the Silent', 'the Wicked', 'the Disturbed',
- 'the Outcast', 'the Heroine', 'Esquire'];
-const REGAL_PREFIXES = ['', 'Sir', 'Count', 'Duchess', 'Baron', 'Commodore', 'Peon'];
+'use strict';
+
+var EPIC_SUFFIXES = ['', 'the Great', 'the Silent', 'the Wicked', 'the Disturbed',
+ 'the Outcast', 'the Heroine', 'Esquire'];
+var REGAL_PREFIXES = ['', 'Sir', 'Count', 'Duchess', 'Baron', 'Commodore', 'Peon'];
var auth = require('../lib/authenticate');
var content = require('../lib/web-remix');
var gravatar = require('gravatar');
@@ -43,14 +45,14 @@ exports.getMessage = function(client, channel, req, io, actionType, callback) {
is_action: isAction,
action_type: actionType
};
-
+
return message;
};
this.generateWelcomeMessage = function() {
- return '<em>Now introducing, ' +
- REGAL_PREFIXES[Math.round(Math.random() * (REGAL_PREFIXES.length - 1))] +
- ' ' + req.session.nickname[channel] +
+ return '<em>Now introducing, ' +
+ REGAL_PREFIXES[Math.round(Math.random() * (REGAL_PREFIXES.length - 1))] +
+ ' ' + req.session.nickname[channel] +
' ' + EPIC_SUFFIXES[Math.round(Math.random() * (EPIC_SUFFIXES.length - 1))] + '</em>';
};
@@ -95,7 +97,7 @@ exports.getMessage = function(client, channel, req, io, actionType, callback) {
} else {
message = '';
- }
+ }
isAction = true;
// if this is a /me prepend with the nick
View
65 lib/noodle-redis.js
@@ -1,13 +1,15 @@
+'use strict';
+
// Redis helper commands
-const MEDIA_IFRAME_MATCHER = /<iframe\s.+><\/iframe>/i;
-const MEDIA_OBJECT_MATCHER = /<object\s.+><\/object>/i;
-const MEDIA_VIDEO_MATCHER = /<video\s.+>.+<\/video>/i;
-const MEDIA_AUDIO_MATCHER = /<audio\s.+>.+<\/audio>/i;
-const MEDIA_IMAGE_MATCHER = /(\.jpg)|(\.jpeg)|(\.png)|(\.gif)/i;
-const ME_MATCH = /^(\/me\s)/i;
-const SLASH_MATCHER = /^(\/)\w?/i;
-const RECENT_MESSAGE_LIMIT = 39; // limit recent messages to 40, starting at 0
-const RECENT_MEDIA_LIMIT = 11; // limit recent media to 7, starting at 0
+var MEDIA_IFRAME_MATCHER = /<iframe\s.+><\/iframe>/i;
+var MEDIA_OBJECT_MATCHER = /<object\s.+><\/object>/i;
+var MEDIA_VIDEO_MATCHER = /<video\s.+>.+<\/video>/i;
+var MEDIA_AUDIO_MATCHER = /<audio\s.+>.+<\/audio>/i;
+var MEDIA_IMAGE_MATCHER = /(\.jpg)|(\.jpeg)|(\.png)|(\.gif)/i;
+var ME_MATCH = /^(\/me\s)/i;
+var SLASH_MATCHER = /^(\/)\w?/i;
+var RECENT_MESSAGE_LIMIT = 39; // limit recent messages to 40, starting at 0
+var RECENT_MEDIA_LIMIT = 11; // limit recent media to 7, starting at 0
var content = require('../lib/web-remix');
var messageMaker = require('../lib/message-maker');
@@ -47,51 +49,6 @@ exports.getUserlist = function(client, channel, callback) {
});
};
-/* Get a list of all the active non-private channels
- * Requires: the db client connection, socket io
- * Returns: a list of active channel hashes
- */
-exports.getChannelList = function(client, io, callback) {
-
- client.keys('channels:*', function(err, channels) {
- if (err) {
- return callback(err);
- }
-
- try {
- var channelList = [];
-
- if (channels.length > 0) {
- channels.forEach(function(channelItem, counter) {
- if (!channelItem.match(/^channels:private-[a-f0-9]{32}-[a-f0-9]{32}$/)) {
- client.get(channelItem, function(errChannel, channel) {
- if (errChannel) {
- return callback(errChannel);
- }
-
- var channelHash = {
- name: channel,
- userCount: io.sockets.clients(channel).length
- };
-
- channelList.unshift(channelHash);
- if (counter === channels.length - 1) {
- return callback(null, channelList);
- }
- });
- } else {
- return callback(null, channelList);
- }
- });
- } else {
- return callback(null, channelList);
- }
- } catch (channelErr) {
- return callback(channelErr);
- }
- });
-};
-
// Set a channel
exports.setChannel = function(client, channel) {
var channelName = escape(channel).toLowerCase();
View
14 lib/web-remix.js
@@ -1,9 +1,11 @@
-const MATCH_NICK = /^(\/nick\s?$)/i;
-const MATCH_ME = /^(\/me\s?$)/i;
-const EMOTI_HEART = '&lt;3';
-const MATCH_CHANNEL = /^#\w+/i;
-const VIDEO_HEIGHT = 281;
-const VIDEO_WIDTH = 500;
+'use strict';
+
+var MATCH_NICK = /^(\/nick\s?$)/i;
+var MATCH_ME = /^(\/me\s?$)/i;
+var EMOTI_HEART = '&lt;3';
+var MATCH_CHANNEL = /^#\w+/i;
+var VIDEO_HEIGHT = 281;
+var VIDEO_WIDTH = 500;
/* Embed media if it matches any of the following:
* 1. Is a Youtube link
View
8 public/javascripts/lib/commands.js
@@ -65,12 +65,6 @@ var checkCommands = function(form) {
commandIsMatched = true;
window.close();
- // channel listing
- } else if (commandMatched(channelMatcher)) {
- hideAllCommands();
- commandIsMatched = true;
- $('#channelList').fadeIn();
-
// personal options toggle
} else if (commandMatched(mediaToggleMatcher)) {
hideAllCommands();
@@ -115,6 +109,6 @@ var hideAllCommands = function(options) {
if (options) {
$(options).fadeOut();
} else {
- $('#help, #userList, #channelList, #whoami').fadeOut();
+ $('#help, #userList, #whoami').fadeOut();
}
}
View
18 public/javascripts/main.js
@@ -6,7 +6,6 @@ $(function() {
var initiatingChats = [];
var messagesUnread = 0;
var userList = [];
- var channelList = [];
var myUserList = [];
var userCount = 0;
var logLimit = 80;
@@ -201,11 +200,6 @@ $(function() {
updateMessage(data);
});
- socket.on('channels', function(data) {
- channelList = data;
- updateChannelList(data);
- });
-
socket.on('private', function (data) {
if (data) {
var chatNum = initiatingChats.indexOf(data);
@@ -280,18 +274,6 @@ $(function() {
}
};
- var updateChannelList = function() {
- var channels = $('#channels');
- channels.html('');
- for (var i=0; i < channelList.length; i++) {
- var channelItem = $('<li><a href="" target="_blank" title=""></a></li>');
- channelItem.find('a').attr('href', '/about/' + channelList[i].name).text(channelList[i].name +
- ' (' + parseInt(channelList[i].userCount, 10) + ')');
- channelItem.find('a').attr('title', channelList[i].name);
- channels.append(channelItem);
- }
- };
-
var keepListSane = function() {
updateUserList();
new TabComplete(myUserList);
View
37 public/stylesheets/style.css
@@ -345,7 +345,7 @@ form input {
box-shadow: #ccc -1px -1px 0px;
color: #606060;
font-size: 20px;
- margin: 5px 0px 0px 0px;
+ margin: 3px 0px 0px 0px;
padding: 5px;
width: 85%;
}
@@ -430,7 +430,7 @@ form.font8 input, .font8 {
width: 280px;
}
-#userList li, #channelList li {
+#userList li {
background-color: #aaeeff;
padding: 3px;
}
@@ -445,13 +445,12 @@ form.font8 input, .font8 {
text-overflow: ellipsis;
}
-#channelList li a, #channelList li span,
#userList li a, #userList li span {
display: block;
font-size: 14px;
}
-#userList li:hover, #channelList li:hover {
+#userList li:hover {
background-color: #c7f4ff;
}
@@ -510,6 +509,32 @@ form.font8 input, .font8 {
color: #397170;
}
+#profile img, #profile h2 {
+ float: left;
+}
+
+#profile h2 {
+ color: #aaa;
+ font-family: 'BebasNeueRegular';
+ font-size: 20px;
+ padding-left: 10px;
+}
+
+body.error h1 {
+ background-image: none;
+ color: #888;
+ font-family: 'BebasNeueRegular';
+ font-size: 20px;
+ text-indent: 0px;
+ width: 100%;
+}
+
+body.error h2 {
+ color: #222;
+ font-family: 'BebasNeueRegular';
+ font-size: 50px;
+}
+
@media only screen and (min-width: 1100px) and (max-width: 1350px) {
#messages {
margin-right: 5px;
@@ -597,7 +622,7 @@ form.font8 input, .font8 {
.info-block li {
width: 260px;
}
- #userList, #help, #channelList {
+ #userList, #help {
left: 20px;
top: 120px;
}
@@ -609,6 +634,7 @@ form.font8 input, .font8 {
width: 270px;
}
body[data-options="mediaOff"] #messages ol li {
+ min-width: 340px;
width: 97%;
}
.info-block li {
@@ -617,5 +643,4 @@ form.font8 input, .font8 {
#info {
right: 0px;
}
-
}
View
19 routes/index.js
@@ -1,6 +1,7 @@
var auth = require('../lib/authenticate');
var gravatar = require('gravatar');
var noodleRedis = require('../lib/noodle-redis');
+var crypto = require('crypto');
module.exports = function(client, noodle, nconf, app, io) {
app.get('/', function (req, res) {
@@ -91,12 +92,24 @@ module.exports = function(client, noodle, nconf, app, io) {
var user = {};
auth.getUserHash(req, req.params.email, channel, false, function(err, userHash) {
+ var placeholder = 'Send a message to this user';
+
+ if (req.session.email && crypto.createHash('md5').update(req.session.email).digest("hex") === userHash.nickname) {
+ placeholder = 'Send a message to yourself';
+ }
+
res.render('profile', {
title: 'Noodle Talk Profile',
- channel: channel,
- nickname: req.params.email,
- avatar: userHash.avatar
+ channel: 'profile-' + userHash.nickname,
+ nickname: userHash.nickname,
+ avatar: userHash.avatar,
+ placeholder: placeholder
});
});
});
+
+ // Post a message to a user or yourself
+ app.post('/message', function(req, res) {
+
+ });
};
View
11 routes/message.js
@@ -35,13 +35,10 @@ module.exports = function(client, nconf, app, io) {
noodleRedis.getUserlist(client, channel, function(userErr, userList) {
try {
- noodleRedis.getChannelList(client, io, function(errList, channels) {
- io.sockets.emit('channels', channels);
- io.sockets.in(channel).emit('userlist', userList);
- io.sockets.in(channel).emit('message', message);
- io.sockets.in(channel).emit('usercount', io.sockets.clients(channel).length);
- res.json(message);
- });
+ io.sockets.in(channel).emit('userlist', userList);
+ io.sockets.in(channel).emit('message', message);
+ io.sockets.in(channel).emit('usercount', io.sockets.clients(channel).length);
+ res.json(message);
} catch(err) {
res.json({ 'status': 500, 'error': errList });
}
View
2  settings.js
@@ -1,3 +1,5 @@
+'use strict';
+
// Module dependencies.
module.exports = function(app, configurations, express) {
var clientSessions = require('client-sessions');
View
25 test/test.routes.message.js
@@ -186,31 +186,6 @@ describe('message', function() {
});
});
- describe('has a channel list', function() {
- it('adds a new channel to the channel list', function(done) {
- var req = {
- body: {
- message: 'test'
- },
- params: {
- channel: 'noodletalk'
- },
- session: {
- nickname: { 'noodletalk': '' },
- email: 'test@test.org',
- emailHash: '12345'
- }
- };
-
- noodleRedis.setRecentMessage(client, req, io, function(err, message) {
- noodleRedis.getChannelList(client, io, function(err, channels) {
- channels[0].name.should.equal('noodletalk');
- });
- done();
- });
- });
- });
-
describe('has no change', function() {
it('ensures no message is broadcasted on a single command', function(done) {
var req = {
View
4 views/error_layout.jade
@@ -10,9 +10,9 @@ html
link(rel='apple-touch-icon', href='/images/apple-touch-icon-iphone4.png')
link(rel='stylesheet', href='/stylesheets/style.css')
- body
+ body.error
#header
- p Noodle Talk Oopsy!
+ h1 Noodle Talk Oopsy!
div#info
if !session.email
View
8 views/index.jade
@@ -26,11 +26,6 @@ block header
p Click on a user to initiate a private chat.
ul#noodlers
-#channelList.info-block
- a(class='close') x
- h2 Active Channels
- ul#channels
-
#whoami.info-block
a(class='close') x
h2 Who am I on this channel?
@@ -42,9 +37,6 @@ block header
h2 Noodle Commands
ul
- li(data-action='/channels')
- h3 /channels
- span= ' lists all active channels'
li(data-action='/clear')
h3 /clear
span= ' removes messages from your screen'
View
22 views/profile.jade
@@ -1 +1,21 @@
-img(src='#{avatar}')
+block header
+ #header
+ a(href='/')
+ h1 Noodle Talk
+ if session.email
+ #message
+ form(method='post', action='/about/#{channel}/message', autocomplete='off', class='font#{session.userFont}')
+ input(type='text', name='message', placeholder='#{placeholder}')
+ button(type='submit') add
+
+ div#info
+ if !session.email
+ a(href='#', id='login') Log in
+ form(method='post', action='/about/#{channel}/login', id='login-form')
+ input(type='hidden', name='bid_assertion', value='1')
+
+#profile
+
+ img(src='#{avatar}')
+
+ h2= nickname
Please sign in to comment.
Something went wrong with that request. Please try again.