From 599e47f1f1d2fee3c1c101413fbc40b3ddf2cb12 Mon Sep 17 00:00:00 2001 From: Jason Liquorish Date: Sat, 13 Oct 2018 12:17:33 +0100 Subject: [PATCH] Initial implementation of a git repository button --- src/config.rs | 2 ++ src/renderer/html_handlebars/hbs_renderer.rs | 4 ++++ src/theme/css/chrome.css | 5 ++++- src/theme/index.hbs | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 655d3da0..736795dd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -440,6 +440,8 @@ pub struct HtmlConfig { pub no_section_label: bool, /// Search settings. If `None`, the default will be used. pub search: Option, + /// Git repository url. If 'None', the git button will not be shown. + pub git_repository_url: Option, } impl HtmlConfig { diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 3f87ba4d..ebf20feb 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -454,6 +454,10 @@ fn make_data( ) } + if let Some(ref git_repository_url) = html_config.git_repository_url { + data.insert("git-repository-url".to_owned(), json!(git_repository_url)); + } + let mut chapters = vec![]; for item in book.iter() { diff --git a/src/theme/css/chrome.css b/src/theme/css/chrome.css index 82883e6b..0ab16869 100644 --- a/src/theme/css/chrome.css +++ b/src/theme/css/chrome.css @@ -63,9 +63,12 @@ a > .hljs { margin: 0; } -#print-button { +.right-buttons { margin: 0 15px; } +.right-buttons a { + text-decoration: none; +} html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-container { transform: translateY(-60px); diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 982c2f7d..21c0b0a4 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -113,6 +113,11 @@ + {{#if git-repository-url}} + + + + {{/if}}