Skip to content

Adding Reading Time Estimation to Article#47392

Closed
CSGoat0 wants to merge 46 commits intojoomla:6.2-devfrom
CSGoat0:plg-content-reading-time-estimation
Closed

Adding Reading Time Estimation to Article#47392
CSGoat0 wants to merge 46 commits intojoomla:6.2-devfrom
CSGoat0:plg-content-reading-time-estimation

Conversation

@CSGoat0
Copy link

@CSGoat0 CSGoat0 commented Mar 14, 2026

Pull Request resolves # .

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

This PR adds a new Content - Time Estimation Plugin that automatically calculates and displays the estimated reading time for articles.

Key Features:

  • Displays a reading time badge (with clock icon) below the article title
  • Shows both estimated minutes and word count
  • Admin can configure words per minute in plugin parameters (default: 50)
  • Works out-of-the-box with Cassiopeia template — no template override needed
  • Uses two Joomla events:
    • onContentPrepare – counts words while article text is raw HTML
    • onContentAfterTitle – injects the badge into afterDisplayTitle template slot

Admin Configuration:

  • Words per minute setting (default: 50) – adjustable based on audience reading speed

Testing Instructions

  1. Download and install the plugin from this PR
  2. Enable the plugin in Extensions → Plugins (search "Content - Time Estimation")
  3. Configure (optional):
    • Go to the plugin parameters
    • Adjust "Words per minute" value (default is 50)
  4. View any article on the frontend of your site
  5. Verify that a reading time badge appears below the article title showing:
    • Estimated minutes (e.g., "3 min read")
    • Word count (e.g., "(150 words)")

Actual result BEFORE applying this Pull Request

Articles do not display estimated reading time. Users have no way to know how long an article will take to read without manually scanning the content.

Expected result AFTER applying this Pull Request

Each article displays a clean reading time badge below its title showing:

  • Estimated reading time based on word count and configurable words-per-minute setting
  • Total word count
    The badge appears automatically in the afterDisplayTitle position without requiring template overrides.

Notes for Reviewers

  • AI Assistance: I used AI to help generate the initial metadata structure and code comments. I am happy to adjust anything if there are concerns about style, accuracy, or compliance.
  • Language Files Location: I followed the plugin development documentation which states that language files should be inside the plugin folder. This works correctly in my testing. I noticed that many existing plugins don't follow this structure, but when I tried to place language files elsewhere, it didn't work. If the preferred location is different, please let me know and I'll be happy to adjust.
  • Default WPM: Set to 50 as a conservative baseline, but fully configurable by admins.

Screenshots

Admin Configuration - Words Per Minute Setting
WPM setting
Admin can set the reading speed (default: 50 WPM)


Frontend Display - Reading Time Badge
Badge below article title
Badge appears automatically below the article title showing minutes and word count

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

bembelimen and others added 30 commits February 18, 2026 20:59
1. Removes the need for a seperate rtl css stylesheet
2. Stops reversing the hours/minutes cell
---------

Co-authored-by: Harald Leithner <leithner@itronic.at>
Co-authored-by: Stefan Wendhausen <stefan.wendhausen@tec-promotion.de>
Signed-off-by: BrianTeeman <brian@teeman.net>
This template allows users to submit detailed bug reports, including contact details, expected outcomes, software version, browser information, relevant logs, and agreement to the Code of Conduct.
Updated the bug report template to improve clarity and streamline the information requested.
Changed the default version from 5.4 to 0 in the bug report template.
Fix typo in expected result description.
Updated the accessibility issue template to YAML format with structured fields for better reporting.
…e-chooser

[5.4] Maintenance Task: Disable blank issue template
@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-6.2-dev Unit/System Tests labels Mar 14, 2026
@CSGoat0 CSGoat0 marked this pull request as draft March 14, 2026 17:07
@brianteeman
Copy link
Contributor

You are trying to merge a pull requests from your branch which is joomla 5.4 into 6.2. that's why you have so many changes

Please note that it is expected that you have actually tested to see if the code you are proposing works!!

; Plugin metadata (shown in Extensions Manager)
PLG_CONTENT_TIMEESTIMATION="Content - Time Estimation"
PLG_CONTENT_TIMEESTIMATION_DESCRIPTION="Displays an estimated reading time before each article, based on a configurable words-per-minute reading speed."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sys.ini file only contains language strings for when the plugin is not yet loaded. So the strings under this line are not necessary in this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I just followed the Plugins structure, they mostly contained those 2 files with duplicates so didn't give it much time to think.
I will remove those strings.

use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put use clauses in alphabetical order.

/**
* Map Joomla events → listener methods.
*
* @return array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK the @since tag is obligated in Joomla core docblocks.

$minLabel = $minutes === 1 ? 'min read' : 'mins read';

return '<div class="reading-time-badge">'
. '<span>&#128337; <strong>' . $minutes . '</strong> ' . $minLabel . '</span>'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this too much inline styling?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you suggest removing them to a temp file?

type="text"
label="PLG_CONTENT_TIMEESTIMATION_WPM_LABEL"
description="PLG_CONTENT_TIMEESTIMATION_WPM_DESC"
default="200"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have a default of 200 here and a (fallback) default in the plugin of 50? I'd expect them both the same, a reasonable default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please close #47391 (refering to this new PR).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have a default of 200 here and a (fallback) default in the plugin of 50? I'd expect them both the same, a reasonable default.

Thank you for catching that, I intended to set the default to 200. I thought this would be so fast then changed to 50 and tested. Everything worked fine, I have missed that one.
I will handle it.

{
$text = strip_tags($html);
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
$text = preg_replace('/\s+/', ' ', trim($text));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line? A word in str_word_count() is any sequence of alphabetic characters, so multiple whitespace characters are ignored.

@Hackwar Hackwar closed this Mar 14, 2026
@Hackwar Hackwar reopened this Mar 14, 2026
@Hackwar
Copy link
Member

Hackwar commented Mar 14, 2026

The team decided to discuss this further, thus I'm opening it back up again.

@CSGoat0
Copy link
Author

CSGoat0 commented Mar 14, 2026

You are trying to merge a pull requests from your branch which is joomla 5.4 into 6.2. that's why you have so many changes

Please note that it is expected that you have actually tested to see if the code you are proposing works!!

It works perfectly! I have tested it.
I only let Ai to write me some comments, I have read them and I appreciate any adjustments to it or if I am missing something.

@CSGoat0
Copy link
Author

CSGoat0 commented Mar 14, 2026

The team decided to discuss this further, thus I'm opening it back up again.

Great, thank you!
I hope my contributions would be helpful.

@brianteeman
Copy link
Contributor

Developing a plugin for including in the core is not the same as a standalone extension.

It can't work as you are missing the SQL to install the plugin on new sites and the SQL to install the plugin on upgraded sites.

The language files should be moved where all the other plugin language files are eg administrator/languages/en-gb

Your test instructions to "download and install" are not possible which you would know if you tried to follow the instructions.

Finally you need to fix your branch as already explained

I am sorry but I do not believe your statement that you only used ai to write the comments

@CSGoat0
Copy link
Author

CSGoat0 commented Mar 14, 2026

Developing a plugin for including in the core is not the same as a standalone extension.

It can't work as you are missing the SQL to install the plugin on new sites and the SQL to install the plugin on upgraded sites.

The language files should be moved where all the other plugin language files are eg administrator/languages/en-gb

Your test instructions to "download and install" are not possible which you would know if you tried to follow the instructions.

Finally you need to fix your branch as already explained

I am sorry but I do not believe your statement that you only used ai to write the comments

You can see in my pr that I have mentioned that I have tried to add the language files with the others and it didn't work.
And I have stated carefully that the developer documentation suggests the structure that I have used in this plugin meanwhile looking at the structure of other plugins, I have noticed that they doesn't follow the structure used in the documentation. I also requested a feedback on that so I can fix it.
Thank you for the feedback.

you can find that part under: Notes for Reviewers

About trusting me, don't worry, I know that you might be saying that because you have suffered from vipe coding, well me too.
I know that pain and I won't cause it to you if that's what you mean.

The task from GSOC was also all by myself; I have discussed it and if that was an AI they would have known as I literally used another approach that I have found in the documentation. That's why I have a good understanding of the plugins.
I truly appreciate your feedback. Thank you!

@brianteeman
Copy link
Contributor

Sorry not wasting my time any more. You're not reading

@CSGoat0
Copy link
Author

CSGoat0 commented Mar 14, 2026

Sorry not wasting my time any more. You're not reading

You said that if I read the instructions I wouldn't add the language file in the plugin. I was just explaining that I added that and said in the pr it might be wrong as it goes against the other plugins and I requested a feedback on that from someone with a better understanding as I am new.

Didn't mean that you didn't just explain that, I have read and understood you comment and thanked you for the feedback on lang files (that I requesting in the pr already).

Anyways, I appreciate your time.
Thanks again.

@brianteeman
Copy link
Contributor

You said that if I read the instructions I wouldn't add the language file in the plugin

Nowhere did I say that

@CSGoat0
Copy link
Author

CSGoat0 commented Mar 14, 2026

Your test instructions to "download and install" are not possible which you would know if you tried to follow the instructions.

This line I was referring to, that's why I sometimes refine my comments to give only the meaning I want, of course if you didn't mean that.
Anyways, it doesn't matter. Can we pass that?
I will be happy if we can focus more on friendly constructive feedback that can really help me go advanced in Joomla.

@brianteeman
Copy link
Contributor

I've already given you feedback,you just chose to ignore it.

@CSGoat0
Copy link
Author

CSGoat0 commented Mar 14, 2026

I've already given you feedback,you just chose to ignore it.

My bad, I am sorry.
I am currently working to solve those conflicts and to add the adjustments
mentioned by Mr HermanPeeren.

I will be reaching out soon to understand how to can I fix this: "It can't work as you are missing the SQL to install the plugin on new sites and the SQL to install the plugin on upgraded sites."
Thank you for your time!

@brianteeman
Copy link
Contributor

@brianteeman
Copy link
Contributor

To get a better understanding of what the sql looks like etc when adding a new plugin to Joomla take a look at https://github.com/joomla/joomla-cms/pull/46514/changes

@richard67
Copy link
Member

@CSGoat0 It makes no sense to try to do e the conflicts in this PR. It will not work as you have made this PR here with a branch which is based in the 5.4-dev branch, it you propose the PR for the 6.0-dev branch. This cannot work and cannot be fixed. Please make a new PR based on the 6.2-dev branch. Thanks in advance.

@richard67 richard67 closed this Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NPM Resource Changed This Pull Request can't be tested by Patchtester PR-6.2-dev Unit/System Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.