load page from JSON file on Github
<script type="text/javascript">
function getUrlVar(key){
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && unescape(result[1]) || "";
}
$ThisPage = getUrlVar('p');
if($ThisPage==''){
$ThisPage = "Home";
}
$token = getUrlVar('t');
var github = new Github({
token: $token,
auth: "oauth"
});
var repo = github.getRepo('kinlane', 'api-commons');
repo.read('master','site.json',function(err, data){
if(!err) {
$Site = jQuery.parseJSON(data);
// Build the navigation
$.each($Site['navigation'], function($key, $value) {
$value = $value + '?p=' + $key + '&t=' + $token;
$NavigationString = '<li><a href="' + $value + '" title="' + $key + '">' + $key + '</a></li>';
$("#primaryNavItems").append($NavigationString);
});
// Build the Page Content
$.each($Site['pages'], function($key, $value) {
if($key==$ThisPage){
$("#pageBody").html($value);
}
});
}
});
</script>