Skip to content

Commit

Permalink
[fixes jeromegn#25] Added proper config parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Feb 8, 2012
1 parent 19c4f2d commit 9cb1d77
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
3 changes: 3 additions & 0 deletions app/resources/repositories.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ handleRepository = (req, res, next)->
return sendHtml(res, err.message, 500) if err
{readme, config} = files

if req.query && req.query.config
config = JSON.parse(req.query.config)

compile req, res, readme, config, (err, html)->
return sendHtml(res, err.message, 500) if err
sendHtml(res, html)
Expand Down
19 changes: 7 additions & 12 deletions documentup.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
this.DocumentUp = {};

var conf_to_params = function (conf) {
var params = "";
for (var param in conf) {
params ? params += "&" : params = "?";
params += param + "=" + encodeURIComponent(conf[param])
}
return params;
}

DocumentUp.document = function (opts) {
var repo;
if ("string" === typeof opts) {
repo = opts;
opts = {};
opts = null;
} else {
repo = opts.repo;
delete opts.repo;
Expand All @@ -24,13 +15,17 @@ DocumentUp.document = function (opts) {
document.open();
document.write(resp.html);
document.close();
if (opts.afterRender && typeof opts.afterRender === "function")
if (opts && opts.afterRender && typeof opts.afterRender === "function")
opts.afterRender()
}
}

var script = document.createElement('script');
script.src = 'http://documentup.com/'+repo+conf_to_params(opts)+'&callback=callback';
script.src = 'http://documentup.com/'+repo
if (opts)
script.src += "?config="+encodeURIComponent(JSON.stringify(opts))+'&callback=callback';
else
script.src += "?callback=callback";

document.getElementsByTagName('head')[0].appendChild(script);
}
2 changes: 1 addition & 1 deletion documentup.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

<!-- Simple instantiation -->
<script>
DocumentUp.document({
repo: "jeromegn/documentup",
DocumentUp.document("jeromegn/documentup",
name: "DocumentUp",
twitter: [
"jeromegn",
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
},
"devDependencies": {
"uglify-js": "1.2.5",
"ender": "0.8.3",
"async": "0.1.15",
"growl": "~1.2.0"
}
}

0 comments on commit 9cb1d77

Please sign in to comment.