New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ticket/13713] User Mentions (GSoC 2018) #5225
Conversation
!set WIP |
Seems that the command no longer works... |
|
well done ... |
@@ -24,5 +24,10 @@ phpbb_help_routing: | |||
resource: help.yml | |||
prefix: /help | |||
|
|||
phpbb_mention_controller: | |||
path: /mention |
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.
Possible to rename the path like mention_json
or mention_api
?
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 don't think there's a need in introducing a suffix with underscore.
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 think we should start using a convention on that. Maybe something like /api/user/mention
on this specific case @marc1706
@@ -5,6 +5,8 @@ | |||
var text_name = <!-- IF $SIG_EDIT -->'signature'<!-- ELSE -->'message'<!-- ENDIF -->; | |||
var load_draft = false; | |||
var upload = false; | |||
var mention_url = '{UA_MENTION_URL}'; |
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 would prefer that these were handled via data attributes on a hidden input or other form of html tag to avoid using inline js cause eventually this will all be factored out. Might as well prep for it
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.
@hanakin so even very huge scripts such as the one in plupload.html will eventually be converted to data-
attributes or something similar?
Requiring additional code to parse them back to the original JS objects?
I haven't made any performance checks or tests but using a script block seems to me as a rather convenient solution. Probably there should be one inline block at the bottom instead of many other, requiring some additional template features like INCLUDEJS for accumulating script data.
IMHO I'll better leave it as is right now so that it can be changed the same way together with other variables when that change rolls out.
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.
The aim would be to get rid of inline js all together.
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.
@CHItA I understand that. That is why I'm asking about the reasons for that.
Because I also use inline script blocks in my extensions (e.g. quickreply_init.html) and I wonder how I'm supposed to convert them in future versions (I understand that I can leave it as is but I'd like to follow the guidelines).
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.
The new theme will probably use some build system for both JS and CSS by default, which will allow us to use some nice features (minification, auto-prefixing etc). This is obviously not usable on inlined JS or CSS.
Probably there will be some backend changes to support some features both for the new theme itself and extensions as well. However, these changes are not yet fully specified so we will probably publish our recommendations for extensions when we release those changes.
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.
@CHItA can't wait for those changes to be done :)
Are there any plans for a preprocessor (LESS/SASS) instead of plain CSS?
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.
There is never a reason to use inline scripts...just port it to its own file and include it using includejs. Using data attr for any template bar stuff etc... the use of minificatiin in the new theme coupled with the adoption of html2 will mean we can globalize most everything anyway at little cost.
The new theme will be a completely different beast and will not be compatible with any extensions now nor should as it will be released under 4.0.0 meaning no compatibility.
I am also looking into vuejs as an additional aspect as working with twig alone is problematic for certain circumstances where vue components just make it effortless and we gain the added benifit of less js for most of the interactivity.
But none of that is for certain still toying around with the idea and doing some tests
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.
@hanakin the only reason I use inline scripts is exactly for template variables that cannot be inserted to the plain JS.
Almost all other JS stuff goes with INCLUDEJS
.
Looking forward for new changes though.
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.
yes but you can instead use data for that and move everything to your js file.
You have a problem with phpBB folder in lowercase |
Isn't so much queries adding too much load to the server? Isn't caching the queries a middle way between server load and accuracy of the suggestions (new users/groups will pop up only after cache is past ttl)? Was this discussed somewhere? |
@senky caching queries will also be done just a bit later. That part should be one of the most complicated to decide. |
@@ -8,6 +8,22 @@ | |||
<!-- BEGIN listitem --><li><!-- END listitem --> | |||
<!-- BEGIN listitem_close --></li><!-- END listitem_close --> | |||
|
|||
<!-- BEGIN mention --> |
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 this temp code? the xsl stuff needs to be extrapolated out into the core. we should not be shipping any xsl in the bbcode.html file. Joshy needs to remove what he left there...
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 wasn't aware of Joshy's plans for that and this place seemed to be the right.
Moved to the core.
There is also much legacy stuff like first and second passes I guess.
Sometimes it is not obvious to distinguish the legacy, and I suppose that new BBCodes should not be handled by that code.
@@ -989,6 +989,18 @@ fieldset.fields2 dl:hover dt label { | |||
outline-color: rgba(19, 164, 236, 0.5); | |||
} | |||
|
|||
.atwho-container .atwho-view ul li:hover, |
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.
You can specify a class with this library so that you do not need to chain selectors
AND ' . $this->db->sql_in_set('u.user_type', [USER_NORMAL, USER_FOUNDER]) . ' | ||
AND ' . $this->db->sql_in_set('u.user_id', $user_ids), | ||
]); | ||
$res = $this->db->sql_query($query); |
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.
A good habit is to use $result
as a variable name.
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 thought that was common for phpBB but now I realize that this habit probably came from extensions.
Changed to $result
.
while ($row = $this->db->sql_fetchrow($res)) | ||
{ | ||
$this->cached_colors['users'][$row['user_id']] = $row['user_colour']; | ||
} |
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->db->sql_freeresult($res);
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.
Done.
while ($row = $this->db->sql_fetchrow($res)) | ||
{ | ||
$this->cached_colors['groups'][$row['group_id']] = $row['group_colour']; | ||
} |
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->db->sql_freeresult($res);
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.
Done.
@@ -1,5 +1,7 @@ | |||
<script type="text/javascript"> | |||
// <![CDATA[ | |||
var mention_url = '{UA_MENTION_URL}'; | |||
var mention_topic_id = '{S_TOPIC_ID}'; |
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.
S_
means switch
, i.e. boolean value. Just use {TOPIC_ID}
which is maybe already defined.
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.
@senky S_TOPIC_ID
is indeed already defined in functions.php
.
That is why it is used 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.
According to guidelines, S_
stands for system
, not for switch
.
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 right, then it's OK.
phpBB/includes/constants.php
Outdated
@@ -190,6 +190,7 @@ | |||
define('BBCODE_ID_EMAIL', 10); | |||
define('BBCODE_ID_FLASH', 11); | |||
define('BBCODE_ID_ATTACH', 12); | |||
define('BBCODE_ID_MENTION', 13); |
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.
How is this going to work out with users having existing custum_bbcodes? Do they start with ID 13? If so, this might cause problems I assume with those. Maybe even a idea to define it completly as custom bbcode instead of hardcoded in core
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 suppose that existing custom BBCodes don't have the hardcoded constant values.
But probably this constant can be removed entirely because it does not seem that I need to use it anywhere with the new parser. It could be suitable for deprecated stuff that is not necessary with the newly added BBCode.
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.
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.
Our stupid file structure is starting to really annoy me with a need to split colors. Please combine all css in a new file called mentions.css except for the colors. And include the new file please.
phpBB/assets/javascript/editor.js
Outdated
$(txtarea).atwho({ | ||
at: "@", | ||
displayTpl: function(data) { | ||
var avatar = (data.avatar.src) ? "<img src='" + data.avatar.src + "'>" : |
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 not use es6 template structure here https://caniuse.com/#search=Template%20literal
@hanakin what about As for ES6, PhpStorm is complaining every time about P.S. Needed to type this reply the second time, mobile Internet chewed my text 🙄 |
@hanakin what is the target IE version for 3.3 BTW? |
We have not supported ie 8 since 3.0 we dropped all support for ie 10 in 3.2 and going forward after 3.3 we are adopting >1% , last 2 browsers, you can check the package.json for any changes |
No do not split admin.css my bad. We no longer really use our lint for js as it’s antiquated and broken. I am working on a fix to switch to xo which is based on eslint which is far better. So for now maybe externalize everything into a function call so we can easily refactor |
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.
when you get time can you provide a screenshot of the rendered html/css also due to the sheer amount of changes can you also please post the rendered html code, that would help a lot?
@@ -29,6 +29,11 @@ | |||
// ]]> | |||
</script> | |||
|
|||
<!-- IF S_ALLOW_MENTIONS --> | |||
<div id="mention_params" style="display: none;" data-mention-url="{U_MENTION_URL}" data-mention-names-limit="{S_MENTION_NAMES_LIMIT}" data-topic-id="{S_TOPIC_ID}"></div> |
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.
just add the data to the form-buttons div
@@ -49,6 +49,12 @@ | |||
|
|||
// ]]> | |||
</script> | |||
|
|||
<!-- IF S_ALLOW_MENTIONS --> | |||
<div id="mention_params" style="display: none;" data-mention-url="{U_MENTION_URL}" data-mention-names-limit="{S_MENTION_NAMES_LIMIT}" data-topic-id="{S_TOPIC_ID}"></div> |
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.
same here just add the data to the format buttons div
@hanakin <div class="atwho-container">
<div id="atwho-ground-message">
<div class="atwho-view" id="at-view-64" style="display: none; top: 356.267px; left: 83.4503px;">
<ul class="atwho-view-ul">
<li class="mention-name cur">
<span class="mention-avatar"><i class="fa fa-user"></i></span><span>test</span>
</li>
<li class="mention-name">
<span class="mention-avatar"><i class="fa fa-group"></i></span><span>Administrators</span>
</li>
<li class="mention-name">
<span class="mention-avatar"><i class="fa fa-group"></i></span><span>Global moderators</span>
</li>
<li class="mention-name">
<span class="mention-avatar"><i class="fa fa-user"></i></span><span>LavIgor</span><span class="mention-rank">Site Admin</span>
</li>
</ul>
</div>
</div>
</div>
According to caniuse.com, IE 11 complies with this requirement. As we've discussed with @CHItA IE is actually the same as Edge and is no longer supported, but I personally use it sometimes. 😊
Should I split regular styles or leave them all as is now?
I've done that already, the function is named |
@lavigor for prosilver only separate out the colors, put the rest in a new css file called mention.css and import it before colours.css, please... hmm as I suspected the structure is actually pretty similar to the pm structure. Which is a port of https://codepen.io/hanakin/pen/vrgOGG?editors=1100. I will have some cleanup for you by Monday ;) |
phpBB/assets/javascript/editor.js
Outdated
(function($) { | ||
function handle_mentions(txtarea) { | ||
var $mentionDataContainer = $('#format-buttons'), |
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.
do not map to an id instead map to the first data element $([data-mention-url])
this way if the id should change it does not break the js
@@ -557,6 +557,11 @@ blockquote .codebox { | |||
padding: 5px 3px; | |||
} | |||
|
|||
/* Mention block */ | |||
.mention { |
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.
where is this used?
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 is used in posts for handling the parsed mention BBCode.
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.
ok it should still be in the new file with everything else.
PHPBB3-13713
PHPBB3-13713
PHPBB3-13713
PHPBB3-13713
PHPBB3-13713
PHPBB3-13713
PHPBB3-13713
PHPBB3-13713
PHPBB3-13713
fe46a41
to
c94eb9d
Compare
Rebased on latest master |
@marc1706 thanks |
No worries. Wanted to see how cleanly it applies and I guess based on tests there might be some incompatibilities we need to resolve. :) |
I've worked a bit on switching from the no longer developed atwho.js to zurb tribute: @lavigor would you have some time to maybe check if the behavior is the same as previously expected? |
I have now replaced this PR with #6206 |
This Pull Request is the result of GSoC 2018 Project “User Mentions”.
The Idea
This project is intended to add the ability to mention specific users in forum topics so that they will receive a notification (just like in many modern messengers and websites).
Affected modules
This PR is backwards-compatible and works well with phpBB 3.3's BBCode parser (that was newly added in phpBB 3.2).
How it works
Users can type the
@
symbol in textarea fields on the board to trigger a dropdown with usernames and group names. This list is generated based on several factors (called 'sources'): e.g. friends and topic repliers are shown higher in the list (internally they are given higher priorities).Besides general user and group sources, built-in name sources include:
Extension developers can add their own sources to give certain users and groups higher priorities based on other conditions.
Special cases taken into consideration:
The name of mentioned user/group becomes a link to its profile highlighed in the colour of that user/group.
Configuration
Users are able to disable mention notifications in the same way as for other types of notifications (on Edit notification options page in User Control Panel).
Administrators can enable/disable the entire mentions feature and set the maximum number of names shown in the dropdown list as well as the maximum number of names fetched from the server on each request (on Post settings page in Administration Control Panel).
Background
This feature uses the At.js library for displaying mention dropdown.
It also involves names caching both on frontend and backend to improve performance and reduce server load.
Current Status
User Mentions work. There'll be a PR to development documentation for how to add a new name source in your extension.
Checklist:
Tracker ticket (set the ticket ID to your ticket ID):
https://tracker.phpbb.com/browse/PHPBB3-13713