Permalink
Browse files

Adding a half converted index page for docs. Also redirecting /foo to…

… /foo/, so that relative links work better.
  • Loading branch information...
1 parent ec4a1f4 commit 0141a053ee41cc2cbcc10bb9ccaac2af410ba374 @augustl augustl committed Jan 23, 2012
View
@@ -20,12 +20,17 @@ function serveFile(path, res) {
});
}
-function serveTemplate(path, res) {
- res.writeHead(200, {"Content-Type": "text/html"});
- fs.readFile(path, function (err, data) {
- res.write(renderTemplate(data.toString("utf8")));
+function serveTemplate(path, pathname, res) {
+ if (pathname.slice(pathname.length - 1) == "/") {
+ res.writeHead(200, {"Content-Type": "text/html"});
+ fs.readFile(path, function (err, data) {
+ res.write(renderTemplate(data.toString("utf8")));
res.end();
- });
+ });
+ } else {
+ res.writeHead(301, {"Location": pathname + "/"});
+ res.end();
+ }
}
function renderTemplate(content) {
@@ -51,14 +56,14 @@ http.createServer(function (req, res) {
if (err || !stat.isFile()) {
notFound(res);
} else {
- serveTemplate(indexHtmlPath, res);
+ serveTemplate(indexHtmlPath, u.pathname, res);
}
});
} else {
- var templatePath = dirPath + ".html";
+ var templatePath = dirPath.slice(0, dirPath.length - 1) + ".html";
fs.stat(templatePath, function (err, stat) {
if (!err && stat.isFile()) {
- serveTemplate(templatePath, res);
+ serveTemplate(templatePath, u.pathname, res);
} else {
notFound(res);
}
File renamed without changes
File renamed without changes
@@ -2,19 +2,19 @@
<h2>Overview</h2>
<p>A lits of most of the things Buster.JS can do.</p>
-<p><a href="<%= doc_url "overview" %>">Read more</a></p>
+<p><a href="overview">Read more</a></p>
<h2>Installation, getting started</h2>
<p>Installation instructions, your first test, the config file, and so on.</p>
-<p><a href="<%= doc_url "getting-started" %>">Read more</a></p>
+<p><a href="getting-started">Read more</a></p>
<h2>Writing tests</h2>
-<p>Read about <a href="<%= doc_url "browser-testing" %>">browser testing</a>, <a href="<%= doc_url "node-testing" %>">Node testing</a> and <a href="<%= doc_url "hybrid-testing" %>">hybrid Node and browser testing</a>.</p>
+<p>Read about <a href="browser-testing">browser testing</a>, <a href="node-testing">Node testing</a> and <a href="hybrid-testing">hybrid Node and browser testing</a>.</p>
-<p><%= m "test/test-case", "buster.testCase" %> documents contexts, setUp and tearDown, asynchronous tests, and more.</p>
+<p><a href="buster-test/test-case">buster.testcase</a> documents contexts, setUp and tearDown, asynchronous tests, and more.</p>
-<p><%= m "assertions", "assertions" %> documents all of our assertions. There are lots of them.</p>
+<p><a href="buster-assertions">buster.assertions</a> documents all of our assertions. There are lots of them.</p>
<h2>Modules</h2>

0 comments on commit 0141a05

Please sign in to comment.