-
Notifications
You must be signed in to change notification settings - Fork 271
made channel names in chat clickable; lets users join channels #385
Conversation
2a9d661
to
164c96e
Compare
@@ -573,6 +573,7 @@ button { | |||
} | |||
#chat .wrap, | |||
#chat .text a { | |||
cursor: pointer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really necessary to add a cursor pointer to a
links as opposed to default behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, what means necessary. If you want the links to appear and behave the same as normal html links, then yes. It is necessary. If you are satified with the default behavior, which means the cursor changes to text
, then it is not necessary.
I like the first option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't see the #chat .wrap
on the first line. However, I'm confused, all links are wrapped into a
links (what you called normal HTML links). Do you have an example where we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MIght be that one of us is missing something. My point is, when I create a link like so: <a data-chan="#channel">
it will not have the pointer cursor due to the missing href
. At least firefox behaves like that. To solve that I added cursor: pointer;
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, very good point! I had forgotten about this oddity. Well, the HTML5 spec does say that the a
element, absent an href
, is not an hyperlink but a placeholder.
This Stack Overflow is very well built and even links to WAI-ARIA!
My conclusion on this (also after reading this) is that we should not go for an a
link. We should either go for a button
or a span
with the right ARIA role and focus behavior. At the moment links on the left menu are using a span
, links on the right menu are using a button
. Please go for a button
and if you realize it's hell to style (not sure how it behaves with long statements that go to a second line) then switch back to a span
:
<button role="button" tabindex="0">...</button>
This is definitely the right way to go for in-app "links" and I'll make sure we go for the right route in subsequent choices. And we keep a
links for actual hyperlinks.
Does that make sense to you? Let me know if you have any questions, and sorry for being slow at first :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sounds good to me. Let me change that tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for being so responsive, I really appreciate it! Talk to you soon.
I'll try to give a review to this PR. Will look for @erming or @JocelynDelalande's eyes as well. |
var html = $(this).html(); | ||
$(this) | ||
.addClass("processed") | ||
.html(html.replace(/(\W)(#[\w\d-.]{0,200})/ig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will match channels longer than the IRC daemon likely supports. Does this need to be 200?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched for the specification when creating the regular expression and came up with this:
Channels names are strings (beginning with a '&' or '#' character) of
length up to 200 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for linking to an RFC 👏
Actually, it's so useful to have it there, could you make it a comment shaped like this please:
// Channels names are strings (beginning with a '&' or '#' character)
// of length up to 200 characters.
// See https://tools.ietf.org/html/rfc1459#section-1.3
.html(...
Three other comments:
- I don't see support for
&channel
, as only#
is present in your regex. Could you add support for this please? - Even though the RFC doesn't explicitly say it, I don't think
#
is a legal channel. So maybe minimal length should be1
instead of0
- The RFC says, however, that channel names are up to 200 characters,
#
/&
included :-) So it should be199
and not200
:-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I couldn't find a network where &channel is working. Are you sure that this is supported by shout's backend?
- Actually, I do think so. Test it on the shout demo network for example.
/join #
works just fine. - I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I couldn't find a network where &channel is working. Are you sure that this is supported by shout's backend?
Typing /join <whatever>
in the input is simply a forward to Slate with <whatever>
as an argument, which in turn merely sends JOIN <whatever>
to the network, so I don't think there any massaging on that. Actually, it might be nice to prevent trying to join a network that does not respect the RFC, either on Shout or on Slate, but that's for another PR ;-)
Additionally, I asked @deiu as I know he is using Shout on a &
-enabled server and he confirmed it works fine.
- Actually, I do think so. Test it on the shout demo network for example.
/join #
works just fine.
You are correct (and it highlighted #483 ^^), so the right interval is {0,199}
indeed!
Sorry for not contributing anything, but I just want to say that I support this feature. I think it's a good addition. |
Thanks for your feedback. Added it to the code. Also I made a litte change to the regex to comply with the rfc completely. Originally, it only allowed a-zA-Z0-9. It's now accepting every character except those mentioned in the RFC: space, comma, \x07 |
// Channels names are strings (beginning with a '&' or '#' character) | ||
// of length up to 200 characters. | ||
// See https://tools.ietf.org/html/rfc1459#section-1.3 | ||
.html(html.replace(/(\W)([#&][^\x07\x2C\s]{0,199})/ig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you replace [\w\d-.]
with [^\x07\x2C\s]
? What does the latter one mean? Seems more cryptic (if you consider regexes aren't cryptic in the first place...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AmShaegar13 answered here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RFC states:
the only restriction on a
channel name is that it may not contain any spaces (' '), a control G
(^G or ASCII 7), or a comma (',' which is used as a list item
separator by the protocol)
Nice @AmShaegar13!
|
I discovered another downside of the button: You cannot select it as text. We should really use span... This should fix long channel names.
This took me to another problem: HTML entities are escaped. So instead of joining |
Yes, go for it :-)
You probably didn't push this, did you?
I don't think we should: this definitely belongs to the client, not the server! Plus, in the |
Here we go. First of all, I replaced button by span. I had to add the rule for the pointer cursor again now. Secondly, I cleaned up the 'processed' thing. I have no ide why I did this in the first place... I made the new message a jQuery object and used this for further processing. I fixed the issue by working directly on the element, if there is one. Also, I broke travis-ci, although I'm not sure if it's really my fault. The output says something about a timeout. I can still fetch link information on my development instance. Still missing the open-already-joined-channels thing. Please let me know what you think! |
You didn't :) Actually, it was broken already, now it's fixed, see #493 please update your PR rebasing on |
Hi @AmShaegar13, this looks very good, exciting! Trying the changes in a local clone, here is what I notice though:
As @JocelynDelalande just said, don't worry about the tests, just rebase and you'll be fine :-) |
if more than 50 chars it's not an irc chan name. |
Waouh! @AmShaegar13 and I got tricked by [an older RFC]! Thanks @JocelynDelalande! @AmShaegar13, could you update your regex to accept the 4 prefixes followed by 49 characters? |
@JocelynDelalande that RFC is near universally rejected by IRC daemon developers. |
This is one of these very strong statements that could really use a reference. Fact is, it seems to be true on Freenode, at least... (or shout itself refuses to join, which is a different but still relevant problem) |
9e145f4
to
7788f69
Compare
Okay, implemended your feedback but there are still two little issues I just found out.
|
a821d58
to
7c26b04
Compare
Okay, fixed that too. The only restriction now is that #channels need to be enclosed by spaces or be at the beginning or end of a line. Do you want me to squash all commits and rebase on master after the final review? |
@AmShaegar13 cool :) just tested : On feature:
On style:
Yes please :) it seems to me that they could be one commit. |
Well, looks like this depends on the network/irc daemon used. The one I am testing on just drops all characters after the 32nd one. So it will always work. If I set the limit down to 50, it will not work in networks that allow 200 characters. So I'd like to stick with that.
I would rather not insert a constant in a regular expression. It makes it even harder to read and understand.
Sorry, just used search an replace ^^ |
7d69b88
to
b3a9946
Compare
.find('.chan.active') | ||
.parent('.network') | ||
.find(".chan[data-title='" + $(this).data("chan") + "']"); | ||
if (chan.size() == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace with ===
here please?
Agreed, and I'm also against centrally-managed constant files here. Many reasons to that but I have seen that in practice and it didn't work well. Simple is enough, and in the future, I'd like to see this very feature being a plugin (but valued as core feature and enabled by default) so having self-sufficient code is ideal. I'll give a full final review whenever I can find time to do so, sorry for the delay. |
cursor: pointer; | ||
} | ||
#chat .msg .inline-channel:hover { | ||
opacity: .8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed existing opacities are floating between .6
and .8
but here I'd prefer .6
to be consistent with existing links on the chat window.
Interesting, when you click on the channel name (in Chrome), you get a link border for a second, but not on the nick names. I guess that's one difference between buttons and spans here... |
Apart from the minor comments I left inline, this looks good to me. Will wait for final amend before 👍. Getting there, getting there! :-) |
b3a9946
to
359905f
Compare
I am sorry. I was very busy. Finally included you remaining points. |
@AmShaegar13 thanks! To be honest, I had forgotten about this, but hopefully this is almooost ready to go. If you take a look at the Travis report, you'll see that your PR breaks a styling rule. Could you use double quotes instead of single quotes? I'll be happy to merge after that! |
.trigger("msg", [ | ||
target, | ||
data.msg | ||
]); | ||
|
||
var text = msg.find('.text'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use double quotes here.
359905f
to
58d4a2f
Compare
GitHub doesn't notify commits, so we were not notified you rebased :-) That's a 👍 for me. |
👍 merging, thanks @AmShaegar13 ! |
@JocelynDelalande, you closed instead of merging :-) |
made channel names in chat clickable; lets users join channels
Implements #361.