FEATURE: navigate to first post and auto bump category settings

### navigate_to_first_post_after_read setting for categories

When enabled on categories logged on users will return to OP after
reading the entire category. (useful for documentation categories)

### num_auto_bump_daily

Set a number of topics that will automatically bump daily on a category.

- Every 15 minutes we will check if any category has this setting
- Categories with the setting are shuffled
- We exclude pinned, closed, category description and archived topics
- Maximum of 1 topic for the list of categories is bumped till limit reached per category
- We always try to bump oldest first
- Limit is elastic using a RateLimiter that ensures that we only bump N per day

Also some minor organisation on category settings

Froze strings on category.rb
This commit is contained in:
Sam
2018-07-16 18:10:35 +10:00
parent 259d16a781
commit ac0053f491
13 changed files with 241 additions and 92 deletions
@@ -115,7 +115,10 @@ const Category = RestModel.extend({
default_view: this.get("default_view"),
subcategory_list_style: this.get("subcategory_list_style"),
default_top_period: this.get("default_top_period"),
minimum_required_tags: this.get("minimum_required_tags")
minimum_required_tags: this.get("minimum_required_tags"),
navigate_to_first_post_after_read: this.get(
"navigate_to_first_post_after_read"
)
},
type: id ? "PUT" : "POST"
});
@@ -212,11 +212,18 @@ const Topic = RestModel.extend({
}.property("url", "last_read_post_number"),
lastUnreadUrl: function() {
const postNumber = Math.min(
this.get("last_read_post_number") + 1,
this.get("highest_post_number")
);
return this.urlForPostNumber(postNumber);
const highest = this.get("highest_post_number");
const lastRead = this.get("last_read_post_number");
if (highest <= lastRead) {
if (this.get("category.navigate_to_first_post_after_read")) {
return this.urlForPostNumber(1);
} else {
return this.urlForPostNumber(lastRead + 1);
}
} else {
return this.urlForPostNumber(lastRead + 1);
}
}.property("url", "last_read_post_number", "highest_post_number"),
lastPostUrl: function() {
@@ -1,3 +1,19 @@
{{#if showPositionInput}}
<section class='field position-fields'>
<label>
{{i18n 'category.position'}}
{{text-field value=category.position class="position-input" type="number"}}
</label>
</section>
{{/if}}
{{#unless showPositionInput}}
<section class='field'>
{{i18n 'category.position_disabled'}}
<a href="/admin/site_settings/category/basic">{{i18n 'category.position_disabled_click'}}</a>
</section>
{{/unless}}
<section class='field'>
<div class="control-group">
<label>
@@ -74,14 +90,21 @@
</div>
</section>
<section class="field num-featured-topics-fields">
<section class="field">
<label>
{{#if category.parent_category_id}}
{{i18n "category.subcategory_num_featured_topics"}}
{{else}}
{{i18n "category.num_featured_topics"}}
{{/if}}
{{text-field value=category.num_featured_topics}}
{{text-field value=category.num_featured_topics type="number"}}
</label>
</section>
<section class="field">
<label>
{{i18n "category.num_auto_bump_daily"}}
{{text-field value=category.custom_fields.num_auto_bump_daily type="number"}}
</label>
</section>
@@ -92,6 +115,13 @@
</label>
</section>
<section class="field">
<label>
{{input type="checkbox" checked=category.navigate_to_first_post_after_read}}
{{i18n "category.navigate_to_first_post_after_read"}}
</label>
</section>
{{#if siteSettings.topic_featured_link_enabled}}
<section class='field'>
<div class="allowed-topic-featured-link-category">
@@ -129,29 +159,6 @@
{{plugin-outlet name="category-email-in" args=(hash category=category)}}
{{/if}}
{{#if showPositionInput}}
<section class='field position-fields'>
<label>
{{i18n 'category.position'}}
{{text-field value=category.position class="position-input"}}
</label>
</section>
{{/if}}
{{#unless emailInEnabled}}
<section class='field'>
{{i18n 'category.email_in_disabled'}}
<a href="/admin/site_settings/category/email">{{i18n 'category.email_in_disabled_click'}}</a>
</section>
{{/unless}}
{{#unless showPositionInput}}
<section class='field'>
{{i18n 'category.position_disabled'}}
<a href="/admin/site_settings/category/basic">{{i18n 'category.position_disabled_click'}}</a>
</section>
{{/unless}}
{{#if siteSettings.tagging_enabled}}
<section class='field minimum-required-tags'>
<label>
@@ -176,3 +183,10 @@
</section>
{{plugin-outlet name="category-custom-settings" args=(hash category=category)}}
{{#unless emailInEnabled}}
<section class='field'>
{{i18n 'category.email_in_disabled'}}
<a href="/admin/site_settings/category/email">{{i18n 'category.email_in_disabled_click'}}</a>
</section>
{{/unless}}
@@ -369,12 +369,8 @@
}
.edit-category-modal {
.future-date-input,
.num-featured-topics-fields,
.position-fields {
input[type="text"] {
width: 50px;
}
input[type="number"] {
width: 50px;
}
.subcategory-list-style-field {