Move escaping of topic and improve UI for long topics
- Data should be handled as is and only do the escaping on the view/template or wherever it is used and escaping is necessary. Keeps things simple and the focus of escaping values in the right place. - Remove topic capitalization - For long topics: hide overflow and add a title to topic span - Also, simplify the code a tiny bit.
This commit is contained in:
parent
dc79d71ae5
commit
4293336f3e
@ -403,16 +403,14 @@ button {
|
||||
line-height: 50px !important;
|
||||
height: 48px;
|
||||
padding: 0 20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
#windows .header .title {
|
||||
font: 14px Lato;
|
||||
}
|
||||
#windows .header .topic {
|
||||
/* Hidden for now */
|
||||
display: none;
|
||||
color: #777;
|
||||
margin-left: 8px;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
#windows .header .right {
|
||||
float: right;
|
||||
|
@ -315,7 +315,11 @@ $(function() {
|
||||
});
|
||||
|
||||
socket.on("topic", function(data) {
|
||||
$("#chan-" + data.chan).find(".header .topic").html(data.topic);
|
||||
// .text() escapes HTML but not quotes. That only matters with text inside attributes.
|
||||
var topic = $("#chan-" + data.chan).find(".header .topic");
|
||||
topic.text(data.topic);
|
||||
// .attr() is safe escape-wise but consider the capabilities of the attribute
|
||||
topic.attr("title", data.topic);
|
||||
});
|
||||
|
||||
socket.on("users", function(data) {
|
||||
|
@ -9,27 +9,24 @@ module.exports = function(irc, network) {
|
||||
return;
|
||||
}
|
||||
var from = data.nick || chan.name;
|
||||
var self = false;
|
||||
if (from.toLowerCase() == irc.me.toLowerCase()) {
|
||||
self = true;
|
||||
}
|
||||
var topic = data.topic;
|
||||
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.TOPIC,
|
||||
mode: chan.getMode(from),
|
||||
from: from,
|
||||
text: topic,
|
||||
self: self
|
||||
self: (from.toLowerCase() === irc.me.toLowerCase())
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
client.emit("msg", {
|
||||
chan: chan.id,
|
||||
msg: msg
|
||||
});
|
||||
chan.topic = topic
|
||||
chan.topic = topic;
|
||||
client.emit("topic", {
|
||||
chan: chan.id,
|
||||
topic: _.escape(topic)
|
||||
topic: chan.topic
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user