dwitter icon indicating copy to clipboard operation
dwitter copied to clipboard

The complete comment system revamp

Open dwitterer opened this issue 7 years ago • 7 comments

(Don't merge yet!)

I was initially going to create just a separate branch for the tests for the new hashtag system, but I ended up having all the new changes in this branch. Anyway, this pull request covers all the new functionalities and improvements for the comment system on Dwitter:

  • The "anchor annihilator", as I affectionately call it, will now remove all links from code blocks. So stuff like colour codes and URLs will not be transformed into tags - this makes hashtags more accurate, and allows users to use code blocks as a mechanism to escape mentions (u/, d/) and links
  • Long, dwitter-specific, URLs will now be "autocropped" into their shorter form upon comment submission - for example, dwitter.net/d/123 will automatically turn into d/123
  • Hashtag requirements updated to allow tags starting with digits - tags must now be preceded by a space (or start of string), and must include at least one letter; old restrictions still apply for the characters allowed in said hashtags
  • New tests were added, per request, to make sure that all the new features work correctly (I know you don't care)

NOTE: The first two bulletpoints seem to require a refresh to work, after you post a comment using them... I'm not sure if this will be the case in production, but it's not a major issue anyway. Just thought I'd let you know, so that you would know. They should show up normally for other users viewing comments.

Overall, just minor things really, but they fix many of the bugs and annoying technical issues with the current comment system, and greatly increase the accuracy of the hashtag system.

dwitterer avatar Nov 20 '18 18:11 dwitterer

Things to fix with the comment system in future PRs:

  • The refresh thing, if applicable
  • Hashtags followed by a dot (and possibly some other characters - I might have an idea how to fix this, but I'll hold off with it for now)
  • Anything else? I can't think of any more issues with the comment system :P

dwitterer avatar Nov 20 '18 18:11 dwitterer

Thanks for the info. I will certainly have a look at the models.py. The refreshing thing woud be qood to fix, but I think that I'll move that onto another PR. This is already quite a large one, and minor annoyances like this are not a major priority right now. I will also have a look at the code thing you sent, but your formatting kinda messed up there, so not sure exactly what that is supposed to say. As for the number-only hashtags, the requirement for a letter kinda put itself in place, and I just kept it there, as it seems to match the way twitter hashtags work, and y'know, twitter knows their stuff when it comes to hashtags :wink: Also, number-only hashtags probably wouldn't be very meaningful anyway. Also also, wht if I make a comment saying "My dweet is #1"? I don't want the "#1" to be a hashtag!

Anyways, I have quite a lot of school work to do for the next few days, but hopefully I can have a look (and maybe finally get this PR ready) next friday/weekend :)

Thanks again for the stuff!

dwitterer avatar Nov 25 '18 20:11 dwitterer

Okay, so I fixed the formatting in that code comment of yours, and pasted it into my localhost version of dwitter. The only thing that I could find that could possibly fail is the double backticks as in `whatever `a``, and we already test for that, so I'll just ignore that for now, unless you can clarify what issue you have found.

So all I need to do now, is solve the usernames thing....

That was easy :D

dwitterer avatar Nov 26 '18 19:11 dwitterer

Okay, so I fixed all of the stuff you mentioned above, and put tests in place for the new punctuation stuff. As of right now, all d/ links, u/ links, and hashtags have to be followed by a space, end-of-string, comma, colon, semi-colon, question mark, or exclamation point. Parentheses and quotes will be added in soon to fix 2-3 more tests....

However, I kinda need your help, as half of my tests are now failing due to 'unbalanaced parentheses' in the same file, at the same place, when I haven't even touched that file... :thinking:

After we fix that, we're pretty much ready to merge :D

dwitterer avatar Nov 26 '18 21:11 dwitterer

The error is on this line: https://github.com/lionleaf/dwitter/pull/424/files#diff-f552aa4b1485a67b4f2ebbdd750855c0R138

stianjensen avatar Nov 26 '18 21:11 stianjensen

Looks like I messed up github markdown in an earlier comment. Let me try again; what happens with a comment like this (today #FFFFFF would become a clickable hashtag):

This is a comment with some code: ` color:#FFFFFF;` 

Does it look ok? And I guess it might be silently added to hashtags, so even if #FFFFFF doesn't become clickable the dweet can now be found at h/FFFFFF ?

lionleaf avatar Nov 28 '18 13:11 lionleaf

Should fix #334

lionleaf avatar Nov 29 '18 14:11 lionleaf