From 70c68f0a7c476f58925b4c864b7ba27316df271a Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Mon, 1 Aug 2016 02:06:55 -0300 Subject: [PATCH] Open print dialog automatically --- .gitignore | 3 +++ app/views/layouts/crawler.html.erb | 1 + app/views/topics/show.html.erb | 8 ++++++++ lib/topic_view.rb | 5 +++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9dfa377bcf8..f5168681fb4 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,6 @@ bundler_stubs/* vendor/bundle/* *.db + +#ignore jetbrains ide file +*.iml diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb index a2dfcf11a0b..f651d4e21b0 100644 --- a/app/views/layouts/crawler.html.erb +++ b/app/views/layouts/crawler.html.erb @@ -71,4 +71,5 @@ <%= raw SiteCustomization.custom_body_tag(session[:preview_style]) %> <%- end %> + <%= yield :after_body %> diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index b227aa3c620..efeaec35241 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -76,3 +76,11 @@ <% end %> <% content_for(:title) { "#{@topic_view.page_title}" } %> + +<% if @topic_view.print %> + <% content_for :after_body do %> + + <% end %> +<% end %> diff --git a/lib/topic_view.rb b/lib/topic_view.rb index d854c09ac7e..bfef06b1b9d 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -5,7 +5,7 @@ require_dependency 'gaps' class TopicView - attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size + attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size, :print attr_accessor :draft, :draft_key, :draft_sequence, :user_custom_fields, :post_custom_fields def self.slow_chunk_size @@ -41,6 +41,7 @@ class TopicView @user = user @guardian = Guardian.new(@user) @topic = find_topic(topic_id) + @print = options[:print].present? check_and_raise_exceptions options.each do |key, value| @@ -50,7 +51,7 @@ class TopicView @page = 1 if (!@page || @page.zero?) @chunk_size = case when options[:slow_platform] then TopicView.slow_chunk_size - when options[:print] then 1000 + when @print then 1000 else TopicView.chunk_size end @limit ||= @chunk_size