From 0d6adc5fc9d1e49e8184173e9a938aeee19134af Mon Sep 17 00:00:00 2001 From: Mathieu David Date: Wed, 13 Sep 2017 22:17:23 +0200 Subject: [PATCH] Fix the issue with pages named print not at the root --- src/renderer/html_handlebars/hbs_renderer.rs | 1 + src/theme/book.css | 15 ++++++++++----- src/theme/book.js | 10 ---------- src/theme/index.hbs | 12 +++++++++++- src/theme/stylus/themes/base.styl | 3 ++- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index f33352c4..999dda50 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -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")))); diff --git a/src/theme/book.css b/src/theme/book.css index abf78685..e2f03e65 100644 --- a/src/theme/book.css +++ b/src/theme/book.css @@ -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, diff --git a/src/theme/book.js b/src/theme/book.js index 4c5108b8..d7f0e690 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -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) { diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 9f735e6c..3b4dbd12 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -88,7 +88,9 @@

{{ book_title }}

- + + +
@@ -156,6 +158,14 @@ {{/if}} + {{#if is_print}} + + {{/if}} + diff --git a/src/theme/stylus/themes/base.styl b/src/theme/stylus/themes/base.styl index 272a3f3f..7bc8d713 100644 --- a/src/theme/stylus/themes/base.styl +++ b/src/theme/stylus/themes/base.styl @@ -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 }