From acc70cc3de30f316035236a93a7a826b43063441 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Thu, 4 Aug 2016 01:58:19 -0300 Subject: [PATCH] SiteSetting, admin passtrough, CSS, hide on mobile --- .../discourse/views/topic-footer-main-buttons.js.es6 | 5 ++++- app/controllers/topics_controller.rb | 3 ++- app/views/layouts/crawler.html.erb | 5 +++++ config/locales/server.en.yml | 2 ++ config/site_settings.yml | 4 ++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 b/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 index 3f2748a5e8e..1dac46feb5b 100644 --- a/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 @@ -7,6 +7,7 @@ export default ContainerView.extend({ @on('init') createButtons() { const mobileView = this.site.mobileView; + const { siteSettings } = this; const topic = this.get('topic'); @@ -32,7 +33,9 @@ export default ContainerView.extend({ this.attachViewClass('invite-reply-button'); } - this.attachViewClass('print-button'); + if (!mobileView && siteSettings.allow_print_page) { + this.attachViewClass('print-button'); + } if (topic.get('isPrivateMessage')) { this.attachViewClass('archive-button'); diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 916a27170ad..d2c66fd9451 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -70,8 +70,9 @@ class TopicsController < ApplicationController end if opts[:print] + raise Discourse::InvalidAccess unless SiteSetting.allow_print_page begin - RateLimiter.new(current_user, "print-topic-per-hour", 10, 1.hour).performed! + RateLimiter.new(current_user, "print-topic-per-hour", 10, 1.hour).performed! unless current_user.admin? rescue RateLimiter::LimitExceeded render_json_error(I18n.t("rate_limiter.slow_down")) end diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb index f651d4e21b0..0446c81f0bf 100644 --- a/app/views/layouts/crawler.html.erb +++ b/app/views/layouts/crawler.html.erb @@ -43,6 +43,11 @@ .topic-list > div { margin-bottom: 15px; } + body img.emoji { + width: 20px; + height: 20px; + vertical-align: middle; + } diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 649f99fe9af..a9bc245b305 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1312,6 +1312,8 @@ en: topic_page_title_includes_category: "Topic page title includes the category name." + allow_print_page: "Enable a special topic page for printing" + 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 3a80594f62b..ee36b1c02b4 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -1220,6 +1220,10 @@ uncategorized: topic_page_title_includes_category: true + allow_print_page: + default: true + client: true + user_preferences: default_email_digest_frequency: enum: 'DigestEmailSiteSetting'