Skip to content

Commit

Permalink
Generate the TOC from data, making it easier to modify. Adjust layout
Browse files Browse the repository at this point in the history
to include generated TOC. Fix error in running that stopped TOC being
generated. Add _view.sh to view locally and modify _deploy.sh to build TOC.
  • Loading branch information
Noel Welsh committed Apr 18, 2012
1 parent 059608a commit cadb197
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 12 deletions.
3 changes: 2 additions & 1 deletion _deploy.sh
@@ -1,4 +1,5 @@
#!/bin/bash
rvm use ruby-1.9.2
racket -e '(begin (require "toc.rkt") (make-toc toc))'
jekyll
rsync -av _site/* admin@unweb:/srv/noelwelsh.com/public/htdocs/blueeyes
rsync -av _site/* admin@unweb:/srv/noelwelsh.com/public/htdocs/blueeyes
13 changes: 13 additions & 0 deletions _includes/toc.html
@@ -0,0 +1,13 @@
<ul>
<li><a href="intro.html">A Quick Introduction to BlueEyes</a></li>
<li><a href="setup.html">Setting up a BlueEyes Project</a></li>
<li><a href="request-handlers.html">Building Request Handlers</a></li>
<li><a href="running.html">Running Services</a></li>
<li><a href="concurrency.html">BlueEyes' Concurrency Model</a></li>
<li><a href="http-client.html">Consuming REST Services</a></li>
<li><a href="testing.html">Testing BlueEyes Services</a></li>
<li><a href="json.html">Manipulating JSON</a></li>
<li><a href="mongo.html">Working with Mongo</a></li>
<li><a href="streaming.html">Streaming Requests and Responses</a></li>
<li><a href="deployment.html">Deploying Services in Production</a></li>
</ul>
11 changes: 1 addition & 10 deletions _layouts/page.html
Expand Up @@ -90,16 +90,7 @@
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Contents</li>
<li><a href="intro.html">Quick Start</a></li>
<li><a href="request-handlers.html">Request Handlers</a></li>
<li><a href="running.html">Running Services</a></li>
<li><a href="concurrency.html">Concurrency</a></li>
<li><a href="http-client.html">Consuming Services</a></li>
<li><a href="testing.html">Testing Services</a></li>
<li><a href="json.html">Manipulating JSON</a></li>
<li><a href="mongo.html">Working with Mongo</a></li>
<li><a href="streaming.html">Streaming Requests and Responses</a></li>
<li><a href="deployment.html">Deployment</a></li>
{% include toc.html %}
</ul>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions _view.sh
@@ -0,0 +1,4 @@
#!/bin/bash
rvm use ruby-1.9.2
racket -e '(begin (require "toc.rkt") (make-toc toc))'
jekyll --server --auto
2 changes: 1 addition & 1 deletion running.markdown
@@ -1,6 +1,6 @@
---
layout: page
titie: Running Services
title: Running Services
---

## Configuration
Expand Down
18 changes: 18 additions & 0 deletions setup.markdown
@@ -0,0 +1,18 @@
---
layout: page
title: Setting up a BlueEyes Project
---

Setting up a BlueEyes project using SBT just requires adding ReportGrid's repository to your resolvers, and then creating a dependency on the three BlueEyes packages. The relevant lines are:

{% highlight scala %}
resolvers ++= Seq(
"ReportGrid" at "http://nexus.reportgrid.com/content/repositories/public-snapshots"
)

libraryDependencies ++= Seq(
"com.reportgrid" %% "blueeyes-core" % "0.6.0-SNAPSHOT",
"com.reportgrid" %% "blueeyes-mongo" % "0.6.0-SNAPSHOT",
"com.reportgrid" %% "blueeyes-json" % "0.6.0-SNAPSHOT"
)
{% endhighlight scala %}
61 changes: 61 additions & 0 deletions toc.rkt
@@ -0,0 +1,61 @@
#lang racket

(provide
toc
make-toc)

(define toc
'("intro.html"
"setup.html"
"request-handlers.html"
"running.html"
"concurrency.html"
"http-client.html"
"testing.html"
"json.html"
"mongo.html"
"streaming.html"
"deployment.html"
))

(define toc-file-name "_includes/toc.html")

(define (make-toc toc)
(define (build-toc toc)
(displayln "<ul>")
(map build-item toc)
(displayln "</ul>"))
(define (build-item item)
(cond
[(string? item)
(printf "<li><a href=\"~a\">~a</a></li>\n" item (title item))]
[(pair? item)
(build-toc item)]))

(with-output-to-file toc-file-name
(lambda () (build-toc toc))
#:exists 'replace))


(define (source-file-name file-name)
(cond
[(file-exists? file-name)
file-name]
[(file-exists? (regexp-replace ".html" file-name ".markdown"))
(regexp-replace ".html" file-name ".markdown")]
[else
(error (format "~a does not exist" file-name))]))

(define (title file-name)
(with-input-from-file (source-file-name file-name)
(lambda ()
(define (find-title)
(let* ([line (read-line)]
[_ (if (eof-object? line)
(error (format "No title found in ~a\n" file-name))
#t)]
[mtch (regexp-match #rx"^title: (.*)$" line)])
(match mtch
[(cons _ (list ttl)) ttl]
[#f (find-title)])))
(find-title))))

0 comments on commit cadb197

Please sign in to comment.