From 5c1e61cf0f84b6522a4c0d02a2c771ad2857339d Mon Sep 17 00:00:00 2001 From: Sneha Mishra <33183263+Tlazypanda@users.noreply.github.com> Date: Mon, 21 Sep 2020 10:24:02 -0700 Subject: [PATCH] fix card page break and move to print layout (#8415) --- app/assets/stylesheets/print_new.css | 2 +- app/controllers/notes_controller.rb | 2 +- app/controllers/wiki_controller.rb | 2 +- app/views/layouts/print.html.erb | 121 +++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 app/views/layouts/print.html.erb diff --git a/app/assets/stylesheets/print_new.css b/app/assets/stylesheets/print_new.css index a27fdbc0de..a9225c3ce9 100644 --- a/app/assets/stylesheets/print_new.css +++ b/app/assets/stylesheets/print_new.css @@ -37,7 +37,7 @@ svg { break-before: avoid-page; } -img { +img, .card { page-break-before: avoid; /* 'always,' 'avoid,' 'left,' 'inherit,' or 'right' */ page-break-after: avoid; /* 'always,' 'avoid,' 'left,' 'inherit,' or 'right' */ page-break-inside: avoid; /* or 'auto' */ diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 47134833a2..3070a8bec8 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -75,7 +75,7 @@ def print if @node impressionist(@node, 'print', unique: [:ip_address]) - render layout: false + render layout: "print" else page_not_found diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 916e19e1e4..ea10b0d4be 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -99,7 +99,7 @@ def print if @node impressionist(@node, 'print', unique: [:ip_address]) - render layout: false + render layout: "print" else page_not_found diff --git a/app/views/layouts/print.html.erb b/app/views/layouts/print.html.erb new file mode 100644 index 0000000000..b74c5a40c5 --- /dev/null +++ b/app/views/layouts/print.html.erb @@ -0,0 +1,121 @@ + + + + + 🎈 Public Lab<%= ": "+(@title || params[:action].capitalize) %> + + <% if @node && @node.body %> + + <% else %> + + <% end %> + <%= action_cable_meta_tag %> + + + + + + <%= javascript_include_tag "application" %> + + + + + <% if @node && @node.has_tag('style:fancy') %> + <%= stylesheet_link_tag "fancy", :media => "all" %> + <% end %> + <%= stylesheet_link_tag "print", :media => "print" %> + + + + + <%= csrf_meta_tags %> + + + <% if current_user %> + <%= javascript_include_tag "cable" %> + <% end %> + + <% if @node && @node.body %> + + + + + + + <% if @node.main_image %> + + + <% elsif scraped_image = @node.scraped_image %> + + + <% end %> + + <% end %> + + + +
+ + <%= yield(:head) %> + + + + <% cache('feature_header', skip_digest: true) do %> + <%= feature("header") %> + <% end %> + + <%= yield(:head) %> + + + + + + + + + +
+
+
+ + <%= yield %> + +
+
+ + + +