summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-03-31 12:31:01 -0700
committerSamy Pessé <samypesse@gmail.com>2014-03-31 12:31:01 -0700
commit4210794de64b396409af080b698a3b5894ee2c80 (patch)
tree5f7ee99c433483b837b20f9d359780008b2ea5c4
parent77a4c1042c7c13327641fb057c3c203cbf868782 (diff)
downloadgitbook-4210794de64b396409af080b698a3b5894ee2c80.zip
gitbook-4210794de64b396409af080b698a3b5894ee2c80.tar.gz
gitbook-4210794de64b396409af080b698a3b5894ee2c80.tar.bz2
Fix all relative links
-rw-r--r--lib/generate/index.js2
-rw-r--r--lib/generate/template.js9
-rw-r--r--templates/includes/book/summary.html8
-rw-r--r--templates/layout.html6
4 files changed, 15 insertions, 10 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js
index 56d1287..c265be3 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -17,7 +17,7 @@ var generate = function(root, output, options) {
github: null
});
- if (!options.github) return Q.reject(new Error("Need options.github for specifing the github origin"));
+ if (!options.github || !options.title) return Q.reject(new Error("Need options.github and optiosn.title"));
// List all files in the repository
return Q.nfcall(glob, "**/*", {
diff --git a/lib/generate/template.js b/lib/generate/template.js
index 8f63190..fdb3578 100644
--- a/lib/generate/template.js
+++ b/lib/generate/template.js
@@ -22,9 +22,12 @@ var initTemplate = function(options) {
});
return function(input, output, local) {
+ var _input = input;
input = path.join(options.root, input);
output = path.join(options.output, output);
+ var basePath = path.relative(path.dirname(output), options.output) || ".";
+
// Read markdown file
return fs.readFile(input, "utf-8")
@@ -37,8 +40,10 @@ var initTemplate = function(options) {
.then(function(sections) {
return tpl(
_.extend(local || {}, options.locals, {
- _input: input,
- content: sections
+ _input: _input,
+ content: sections,
+ basePath: basePath,
+ staticBase: path.join(basePath, "gitbook")
})
);
})
diff --git a/templates/includes/book/summary.html b/templates/includes/book/summary.html
index 65fd398..99c226c 100644
--- a/templates/includes/book/summary.html
+++ b/templates/includes/book/summary.html
@@ -1,20 +1,20 @@
<div class="book-summary">
<ul class="summary">
<li>
- <a href="/book/{{ book.attributes.full_name }}/README.md">Introduction</a>
+ <a href="{{ basePath }}/README.html">Introduction</a>
</li>
<li>
- <a href="https://github.com/{{ book.attributes.owner.login }}" target="blank">About the author</a>
+ <a href="https://github.com/{{ owner }}" target="blank">About the author</a>
</li>
<li class="divider"></li>
{% for item in summary.chapters %}
<li>
- <a href="{{ item.chapter.path }}">{{ item.chapter.title }}</a>
+ <a href="{{ basePath }}/{{ item.chapter.path }}">{{ item.chapter.title }}</a>
{% if item.articles.length > 0 %}
<ul class="articles">
{% for article in item.articles %}
<li>
- <a href="{{ article.path }}">{{ article.title }}</a>
+ <a href="{{ basePath }}/{{ article.path }}">{{ article.title }}</a>
</li>
{% endfor %}
</ul>
diff --git a/templates/layout.html b/templates/layout.html
index 5542cfd..fb57c8a 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -9,8 +9,8 @@
{% else %}
<meta name="robots" content="{% block robots %}noindex, nofollow{% endblock %}">
{% endif %}
- <link rel="icon" href="gitbook/images/icons/32.png">
- <link rel="stylesheet" href="gitbook/style.css">
+ <link rel="icon" href="{{ staticBase }}/images/icons/32.png">
+ <link rel="stylesheet" href="{{ staticBase }}/style.css">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="{% block description %}{% endblock %}">
<meta name="keywords" content="{% block keywords %}{% endblock %}" >
@@ -19,7 +19,7 @@
<meta name="og:site_name" content="GitBook">
<meta name="og:url" content="{{ config.web.url }}">
<meta name="og:description" content="{% block description %}{% endblock %}">
- <meta name="og:image" content="gitbook/images/icons/ios.png" >
+ <meta name="og:image" content="{{ staticBase }}/images/icons/ios.png" >
<meta name="application-name" content="Gitbook">
<meta name="application-url" content="{{ config.web.url }}">
<meta name="msapplication-tooltip" content="{% block description %}{% endblock %}">