mirror of
https://github.com/lise-henry/crowbook
synced 2024-05-25 02:46:08 +02:00
Add html.footer option
This commit is contained in:
parent
412ce721ef
commit
abb05a224e
|
@ -1,4 +1,6 @@
|
|||
menu: Table of contents
|
||||
|
||||
display_all: Display all chapters
|
||||
display_one: Display one chapter
|
||||
display_one: Display one chapter
|
||||
|
||||
generated_by_crowbook: 'Generated by <a href = "https://github.com/lise-henry/crowbook">Crowbook</a>'
|
|
@ -1,4 +1,6 @@
|
|||
menu: Table des matières
|
||||
|
||||
display_all: Afficher tous les chapitres
|
||||
display_one: "N'afficher qu'un chapitre"
|
||||
display_one: "N'afficher qu'un chapitre"
|
||||
|
||||
generated_by_crowbook: 'Généré par <a href = "https://github.com/lise-henry/crowbook">Crowbook</a>'
|
|
@ -40,6 +40,8 @@ html.print_css:path # Path of a media print stylesheet for HTML
|
|||
html.script:path # Path of a javascript file
|
||||
html.display_chapter:bool:false # Display only one chapter at a time (with option to display all)
|
||||
html.side_notes:bool:false # Display footnotes as side notes in HTML/Epub (experimental)
|
||||
html.crowbook_link:bool:true # Display a 'Generated by crowbook' at the end of the document
|
||||
html.footer:str # Custom footer to display at the end of HTML file(s)
|
||||
|
||||
# Multifile HTML options
|
||||
html_dir.script:path # Path of a javascript file
|
||||
|
|
|
@ -25,6 +25,7 @@ use resource_handler::ResourceHandler;
|
|||
use std::borrow::Cow;
|
||||
use templates::{html};
|
||||
use renderer::Renderer;
|
||||
use lang;
|
||||
|
||||
use mustache;
|
||||
use rustc_serialize::base64::{self, ToBase64};
|
||||
|
@ -243,6 +244,7 @@ impl<'a> HtmlRenderer<'a> {
|
|||
.insert_str("print_style", self.book.get_template("html.print_css").unwrap())
|
||||
.insert_str("menu_svg", menu_svg)
|
||||
.insert_str("book_svg", book_svg)
|
||||
.insert_str("footer", self.get_footer())
|
||||
.insert_str("pages_svg", pages_svg);
|
||||
if self.book.options.get_bool("html.highlight_code") == Ok(true) {
|
||||
let highlight_js = try!(self.book.get_template("html.highlight.js"))
|
||||
|
@ -327,6 +329,26 @@ impl<'a> HtmlRenderer<'a> {
|
|||
res.push_str("</table>");
|
||||
}
|
||||
}
|
||||
|
||||
/// Renders a footer, which can include a "Generated by Crowboook" link
|
||||
/// or a customized text
|
||||
pub fn get_footer(&self) -> String {
|
||||
let content =
|
||||
if let Ok(footer) = self.book.options.get_str("html.footer") {
|
||||
footer.to_owned()
|
||||
} else {
|
||||
if self.book.options.get_bool("html.crowbook_link") == Ok(true) {
|
||||
lang::get_str(self.book.options.get_str("lang").unwrap(), "generated_by_crowbook")
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
};
|
||||
if content.is_empty() {
|
||||
content
|
||||
} else {
|
||||
format!("<div id = \"footer\"><p>{}</p></div>", content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Renderer for HtmlRenderer<'a> {
|
||||
|
|
|
@ -172,6 +172,7 @@ impl<'a> HtmlDirRenderer<'a> {
|
|||
.insert_str("toc", toc.clone())
|
||||
.insert_str("prev_chapter", prev_chapter)
|
||||
.insert_str("next_chapter", next_chapter)
|
||||
.insert_str("footer", self.html.get_footer())
|
||||
.insert_str("script", self.html.book.get_template("html_dir.script").unwrap())
|
||||
.insert_bool(self.html.book.options.get_str("lang").unwrap(), true);
|
||||
|
||||
|
@ -214,6 +215,7 @@ impl<'a> HtmlDirRenderer<'a> {
|
|||
// Render index.html and write it too
|
||||
let mut mapbuilder = self.html.book.get_mapbuilder("none")
|
||||
.insert_str("content", content)
|
||||
.insert_str("footer", self.html.get_footer())
|
||||
.insert_str("toc", toc.clone())
|
||||
.insert_str("script", self.html.book.get_template("html_dir.script").unwrap())
|
||||
.insert_bool(self.html.book.options.get_str("lang").unwrap(), true);
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
{{{content}}}
|
||||
{{{next_chapter}}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{{footer}}}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -45,5 +45,6 @@
|
|||
{{{content}}}
|
||||
</div>
|
||||
</div>
|
||||
{{{footer}}}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* Default HTML CSS file includes default EPUB CSS file */
|
||||
span.initial {
|
||||
all: initial;
|
||||
}
|
||||
|
@ -150,3 +151,28 @@ blockquote {
|
|||
#toolbar img {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#footer {
|
||||
background-color: #474747;
|
||||
margin-top: 2em;
|
||||
text-align: center;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#footer a {
|
||||
color: #ef68ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#footer a:hover {
|
||||
color: #ca58d7;
|
||||
}
|
||||
|
||||
#footer p {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -60,5 +60,6 @@
|
|||
{{{content}}}
|
||||
</div>
|
||||
</div>
|
||||
{{{footer}}}
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue