diff --git a/book-example/book/README.html b/book-example/book/README.html index b4b14455..981dad18 100644 --- a/book-example/book/README.html +++ b/book-example/book/README.html @@ -24,8 +24,9 @@

-
-

mdBook

+
+
+

mdBook

mdBook is a command line tool and Rust library to create books using Markdown. It's very similar to Gitbook but written in Rust.

This book serves as an example of the output of mdBook and as the docs at the same time.

@@ -34,8 +35,24 @@ Issues and feature requests can be posted on the Mozilla Public License v2.0

+
+ + + + + + + +
diff --git a/book-example/book/book.css b/book-example/book/book.css index 2c93872a..86ac8f08 100644 --- a/book-example/book/book.css +++ b/book-example/book/book.css @@ -55,6 +55,15 @@ html, body { } .page { + position: absolute; + top: 50px; + right: 0; + left: 0; + bottom: 0; + overflow-y: auto; +} + +.content { margin-left: auto; margin-right:auto; max-width: 750px; @@ -126,10 +135,6 @@ pre { border-radius: 3px; } -.nav-previous-next { - margin-top: 60px; -} - .left { float: left; } @@ -140,11 +145,48 @@ pre { /* Content */ -.page a { +.content a { color: #4183c4; text-decoration: none; } -.page a:hover { +.content a:hover { text-decoration: underline; } + +/* Nav icons */ +.nav-chapters { + color: #CCC; + font-size: 40px; + text-align: center; + text-decoration: none; + + position: absolute; + top: 50px; /* Height of menu-bar */ + bottom: 0; + margin: 0; + max-width: 150px; + min-width: 90px; + display: flex; + justify-content: center; + align-content: center; + flex-direction: column; + + -webkit-transition: color 0.5s; /* Safari */ + -o-transition: color 0.5s; /* Opera */ + -moz-transition: color 0.5s; /* Mozilla Firefox */ + transition: color 0.5s; +} + +.nav-chapters:hover { + color: #333; + text-decoration: none; +} + +.previous { + left: 0; +} + +.next { + right: 0; +} diff --git a/book-example/book/book.js b/book-example/book/book.js index 643755e5..d3cff82f 100644 --- a/book-example/book/book.js +++ b/book-example/book/book.js @@ -14,4 +14,13 @@ $( document ).ready(function() { } }); + + // Hide navigation icons when there is no next or previous link + // JavaScript Solution until I find a way to do this in the template + $(".nav-chapters").each(function(){ + if(!$(this).attr('href')){ + this.remove(); + } + }); + }); diff --git a/book-example/book/cli/build.html b/book-example/book/cli/build.html index 05879026..4322b6d6 100644 --- a/book-example/book/cli/build.html +++ b/book-example/book/cli/build.html @@ -24,8 +24,9 @@

-
-

The build command

+
+
+

The build command

The build command is used to render your book:

mdbook build
 
@@ -41,8 +42,24 @@ current working directory.


note: make sure to run the build command in the root directory and not in the src directory

+
+ + + + + + + +
diff --git a/book-example/book/cli/cli-tool.html b/book-example/book/cli/cli-tool.html index f9a77206..d7c2fe38 100644 --- a/book-example/book/cli/cli-tool.html +++ b/book-example/book/cli/cli-tool.html @@ -24,13 +24,30 @@

-
-

Command Line Tool

+
+
+

Command Line Tool

mdBook can be used either as a command line tool or a Rust library. Let's focus on the command line tool capabilities first.

+
+ + + + + + + +
diff --git a/book-example/book/cli/init.html b/book-example/book/cli/init.html index 6975b848..c9fef2ea 100644 --- a/book-example/book/cli/init.html +++ b/book-example/book/cli/init.html @@ -24,8 +24,9 @@

-
-

The init command

+
+
+

The init command

The init command, used like this:

mdbook init
 
@@ -58,8 +59,24 @@ The user could then tweak the theme to his needs. not create the corresponding files, init command should create the files for him. +
+ + + + + + + +
diff --git a/book-example/book/index.html b/book-example/book/index.html index b4b14455..981dad18 100644 --- a/book-example/book/index.html +++ b/book-example/book/index.html @@ -24,8 +24,9 @@

-
-

mdBook

+
+
+

mdBook

mdBook is a command line tool and Rust library to create books using Markdown. It's very similar to Gitbook but written in Rust.

This book serves as an example of the output of mdBook and as the docs at the same time.

@@ -34,8 +35,24 @@ Issues and feature requests can be posted on the Mozilla Public License v2.0

+
+ + + + + + + +
diff --git a/src/book/mdbook.rs b/src/book/mdbook.rs index 1890bcc4..4a7b707e 100644 --- a/src/book/mdbook.rs +++ b/src/book/mdbook.rs @@ -1,6 +1,6 @@ use std::path::Path; use std::fs::{self, File, metadata}; -use std::io::{self, Write}; +use std::io::Write; use std::error::Error; use {BookConfig, BookItem}; diff --git a/src/renderer/html_handlebars/hbs_navigation_helper.rs b/src/renderer/html_handlebars/hbs_navigation_helper.rs index e14034dc..b7a699c3 100644 --- a/src/renderer/html_handlebars/hbs_navigation_helper.rs +++ b/src/renderer/html_handlebars/hbs_navigation_helper.rs @@ -23,7 +23,7 @@ pub fn previous(c: &Context, _h: &Helper, _: &Handlebars, rc: &mut RenderContext // Decode json format let decoded: Vec> = json::decode(&chapters.to_string()).unwrap(); - let mut previous = PathBuf::new(); + let mut previous = PathBuf::from(""); for item in decoded { @@ -56,8 +56,6 @@ pub fn next(c: &Context, _h: &Helper, _: &Handlebars, rc: &mut RenderContext) -> let current = c.navigate(rc.get_path(), "path").to_string().replace("\"", ""); let path_to_root = c.navigate(rc.get_path(), "path_to_root").to_string().replace("\"", ""); - try!(rc.writer.write(path_to_root.as_bytes())); - // Decode json format let decoded: Vec> = json::decode(&chapters.to_string()).unwrap(); @@ -70,6 +68,7 @@ pub fn next(c: &Context, _h: &Helper, _: &Handlebars, rc: &mut RenderContext) -> if is_current { let mut next = PathBuf::from(path); next.set_extension("html"); + try!(rc.writer.write(path_to_root.as_bytes())); try!(rc.writer.write(next.to_str().unwrap().as_bytes())); break; } else if path == ¤t { diff --git a/src/renderer/renderer.rs b/src/renderer/renderer.rs index 1165523f..cd751791 100644 --- a/src/renderer/renderer.rs +++ b/src/renderer/renderer.rs @@ -1,4 +1,4 @@ -use book::{BookItem, BookItems}; +use book::BookItems; use book::BookConfig; use std::error::Error; diff --git a/src/theme/book.css b/src/theme/book.css index f8c20713..86ac8f08 100644 --- a/src/theme/book.css +++ b/src/theme/book.css @@ -55,6 +55,15 @@ html, body { } .page { + position: absolute; + top: 50px; + right: 0; + left: 0; + bottom: 0; + overflow-y: auto; +} + +.content { margin-left: auto; margin-right:auto; max-width: 750px; @@ -136,11 +145,48 @@ pre { /* Content */ -.page a { +.content a { color: #4183c4; text-decoration: none; } -.page a:hover { +.content a:hover { text-decoration: underline; } + +/* Nav icons */ +.nav-chapters { + color: #CCC; + font-size: 40px; + text-align: center; + text-decoration: none; + + position: absolute; + top: 50px; /* Height of menu-bar */ + bottom: 0; + margin: 0; + max-width: 150px; + min-width: 90px; + display: flex; + justify-content: center; + align-content: center; + flex-direction: column; + + -webkit-transition: color 0.5s; /* Safari */ + -o-transition: color 0.5s; /* Opera */ + -moz-transition: color 0.5s; /* Mozilla Firefox */ + transition: color 0.5s; +} + +.nav-chapters:hover { + color: #333; + text-decoration: none; +} + +.previous { + left: 0; +} + +.next { + right: 0; +} diff --git a/src/theme/book.js b/src/theme/book.js index 643755e5..d3cff82f 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -14,4 +14,13 @@ $( document ).ready(function() { } }); + + // Hide navigation icons when there is no next or previous link + // JavaScript Solution until I find a way to do this in the template + $(".nav-chapters").each(function(){ + if(!$(this).attr('href')){ + this.remove(); + } + }); + }); diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 0539840f..d2177dc9 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -24,10 +24,27 @@

{{ title }}

-
- {{{ content }}} +
+
+ {{{ content }}} +
+ + + + + + + +