https://github.com/nikkos/retim
Estimate Reading Time
https://github.com/nikkos/retim
elixir estimate minutes phoenix readingtime text words
Last synced: 4 months ago
JSON representation
Estimate Reading Time
- Host: GitHub
- URL: https://github.com/nikkos/retim
- Owner: nikkos
- License: mit
- Created: 2017-03-17T16:44:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-08T00:40:10.000Z (about 8 years ago)
- Last Synced: 2025-10-21T15:51:36.366Z (8 months ago)
- Topics: elixir, estimate, minutes, phoenix, readingtime, text, words
- Language: Elixir
- Size: 297 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Retim
[](https://travis-ci.org/nikkos/retim)
Estimate the reading time of a text or a text file
## Installation
You can donwload retim or you can install it as package, to use it in your projects.
You can found it at [Hex](https://hex.pm/packages/retim).
Also you can add `retim` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:retim, "~> 0.2.3"}]
end
```
## Supported languages:
- English: "en"
- Greek: "gr"
- Italian: "it"
- Spanish: "es"
- Norwegian: "no"
- German: "ge"
- Russian: "ru"
- Portuguese: "pt"
## How to use it
Estimate the reading time of a setence:
```elixir
iex> Retim.count("Hello World")
"1 minute"
```
You can change the default language:
```elixir
iex> Retim.count("Hello World", "it")
"1 minuto"
```
The average reading time per minute is 180 words. If you want to change it you can pass a second argument:
```elixir
iex> Retim.count("Hello World", "en", 120)
"1 minute"
```
If you want to change only the reading time, you need to choose the language or leave the second argument blank:
```elixir
iex> Retim.count("Hello World", "", 150)
```
Read words from a file:
```elixir
iex> Retim.count_file("hello.md")
"4 minutes"
```
Read a file and change the average reading time to 120 words / per minute:
```elixir
iex> Retim.count_file("hello.md", "en", 120)
"7 minutes"
```
## Use Retim in Phoenix
Add retim on your dependencies:
```elixir
defp deps do
[{:phoenix, "~> 1.2.1"},
........
........
{:cowboy, "~> 1.0"},
{:retim, "~> 0.2.3"}]
end
```
Run deps.get on your terminal:
```elixir
mix deps.get
```
### Example
Generate a post:
```elixir
mix phoenix.gen.html Post posts title:string body:text
```
To count the reading time of the body text, add count(@post.body) on your templates(post/show.html.eex):
```elixir
<%= Retim.count(@post.body) %>
```
### Result

To change the language add:
```elixir
<%= Retim.count(@post.body, "es") %>
```
### Result (with spanish)

### To-do
- [x] Add other languages
- [ ] Add new print format (Example: 3 minutes and 10 seconds)