diff --git a/gsd-server/app.js b/gsd-server/app.js index 2f64547..78f20c3 100644 --- a/gsd-server/app.js +++ b/gsd-server/app.js @@ -60,6 +60,25 @@ function startServer(reps, port_number){ }); }); + app.get('/frame/:repo/:branch/:commit/:file?*', function(req, res){ + var repo = req.params.repo, + branch = req.params.branch; + commit = req.params.commit; + file = req.params.file; + + if(commit === "index.html"){ + repoPath = branch+ '/' + 'index.html'; + }else + { + repoPath = commit + '/' + file; + } + + gs.getBranchCommits(repo, branch, function(err, commits){ + res.render('frame', { page_title: repo + ' - ' + branch, repo: repo, branch: branch, repoPath: repoPath }); + }); + }); + + app.get('/:repo?', function(req, res){ var repo = req.params.repo console.log('here') @@ -76,6 +95,7 @@ function startServer(reps, port_number){ }); }); + app.get('/:repo/:branchOrBranch/:file?*', gs.route()); http.createServer(app).listen(app.get('port'), function(){ diff --git a/gsd-server/public/stylesheets/style.css b/gsd-server/public/stylesheets/style.css index c24cd88..f1dc49c 100644 --- a/gsd-server/public/stylesheets/style.css +++ b/gsd-server/public/stylesheets/style.css @@ -23,3 +23,23 @@ h1 { .code { font-family: 'Andale Mono', courier, monospace; } + +.menu { + position: absolute; + background-color: rgb(235,235,235); + top: 0; + left: 0; + height: 100%; + width: 300px; + border: 0; + border-right: 1px solid gray; +} + +.file { + position: absolute; + top: 0; + left: 300px; + border: 0; + height: 100%; + width: 80%; +} \ No newline at end of file diff --git a/gsd-server/views/branch.jade b/gsd-server/views/branch.jade index a6ef76c..faafc80 100644 --- a/gsd-server/views/branch.jade +++ b/gsd-server/views/branch.jade @@ -1,5 +1,7 @@ extends layout +block head + base(target="_parent") block content p.page-type Repository-branch h1 @@ -10,8 +12,8 @@ block content ul.code each commit in commits li - a(href="/#{repo}/"+ commit.sha.substring(0,6) + "/index.html")= commit.message + a(href="/frame/#{repo}/#{branch}/"+ commit.sha.substring(0,6) + "/index.html")= commit.message ul - li= new Date(commit.date).toLocaleString().replace(/ 20(\d{2})/,', \'$1 -').replace(/GMT-\d{4}.* /,'') + li= new Date(commit.date).toLocaleString().substring(0,21) li= commit.sha.substring(0,6) li= commit.author \ No newline at end of file diff --git a/gsd-server/views/frame.jade b/gsd-server/views/frame.jade new file mode 100644 index 0000000..9493477 --- /dev/null +++ b/gsd-server/views/frame.jade @@ -0,0 +1,9 @@ +doctype html +html + head + title= page_title + link(rel='stylesheet', href='/stylesheets/style.css') + body(height="100%") + iframe.menu(src="/#{repo}/#{branch}/") + + iframe.file(src="/#{repo}/#{repoPath}") diff --git a/gsd-server/views/layout.jade b/gsd-server/views/layout.jade index ace5126..63576e4 100644 --- a/gsd-server/views/layout.jade +++ b/gsd-server/views/layout.jade @@ -2,6 +2,7 @@ doctype html html head title= page_title + block head link(rel='stylesheet', href='/stylesheets/style.css') body block content \ No newline at end of file diff --git a/gsd-server/views/repo.jade b/gsd-server/views/repo.jade index 9191601..1789dc8 100644 --- a/gsd-server/views/repo.jade +++ b/gsd-server/views/repo.jade @@ -12,4 +12,4 @@ block content a(href="/#{repo}/#{branch}")= branch ul li - a(href="/#{repo}/#{branch}/index.html")= "latest" + a(href="/frame/#{repo}/#{branch}/index.html")= "latest"