Merge pull request #889 from s3bk/master

new "Book" theme
This commit is contained in:
Dylan DPC 2019-05-04 17:45:37 +02:00 committed by GitHub
commit b30b58b565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 3 deletions

View File

@ -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)?;

View File

@ -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)?;
@ -552,7 +553,7 @@ fn fix_code_blocks(html: &str) -> String {
let after = &caps[3];
format!(
r#"<code{before}class="{classes}"{after}>"#,
r#"<code{before}class="block {classes}"{after}>"#,
before = before,
classes = classes,
after = after

View File

@ -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 == 'book') {
stylesheets.ayuHighlight.disabled = true;
stylesheets.tomorrowNight.disabled = true;
stylesheets.highlight.disabled = true;
ace_theme = "ace/theme/tomorrow_night";
} else {
stylesheets.ayuHighlight.disabled = true;

65
src/theme/css/book.css Normal file
View File

@ -0,0 +1,65 @@
body {
font-family: "Source Serif Pro", serif;
}
p {
text-align: justify;
line-height: 1.25em;
}
code {
font-family: "Source Code Pro", monospace;
padding: 0 !important;
}
code:not(.block) {
padding: 0 0 1pt 0 !important;
}
code:not(.block)::before {
content: '';
}
code:not(.block)::after {
content: '';
}
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;
}
.left-buttons {
position: absolute;
}
.right-buttons {
position: absolute;
right: 0;
}
#menu-bar-sticky-container {
background-color: rgba(255, 255, 255, 0.8) !important;
}
@media print {
.menu-bar, .buttons {
display: none;
}
body {
font-size: 11pt;
}
}

View File

@ -13,18 +13,18 @@
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
<link rel="stylesheet" href="{{ path_to_root }}css/book.css">
<link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro|Source+Serif+Pro" rel="stylesheet">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="{{ path_to_root }}highlight.css">
<link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
<link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
<!-- Custom theme stylesheets -->
{{#each additional_css}}
<link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
@ -105,6 +105,7 @@
<li role="none"><button role="menuitem" class="theme" id="coal">{{ theme_option "Coal" }}</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">{{ theme_option "Navy" }}</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">{{ theme_option "Ayu" }}</button></li>
<li role="none"><button role="menuitem" class="theme" id="book">{{ theme_option "Book" }}</button></li>
</ul>
{{#if search_enabled}}
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">

View File

@ -15,6 +15,7 @@ pub static INDEX: &'static [u8] = include_bytes!("index.hbs");
pub static HEADER: &'static [u8] = include_bytes!("header.hbs");
pub static CHROME_CSS: &'static [u8] = include_bytes!("css/chrome.css");
pub static GENERAL_CSS: &'static [u8] = include_bytes!("css/general.css");
pub static BOOK_CSS: &'static [u8] = include_bytes!("css/book.css");
pub static PRINT_CSS: &'static [u8] = include_bytes!("css/print.css");
pub static VARIABLES_CSS: &'static [u8] = include_bytes!("css/variables.css");
pub static FAVICON: &'static [u8] = include_bytes!("favicon.png");
@ -49,6 +50,7 @@ pub struct Theme {
pub header: Vec<u8>,
pub chrome_css: Vec<u8>,
pub general_css: Vec<u8>,
pub book_css: Vec<u8>,
pub print_css: Vec<u8>,
pub variables_css: Vec<u8>,
pub favicon: Vec<u8>,
@ -80,6 +82,7 @@ impl Theme {
(theme_dir.join("book.js"), &mut theme.js),
(theme_dir.join("css/chrome.css"), &mut theme.chrome_css),
(theme_dir.join("css/general.css"), &mut theme.general_css),
(theme_dir.join("css/book.css"), &mut theme.book_css),
(theme_dir.join("css/print.css"), &mut theme.print_css),
(
theme_dir.join("css/variables.css"),
@ -121,6 +124,7 @@ impl Default for Theme {
header: HEADER.to_owned(),
chrome_css: CHROME_CSS.to_owned(),
general_css: GENERAL_CSS.to_owned(),
book_css: BOOK_CSS.to_owned(),
print_css: PRINT_CSS.to_owned(),
variables_css: VARIABLES_CSS.to_owned(),
favicon: FAVICON.to_owned(),
@ -176,6 +180,7 @@ mod tests {
"favicon.png",
"css/chrome.css",
"css/general.css",
"css/book.css",
"css/print.css",
"css/variables.css",
"book.js",
@ -208,6 +213,7 @@ mod tests {
highlight_css: Vec::new(),
tomorrow_night_css: Vec::new(),
ayu_highlight_css: Vec::new(),
book_css: Vec::new(),
highlight_js: Vec::new(),
clipboard_js: Vec::new(),
};