From 51ced7aeaecfc9af7e05636fc74455d08827f4d3 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Wed, 30 Dec 2015 12:15:17 +0530 Subject: [PATCH] make site setting for read time word count per minute --- app/assets/javascripts/discourse/models/topic.js.es6 | 3 +-- config/locales/server.en.yml | 2 ++ config/site_settings.yml | 4 ++++ lib/topic_view.rb | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/models/topic.js.es6 b/app/assets/javascripts/discourse/models/topic.js.es6 index bbbd6886d09..c7c8679469b 100644 --- a/app/assets/javascripts/discourse/models/topic.js.es6 +++ b/app/assets/javascripts/discourse/models/topic.js.es6 @@ -228,8 +228,7 @@ const Topic = RestModel.extend({ const wordCount = this.get('word_count'); if (!wordCount) return; - // Avg for 500 words per minute when you account for skimming - return Math.floor(wordCount / 500.0); + return Math.floor(wordCount / Discourse.SiteSettings.read_time_word_count); }.property('word_count'), toggleBookmark() { diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 0787b73fa32..258770c833c 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1169,6 +1169,8 @@ en: automatically_unpin_topics: "Automatically unpin topics when the user reaches the bottom." + read_time_word_count: "Word count per minute for calculating estimated reading time." + full_name_required: "Full name is a required field of a user's profile." enable_names: "Show the user's full name on their profile, user card, and emails. Disable to hide full name everywhere." display_name_on_posts: "Show a user's full name on their posts in addition to their @username." diff --git a/config/site_settings.yml b/config/site_settings.yml index 69523948f21..ff7f6173c6c 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -1029,6 +1029,10 @@ uncategorized: default: true client: true + read_time_word_count: + default: 500 + client: true + user_preferences: default_email_digest_frequency: enum: 'DigestEmailSiteSetting' diff --git a/lib/topic_view.rb b/lib/topic_view.rb index 9f9cfb41f53..7db989d45e8 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -161,7 +161,7 @@ class TopicView def read_time return nil if @post_number.present? && @post_number.to_i != 1 # only show for topic URLs - (@topic.word_count/500).floor if @topic.word_count + (@topic.word_count/SiteSetting.read_time_word_count).floor if @topic.word_count end def like_count