Currently, newly-created comments and replies in the InlineComments extensions appear with just the username, not the date and time; you need to reload the page to see those. That's because there's no easy way, within JavaScript, to display a datetime in the way that the current user prefers. Solving this may require creating an API action wihin InlineComments, so that the JS code can call the API to retrieve the correct string from PHP.
Description
Details
Related Objects
- Mentioned In
- T359976: {GSOC 2024 Project Proposal}-Improve InlineComments Extension
T359889: Gsoc-2024 : Improve InlineComments Extension Project Proposal
T359771: GSoC 2024 proposal - Improve InlineComments extension
T359760: GSOC(2024) Proposal for Improve InlineComments extension
T327263: Add class to row's paragraph
T356436: Improve InlineComments extension
Event Timeline
@Yaron_Koren , on going through the codebase I understood a few things ,
- In makeComment.js the below code snippet gets the username and appends it to the textDiv when a comment is added.
if ( mw.config.get( 'wgUserName' ) !== null ) { // username will be null if anon. var author = document.createElement( 'div' ); author.className = 'mw-inlinecomment-author'; author.textContent = mw.config.get( 'wgUserName' ); textDiv.append( author );
- In AnnotationFormatter.js the formatAuthor function formats the div to concatenate timestamp as well after the page is reloaded.
private function formatAuthor( $userId, $username, string $timestamp ) { return Html::rawElement( 'div', [ 'class' => 'mw-inlinecomment-author' ], Linker::userLink( $userId, $username ) . $timestamp ); }
I referred to these links https://www.mediawiki.org/wiki/API:Tutorial, https://www.mediawiki.org/w/api.php, https://www.mediawiki.org/wiki/Timestamp as well. To understand the codebase well, can you assist me further on how to proceed further and extract timestamp and implement the above functionality.
@Yaron_Koren I think I have figured out an implementation for this issue . I declared an AddTimestamp api which fetches timestamp from wfTimestampnow() and formats it in the same format as AnnotationFormatter.php and displays it with the author name and registered the api in extension.json . I have attached a screencast of the feature , should I make a draft PR as of now as more changes to AnnotationFormatter are yet to be done, also this is for makeComment.js , I believe similar changes have to be made for addReply.js as well.
Change 1010349 had a related patch set uploaded (by Rockingpenny4; author: Rockingpenny4):
[mediawiki/extensions/InlineComments@master] Adds timestamp api to display correct date/time on comment creation
Change 1010349 had a related patch set uploaded (by Rockingpenny4; author: Rockingpenny4):
[mediawiki/extensions/InlineComments@master] Add Timestamp display on comment creation
Change 1010349 merged by jenkins-bot:
[mediawiki/extensions/InlineComments@master] Add Timestamp display on comment creation
Change 1010852 had a related patch set uploaded (by Rockingpenny4; author: Rockingpenny4):
[mediawiki/extensions/InlineComments@master] Add timestamps to comment replies
Change 1010852 merged by jenkins-bot:
[mediawiki/extensions/InlineComments@master] Add Timestamp display to comment replies