Merge pull request #4492 from xfalcox/print-style

Add some styling to print redux version
This commit is contained in:
Jeff Atwood 2016-10-12 20:37:32 +02:00 committed by GitHub
commit 6adfe1af47
3 changed files with 13 additions and 42 deletions

View File

@ -10,46 +10,6 @@
<%- end %> <%- end %>
<%= render_google_universal_analytics_code %> <%= render_google_universal_analytics_code %>
<%= yield :head %> <%= yield :head %>
<style>
header img {
max-width: 90% !important;
padding-bottom: 10px;
}
img { max-width: 100%; width: auto; height: auto; }
#main-outlet > div {
margin-bottom: 15px;
}
footer nav a {
margin-right: 15px;
}
footer nav {
line-height: 30px;
}
body {
max-width: 98%;
padding-left: 1%;
}
.topic-list > div > a {
margin-right: 10px;
}
.topic-list > div .posts {
margin-left: 10px;
}
.topic-list > div {
margin-bottom: 15px;
}
body img.emoji {
width: 20px;
height: 20px;
vertical-align: middle;
}
</style>
</head> </head>
<body> <body>
<%- unless customization_disabled? %> <%- unless customization_disabled? %>

View File

@ -69,6 +69,17 @@
<% if @topic_view.print %> <% if @topic_view.print %>
<% content_for :after_body do %> <% content_for :after_body do %>
<%- if rtl? %>
<%= DiscourseStylesheets.stylesheet_link_tag(mobile_view? ? :mobile_rtl : :desktop_rtl, 'print') %>
<%- else %>
<%= DiscourseStylesheets.stylesheet_link_tag(mobile_view? ? :mobile : :desktop, 'print') %>
<%- end %>
<style media="print">
/* For readability */
a, a:visited {
color: #0088cc !important;
}
</style>
<script> <script>
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
window.print(); window.print();

View File

@ -14,7 +14,7 @@ class DiscourseStylesheets
@cache ||= DistributedCache.new("discourse_stylesheet") @cache ||= DistributedCache.new("discourse_stylesheet")
end end
def self.stylesheet_link_tag(target = :desktop) def self.stylesheet_link_tag(target = :desktop, media = 'all')
tag = cache[target] tag = cache[target]
@ -24,7 +24,7 @@ class DiscourseStylesheets
builder = self.new(target) builder = self.new(target)
builder.compile unless File.exists?(builder.stylesheet_fullpath) builder.compile unless File.exists?(builder.stylesheet_fullpath)
builder.ensure_digestless_file builder.ensure_digestless_file
tag = %[<link href="#{Rails.env.production? ? builder.stylesheet_cdnpath : builder.stylesheet_relpath_no_digest + '?body=1'}" media="all" rel="stylesheet" />] tag = %[<link href="#{Rails.env.production? ? builder.stylesheet_cdnpath : builder.stylesheet_relpath_no_digest + '?body=1'}" media="#{media}" rel="stylesheet" />]
cache[target] = tag cache[target] = tag