Skip to content
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

PrettyTime: Use for minute(s) read #288

Open
melloware opened this issue Nov 18, 2024 · 10 comments
Open

PrettyTime: Use for minute(s) read #288

melloware opened this issue Nov 18, 2024 · 10 comments
Labels
enhancement New feature or request

Comments

@melloware
Copy link
Contributor

melloware commented Nov 18, 2024

We should make Minutes Read so its properly formatted using QuarkiVerse PrettyTime: https://github.com/quarkiverse/quarkus-prettytime

@melloware melloware added the enhancement New feature or request label Nov 20, 2024
@melloware
Copy link
Contributor Author

PrettyTime won't help here...

@ia3andy
Copy link
Contributor

ia3andy commented Dec 11, 2024

@melloware I don't remember where but I discussed this with @FroMage and @mkouba and there is something done in Renarde that we could move to Qute Web

@melloware
Copy link
Contributor Author

But those are like PrettyTime they are time "since" like "8 minutes ago" when we need "1 minute" or "4 minutes" to read an article. All those are based on calculating from a point in time.

@mkouba
Copy link

mkouba commented Dec 11, 2024

But those are like PrettyTime they are time "since" like "8 minutes ago" when we need "1 minute" or "4 minutes" to read an article. All those are based on calculating from a point in time.

How do you estimate/determine the value for "1 minute" or "4 minutes"? Is it a duration or what exactly?

@melloware
Copy link
Contributor Author

its magic...

public static Object readTime(Page page) {
        final long count = numberOfWords(page.rawContent());
        return Math.round((float) count / 200);
    }

@ia3andy
Copy link
Contributor

ia3andy commented Dec 11, 2024

This is an average formula based on word counts you can find more info on google.

@mkouba
Copy link

mkouba commented Dec 12, 2024

I see. But then you don't need any library, right?

@TemplateExtension
public static String minutesRead(int minutes) {
   return minutes <= 1 ? "1 minute" : (minutes + " minutes");
}

And in the template something like {page.readTime.minutesRead}?

@melloware melloware reopened this Dec 12, 2024
@melloware
Copy link
Contributor Author

Yep let me submit a PR

@melloware
Copy link
Contributor Author

Ahhh its in the UI code because of IL8N being able to customize it per language. I don't want to hard code "minute" in the template extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants