diff --git a/.gitignore b/.gitignore index 00748524..d6ad3d00 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ node_modules tmtags *.DS_Store examples/*/log/* +site/log/* .log npm-debug.log doc/ diff --git a/docs/architecture.md b/docs/1-architecture.md similarity index 100% rename from docs/architecture.md rename to docs/1-architecture.md diff --git a/docs/controllers.md b/docs/2-router.md similarity index 100% rename from docs/controllers.md rename to docs/2-router.md diff --git a/docs/models.md b/docs/3-controllers.md similarity index 100% rename from docs/models.md rename to docs/3-controllers.md diff --git a/docs/router.md b/docs/4-models.md similarity index 100% rename from docs/router.md rename to docs/4-models.md diff --git a/docs/templates.md b/docs/5-templates.md similarity index 100% rename from docs/templates.md rename to docs/5-templates.md diff --git a/docs/CLI.md b/docs/6-CLI.md similarity index 100% rename from docs/CLI.md rename to docs/6-CLI.md diff --git a/site/app/controllers/main.js b/site/app/controllers/main.js index 8334cd65..2b910a7c 100644 --- a/site/app/controllers/main.js +++ b/site/app/controllers/main.js @@ -34,10 +34,19 @@ var Main = function () { this.documentation = function (req, resp, params) { var self = this - , opts = { - url: 'https://api.github.com/repos/mde/geddy/commits' - , dataType: 'json' + , docs = [] + , count = 0 + + // once we've got a list of commits, get the tree + // for the latest commit + , gotCommits = function (err, commits) { + var commit = commits[0] && commits[0].commit + , url = commit.tree && commit.tree.url; + return getTree(url, gotTree); } + + // once we've got the first tree, get 'docs' tree + // once we've got the 'docs' tree, call gotTree , getTree = function (url, callback) { var tree; opts.url = url; @@ -54,19 +63,47 @@ var Main = function () { return callback(err, trees.tree); }); } - , gotCommits = function (err, commits) { - var commit = commits[0] && commits[0].commit - , url = commit.tree && commit.tree.url; - return getTree(url, gotTree); + , getBlob = function (paths, i, callback) { + var options = { + url: paths[i].url + , dataType: 'json' + } + geddy.request(options, function (err, resp) { + var content = new Buffer(resp.content, 'base64').toString('utf8') + , name = paths[i].path.replace('.md',''); + docs[name[0]] = { + name: name.split().splice(0,2) + , content: content + }; + return respond(paths.length); + }); } + + // once we've got the 'docs' tree, + // parse it and call getBlob for each file , gotTree = function (err, tree) { for (var i in tree) { console.log(tree[i].path, ':', tree[i].url); + getBlob(tree, i, respond); } - self.respond(params, { - format: 'html' - , template: 'app/views/main/documentation' - }); + } + + // once we've got everything done, respond with data + , respond = function (total) { + count++; + if (count == total) { + console.log(docs); + self.respond(params, { + format: 'html' + , template: 'app/views/main/documentation' + }); + } + } + + // inital call to get the commits + , opts = { + url: 'https://api.github.com/repos/mde/geddy/commits' + , dataType: 'json' } geddy.request(opts, gotCommits); }; diff --git a/site/log/access.log b/site/log/access.log index 45bea143..50fb9f1d 100644 --- a/site/log/access.log +++ b/site/log/access.log @@ -1,7 +1,7 @@ -[Sat, 06 Oct 2012 22:57:18 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 15:57:16 GMT-0700 (PDT)] "GET /documentation 1.1" 200 5144 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" -[Sat, 06 Oct 2012 22:57:18 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 15:57:18 GMT-0700 (PDT)] "GET /css/style.css 1.1" 200 4632 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" -[Sat, 06 Oct 2012 22:57:18 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 15:57:18 GMT-0700 (PDT)] "GET /css/bootstrap.responsive.min.css 1.1" 200 15962 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" -[Sat, 06 Oct 2012 22:57:18 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 15:57:18 GMT-0700 (PDT)] "GET /css/bootstrap.min.css 1.1" 200 98165 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" -[Sat, 06 Oct 2012 22:57:18 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 15:57:18 GMT-0700 (PDT)] "GET /js/bootstrap.min.js 1.1" 200 25563 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" -[Sat, 06 Oct 2012 22:57:18 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 15:57:18 GMT-0700 (PDT)] "GET /js/jquery.min.js 1.1" 200 93437 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" -[Sat, 06 Oct 2012 22:57:19 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 15:57:19 GMT-0700 (PDT)] "GET /images/favicon.ico 1.1" 404 30 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" +[Sat, 06 Oct 2012 23:36:20 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 16:36:17 GMT-0700 (PDT)] "GET /documentation 1.1" 200 5144 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" +[Sat, 06 Oct 2012 23:36:20 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 16:36:20 GMT-0700 (PDT)] "GET /css/style.css 1.1" 200 4632 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" +[Sat, 06 Oct 2012 23:36:20 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 16:36:20 GMT-0700 (PDT)] "GET /css/bootstrap.responsive.min.css 1.1" 200 15962 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" +[Sat, 06 Oct 2012 23:36:20 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 16:36:20 GMT-0700 (PDT)] "GET /js/bootstrap.min.js 1.1" 200 25563 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" +[Sat, 06 Oct 2012 23:36:20 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 16:36:20 GMT-0700 (PDT)] "GET /css/bootstrap.min.css 1.1" 200 98165 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" +[Sat, 06 Oct 2012 23:36:20 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 16:36:20 GMT-0700 (PDT)] "GET /js/jquery.min.js 1.1" 200 93437 "http://localhost:4000/documentation" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" +[Sat, 06 Oct 2012 23:36:20 GMT] ACCESS 127.0.0.1 - - [Sat Oct 06 2012 16:36:20 GMT-0700 (PDT)] "GET /images/favicon.ico 1.1" 404 30 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1" diff --git a/site/log/stdout.log b/site/log/stdout.log index ff512b03..621ee6ed 100644 --- a/site/log/stdout.log +++ b/site/log/stdout.log @@ -1,4 +1,4 @@ -[Sat, 06 Oct 2012 22:57:13 GMT] INFO Server starting with config: { +[Sat, 06 Oct 2012 23:36:12 GMT] INFO Server starting with config: { "environment": "development", "workers": 1, "port": 4000, @@ -29,7 +29,7 @@ "hostname": null, "detailedErrors": true } -[Sat, 06 Oct 2012 22:57:13 GMT] INFO Creating 1 worker process. -[Sat, 06 Oct 2012 22:57:13 GMT] INFO Server worker running in development on port 4000 with a PID of: 79294 -[Sat, 06 Oct 2012 22:57:13 GMT] DEBUG LOGGING STARTED ============================================ -[Sat, 06 Oct 2012 22:57:13 GMT] DEBUG ============================================================ +[Sat, 06 Oct 2012 23:36:12 GMT] INFO Creating 1 worker process. +[Sat, 06 Oct 2012 23:36:12 GMT] INFO Server worker running in development on port 4000 with a PID of: 80075 +[Sat, 06 Oct 2012 23:36:12 GMT] DEBUG LOGGING STARTED ============================================ +[Sat, 06 Oct 2012 23:36:12 GMT] DEBUG ============================================================