Fix the issue with pages named print not at the root

This commit is contained in:
Mathieu David 2017-09-13 22:17:23 +02:00
parent 0226da91e4
commit 0d6adc5fc9
5 changed files with 24 additions and 17 deletions

View File

@ -220,6 +220,7 @@ impl HtmlHandlebars {
// Make sure that the Print chapter does not display the title from
// the last rendered chapter by removing it from its context
data.remove("title");
data.insert("is_print".to_owned(), json!(true));
data.insert("path".to_owned(), json!("print.md"));
data.insert("content".to_owned(), json!(print_content));
data.insert("path_to_root".to_owned(), json!(utils::fs::path_to_root(Path::new("print.md"))));

View File

@ -351,7 +351,8 @@ table thead td {
.light .nav-chapters,
.light .nav-chapters:visited,
.light .mobile-nav-chapters,
.light .mobile-nav-chapters:visited {
.light .mobile-nav-chapters:visited,
.light .menu-bar a i {
color: #ccc;
}
.light .menu-bar i:hover,
@ -471,7 +472,8 @@ table thead td {
.coal .nav-chapters,
.coal .nav-chapters:visited,
.coal .mobile-nav-chapters,
.coal .mobile-nav-chapters:visited {
.coal .mobile-nav-chapters:visited,
.coal .menu-bar a i {
color: #43484d;
}
.coal .menu-bar i:hover,
@ -591,7 +593,8 @@ table thead td {
.navy .nav-chapters,
.navy .nav-chapters:visited,
.navy .mobile-nav-chapters,
.navy .mobile-nav-chapters:visited {
.navy .mobile-nav-chapters:visited,
.navy .menu-bar a i {
color: #737480;
}
.navy .menu-bar i:hover,
@ -711,7 +714,8 @@ table thead td {
.rust .nav-chapters,
.rust .nav-chapters:visited,
.rust .mobile-nav-chapters,
.rust .mobile-nav-chapters:visited {
.rust .mobile-nav-chapters:visited,
.rust .menu-bar a i {
color: #737480;
}
.rust .menu-bar i:hover,
@ -831,7 +835,8 @@ table thead td {
.ayu .nav-chapters,
.ayu .nav-chapters:visited,
.ayu .mobile-nav-chapters,
.ayu .mobile-nav-chapters:visited {
.ayu .mobile-nav-chapters:visited,
.ayu .menu-bar a i {
color: #737480;
}
.ayu .menu-bar i:hover,

View File

@ -83,16 +83,6 @@ $( document ).ready(function() {
}
// Print button
$("#print-button").click(function(){
var printWindow = window.open("print.html");
});
if( url.substring(url.lastIndexOf('/')+1) == "print.html" ) {
window.print();
}
// Theme button
$("#theme-toggle").click(function(){
if($('.theme-popup').length) {

View File

@ -88,7 +88,9 @@
<h1 class="menu-title">{{ book_title }}</h1>
<div class="right-buttons">
<i id="print-button" class="fa fa-print" title="Print this book"></i>
<a href="print.html">
<i id="print-button" class="fa fa-print" title="Print this book"></i>
</a>
</div>
</div>
@ -156,6 +158,14 @@
<script src="{{ theme_tomorrow_night_js }}" type="text/javascript" charset="utf-8"></script>
{{/if}}
{{#if is_print}}
<script>
$(document).ready(function() {
window.print();
})
</script>
{{/if}}
<script src="highlight.js"></script>
<script src="book.js"></script>
</body>

View File

@ -38,7 +38,8 @@
.nav-chapters,
.nav-chapters:visited,
.mobile-nav-chapters,
.mobile-nav-chapters:visited {
.mobile-nav-chapters:visited,
.menu-bar a i {
color: $icons
}