Adjusts from review
This commit is contained in:
parent
acc70cc3de
commit
2a5a0bebb3
|
@ -134,9 +134,10 @@ const Topic = RestModel.extend({
|
||||||
return this.get('url') + (user ? '?u=' + user.get('username_lower') : '');
|
return this.get('url') + (user ? '?u=' + user.get('username_lower') : '');
|
||||||
}.property('url'),
|
}.property('url'),
|
||||||
|
|
||||||
printUrl: function(){
|
@computed('url')
|
||||||
return this.get('url') + '/print';
|
printUrl(url) {
|
||||||
}.property('url'),
|
return url + '/print';
|
||||||
|
},
|
||||||
|
|
||||||
url: function() {
|
url: function() {
|
||||||
let slug = this.get('slug') || '';
|
let slug = this.get('slug') || '';
|
||||||
|
|
|
@ -7,7 +7,6 @@ export default ContainerView.extend({
|
||||||
@on('init')
|
@on('init')
|
||||||
createButtons() {
|
createButtons() {
|
||||||
const mobileView = this.site.mobileView;
|
const mobileView = this.site.mobileView;
|
||||||
const { siteSettings } = this;
|
|
||||||
|
|
||||||
const topic = this.get('topic');
|
const topic = this.get('topic');
|
||||||
|
|
||||||
|
@ -33,7 +32,7 @@ export default ContainerView.extend({
|
||||||
this.attachViewClass('invite-reply-button');
|
this.attachViewClass('invite-reply-button');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mobileView && siteSettings.allow_print_page) {
|
if (!mobileView && this.siteSettings.max_prints_per_hour_per_user > 0) {
|
||||||
this.attachViewClass('print-button');
|
this.attachViewClass('print-button');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,9 +70,9 @@ class TopicsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts[:print]
|
if opts[:print]
|
||||||
raise Discourse::InvalidAccess unless SiteSetting.allow_print_page
|
raise Discourse::InvalidAccess unless SiteSetting.max_prints_per_hour_per_user > 0
|
||||||
begin
|
begin
|
||||||
RateLimiter.new(current_user, "print-topic-per-hour", 10, 1.hour).performed! unless current_user.admin?
|
RateLimiter.new(current_user, "print-topic-per-hour", 10, 1.hour).performed! unless @guardian.is_admin?
|
||||||
rescue RateLimiter::LimitExceeded
|
rescue RateLimiter::LimitExceeded
|
||||||
render_json_error(I18n.t("rate_limiter.slow_down"))
|
render_json_error(I18n.t("rate_limiter.slow_down"))
|
||||||
end
|
end
|
||||||
|
|
|
@ -1312,7 +1312,7 @@ en:
|
||||||
|
|
||||||
topic_page_title_includes_category: "Topic page title includes the category name."
|
topic_page_title_includes_category: "Topic page title includes the category name."
|
||||||
|
|
||||||
allow_print_page: "Enable a special topic page for printing"
|
max_prints_per_hour_per_user: "Maximum number of /print page impressions (set to 0 to disable)"
|
||||||
|
|
||||||
full_name_required: "Full name is a required field of a user's profile."
|
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."
|
enable_names: "Show the user's full name on their profile, user card, and emails. Disable to hide full name everywhere."
|
||||||
|
|
|
@ -909,6 +909,9 @@ rate_limits:
|
||||||
client: true
|
client: true
|
||||||
shadowed_by_global: true
|
shadowed_by_global: true
|
||||||
default: 0
|
default: 0
|
||||||
|
max_prints_per_hour_per_user:
|
||||||
|
default: 0
|
||||||
|
client: true
|
||||||
|
|
||||||
developer:
|
developer:
|
||||||
force_hostname:
|
force_hostname:
|
||||||
|
@ -1220,9 +1223,6 @@ uncategorized:
|
||||||
|
|
||||||
topic_page_title_includes_category: true
|
topic_page_title_includes_category: true
|
||||||
|
|
||||||
allow_print_page:
|
|
||||||
default: true
|
|
||||||
client: true
|
|
||||||
|
|
||||||
user_preferences:
|
user_preferences:
|
||||||
default_email_digest_frequency:
|
default_email_digest_frequency:
|
||||||
|
|
|
@ -51,7 +51,7 @@ class TopicView
|
||||||
@page = 1 if (!@page || @page.zero?)
|
@page = 1 if (!@page || @page.zero?)
|
||||||
@chunk_size = case
|
@chunk_size = case
|
||||||
when options[:slow_platform] then TopicView.slow_chunk_size
|
when options[:slow_platform] then TopicView.slow_chunk_size
|
||||||
when @print then 1000
|
when @print then TopicView.print_chunk_size
|
||||||
else TopicView.chunk_size
|
else TopicView.chunk_size
|
||||||
end
|
end
|
||||||
@limit ||= @chunk_size
|
@limit ||= @chunk_size
|
||||||
|
|
Loading…
Reference in New Issue