From 7afc5746f09d3b325aa9efa4bda7e64dd838e362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Bu=C4=9Fdayc=C4=B1?= Date: Wed, 16 Jul 2014 14:03:49 +0300 Subject: [PATCH 1/4] Adding a frame to list the version next to files --- gsd-server/app.js | 12 ++++++++++++ gsd-server/public/stylesheets/style.css | 20 ++++++++++++++++++++ gsd-server/views/branch.jade | 2 +- gsd-server/views/frame.jade | 10 ++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gsd-server/views/frame.jade diff --git a/gsd-server/app.js b/gsd-server/app.js index 2f64547..c4ddce5 100644 --- a/gsd-server/app.js +++ b/gsd-server/app.js @@ -60,6 +60,17 @@ 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; + gs.getBranchCommits(repo, branch, function(err, commits){ + res.render('frame', { page_title: repo + ' - ' + branch, repo: repo, branch: branch, commit: commit, file: file, commits: commits }); + }); + }); + + app.get('/:repo?', function(req, res){ var repo = req.params.repo console.log('here') @@ -76,6 +87,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..416cd44 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: 100%; +} \ No newline at end of file diff --git a/gsd-server/views/branch.jade b/gsd-server/views/branch.jade index a6ef76c..33effe8 100644 --- a/gsd-server/views/branch.jade +++ b/gsd-server/views/branch.jade @@ -10,7 +10,7 @@ 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= commit.sha.substring(0,6) diff --git a/gsd-server/views/frame.jade b/gsd-server/views/frame.jade new file mode 100644 index 0000000..359d211 --- /dev/null +++ b/gsd-server/views/frame.jade @@ -0,0 +1,10 @@ +doctype html +html + head + title= page_title + base(target=_blank) + link(rel='stylesheet', href='/stylesheets/style.css') + body(height="100%") + iframe.menu(src="/#{repo}/#{branch}/") + + iframe.file(src="/#{repo}/#{commit}/#{file}") From 8078e82a6af600a65ee1f45bcddab22127e7826c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Bu=C4=9Fdayc=C4=B1?= Date: Wed, 16 Jul 2014 14:53:55 +0300 Subject: [PATCH 2/4] Adding the frame link to repo page too. Fixing the iframe link open target --- gsd-server/app.js | 11 +++++++++- gsd-server/public/stylesheets/style.css | 28 ++++++++++++------------- gsd-server/views/branch.jade | 2 ++ gsd-server/views/frame.jade | 3 +-- gsd-server/views/layout.jade | 1 + gsd-server/views/repo.jade | 2 +- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/gsd-server/app.js b/gsd-server/app.js index c4ddce5..08cd33c 100644 --- a/gsd-server/app.js +++ b/gsd-server/app.js @@ -65,8 +65,17 @@ function startServer(reps, port_number){ branch = req.params.branch; commit = req.params.commit; file = req.params.file; + + if(commit === "index.html"){ + path = branch+ '/' + 'index.html'; + }else + { + path = commit + '/' + file; + } + console.log(path); + gs.getBranchCommits(repo, branch, function(err, commits){ - res.render('frame', { page_title: repo + ' - ' + branch, repo: repo, branch: branch, commit: commit, file: file, commits: commits }); + res.render('frame', { page_title: repo + ' - ' + branch, repo: repo, branch: branch, path: path }); }); }); diff --git a/gsd-server/public/stylesheets/style.css b/gsd-server/public/stylesheets/style.css index 416cd44..f1dc49c 100644 --- a/gsd-server/public/stylesheets/style.css +++ b/gsd-server/public/stylesheets/style.css @@ -25,21 +25,21 @@ h1 { } .menu { -position: absolute; -background-color: rgb(235,235,235); -top: 0; -left: 0; -height: 100%; -width: 300px; -border: 0; -border-right: 1px solid gray; + 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: 100%; + 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 33effe8..bd0b8c5 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 diff --git a/gsd-server/views/frame.jade b/gsd-server/views/frame.jade index 359d211..2063dc0 100644 --- a/gsd-server/views/frame.jade +++ b/gsd-server/views/frame.jade @@ -2,9 +2,8 @@ doctype html html head title= page_title - base(target=_blank) link(rel='stylesheet', href='/stylesheets/style.css') body(height="100%") iframe.menu(src="/#{repo}/#{branch}/") - iframe.file(src="/#{repo}/#{commit}/#{file}") + iframe.file(src="/#{repo}/#{path}") 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" From b8cc3611c574ad533be89ddc2b20f21422b1b03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Bu=C4=9Fdayc=C4=B1?= Date: Wed, 16 Jul 2014 15:16:59 +0300 Subject: [PATCH 3/4] Easier locale strings --- gsd-server/views/branch.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gsd-server/views/branch.jade b/gsd-server/views/branch.jade index bd0b8c5..faafc80 100644 --- a/gsd-server/views/branch.jade +++ b/gsd-server/views/branch.jade @@ -1,7 +1,7 @@ extends layout block head - base(target="_parent") + base(target="_parent") block content p.page-type Repository-branch h1 @@ -14,6 +14,6 @@ block content li 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 From cc5dd0d969e45215b4febfb24f8926afa92e5e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Bu=C4=9Fdayc=C4=B1?= Date: Wed, 16 Jul 2014 15:38:44 +0300 Subject: [PATCH 4/4] Fix the path variable --- gsd-server/app.js | 9 ++++----- gsd-server/views/frame.jade | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gsd-server/app.js b/gsd-server/app.js index 08cd33c..78f20c3 100644 --- a/gsd-server/app.js +++ b/gsd-server/app.js @@ -67,15 +67,14 @@ function startServer(reps, port_number){ file = req.params.file; if(commit === "index.html"){ - path = branch+ '/' + 'index.html'; + repoPath = branch+ '/' + 'index.html'; }else { - path = commit + '/' + file; + repoPath = commit + '/' + file; } - console.log(path); - + gs.getBranchCommits(repo, branch, function(err, commits){ - res.render('frame', { page_title: repo + ' - ' + branch, repo: repo, branch: branch, path: path }); + res.render('frame', { page_title: repo + ' - ' + branch, repo: repo, branch: branch, repoPath: repoPath }); }); }); diff --git a/gsd-server/views/frame.jade b/gsd-server/views/frame.jade index 2063dc0..9493477 100644 --- a/gsd-server/views/frame.jade +++ b/gsd-server/views/frame.jade @@ -6,4 +6,4 @@ html body(height="100%") iframe.menu(src="/#{repo}/#{branch}/") - iframe.file(src="/#{repo}/#{path}") + iframe.file(src="/#{repo}/#{repoPath}")