From 9b6f5a9840688a4bf544dabf4548f570862f5f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=B6ln?= Date: Wed, 20 Mar 2019 15:21:36 +0100 Subject: [PATCH 1/6] add Book theme (Liberation fonts need to be in /fonts/ on the server) --- src/book/init.rs | 3 + src/renderer/html_handlebars/hbs_renderer.rs | 3 +- src/theme/book.js | 6 ++ src/theme/css/book.css | 68 ++++++++++++++++++++ src/theme/index.hbs | 3 +- src/theme/mod.rs | 6 ++ 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/theme/css/book.css diff --git a/src/book/init.rs b/src/book/init.rs index 4acf4b52..4726d570 100644 --- a/src/book/init.rs +++ b/src/book/init.rs @@ -134,6 +134,9 @@ impl BookBuilder { let mut general_css = File::create(cssdir.join("general.css"))?; general_css.write_all(theme::GENERAL_CSS)?; + let mut book_css = File::create(cssdir.join("book.css"))?; + book_css.write_all(theme::BOOK_CSS)?; + let mut chrome_css = File::create(cssdir.join("chrome.css"))?; chrome_css.write_all(theme::CHROME_CSS)?; diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index b5ef228d..83a47485 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -119,6 +119,7 @@ impl HtmlHandlebars { write_file(destination, "book.js", &theme.js)?; write_file(destination, "css/general.css", &theme.general_css)?; + write_file(destination, "css/book.css", &theme.book_css)?; write_file(destination, "css/chrome.css", &theme.chrome_css)?; write_file(destination, "css/print.css", &theme.print_css)?; write_file(destination, "css/variables.css", &theme.variables_css)?; @@ -558,7 +559,7 @@ fn fix_code_blocks(html: &str) -> String { let after = &caps[3]; format!( - r#""#, + r#""#, before = before, classes = classes, after = after diff --git a/src/theme/book.js b/src/theme/book.js index 4640e8fc..9d5cc032 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -331,6 +331,12 @@ function playpen_text(playpen) { stylesheets.tomorrowNight.disabled = true; stylesheets.highlight.disabled = true; + ace_theme = "ace/theme/tomorrow_night"; + } else if (theme == 'classic') { + stylesheets.ayuHighlight.disabled = true; + stylesheets.tomorrowNight.disabled = true; + stylesheets.highlight.disabled = true; + ace_theme = "ace/theme/tomorrow_night"; } else { stylesheets.ayuHighlight.disabled = true; diff --git a/src/theme/css/book.css b/src/theme/css/book.css new file mode 100644 index 00000000..a7f24a26 --- /dev/null +++ b/src/theme/css/book.css @@ -0,0 +1,68 @@ +@font-face { + font-family: "Liberation Serif"; + src: url("/fonts/LiberationSerif-Regular.ttf"); + font-weight: normal; +} +@font-face { + font-family: "Liberation Serif"; + src: url("/fonts/LiberationSerif-Bold.ttf"); + font-weight: bold; +} +@font-face { + font-family: "Liberation Serif"; + src: url("/fonts/LiberationSerif-Italic.ttf"); + font-style: italic; +} +@font-face { + font-family: "Liberation Mono"; + src: url("/fonts/LiberationMono-Regular.ttf"); + font-weight: normal; +} + +body { + font-family: "Liberation Serif", serif; +} +p { + text-align: justify; + line-height: 1.25em; +} +code { + font-family: "Liberation Mono", monospace; +} +pre { + margin-left: 2em; +} +pre pre { + margin-left: 0; +} +pre.playpen > div.buttons { + float: right; + height: 0; +} +em { + font-style: italic; +} +h3::before { + content: "¶"; + width: 1em; + display: inline-block; + margin-left: -1em; +} +h4::before { + content: "§"; + width: 1em; + display: inline-block; + margin-left: -1em; +} +#menu-bar-sticky-container { + background-color: rgba(255, 255, 255, 0.8) !important; +} + +@media print { + .bottons { + display: none; + } + body { + font-size: 11pt; + } +} diff --git a/src/theme/index.hbs b/src/theme/index.hbs index bfe4283a..8ecf20c8 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -13,6 +13,7 @@ + @@ -24,7 +25,6 @@ - {{#each additional_css}} @@ -102,6 +102,7 @@
  • +
  • {{#if search_enabled}}