Skip to content

Commit

Permalink
Remove console logs, ui tweaks, auth tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Izaak Schroeder committed Feb 28, 2014
1 parent 6550f0a commit 45d1d42
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 31 deletions.
14 changes: 14 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

ROOT=`dirname $0`

# Give nodejs the ability to bind to ports below 1024.
# Since apparently you can't setcap on a user may as well
# give this power to ANYONE WITH THE NODE BINARY LOL.
sudo setcap cap_net_bind_service=ep /usr/bin/nodejs

# Fix some retardation. This is unbelievably annoying.
sudo cp "${ROOT}/share/lxc/fuck-lxc.conf" "/etc/init/fuck-lxc.conf"

# Think we good now
# Yea boi.
17 changes: 10 additions & 7 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ app.get(
kiddies(assignment, function(err) {
load(assignment, { principal: req.principal }, function(err, context) {
if (err) return next(err);
console.log(context);
//console.log(context);
res.render('assignment', {
assignment: assignment,
context: context
Expand Down Expand Up @@ -352,7 +352,6 @@ var loaders = [{
mongoose.model('EvaluationSettings').findOne({ assignment: assignment }, next)
},
'evaluations': function(next) {
console.log({ assignment: assignment.id, target: context.principal })
mongoose.model('Evaluation').find({ assignment: assignment.id, target: context.principal }).limit(10).exec(next);
}
}, next);
Expand Down Expand Up @@ -404,7 +403,6 @@ var loaders = [{
});
}
else {
console.log('returning repo!');
return next(undefined, { repository: item.repository });
}
});
Expand Down Expand Up @@ -439,7 +437,6 @@ function load(component, context, done) {
function get(name) {
var model = mongoose.model(name), key = name.toLowerCase();
return function(req, res, next, id) {
console.log('finding',name)
if (req[key]) return next();
model.findById(id, function(err, result) {
if (err) return next(err);
Expand All @@ -456,6 +453,12 @@ app.param('repository', get('Repository'))

mongoose.model('Repository').schema.set('repository path', app.get('path')+'/var/repositories');

function onlyOwner() {
return function(req, res, next) {
if (req.principal !== req.repository.owner) return next({ statusCode: 403 });
next();
}
}

var git = require('./git'), authSK = require('./authentication/secure-key')(mongoose.model('SecureKey'));

Expand All @@ -464,7 +467,7 @@ app.post(
'/code/:repository/git-upload-pack',
authSK('git'),
authenticated(),
//authorize.owner(),
onlyOwner(),
git.uploadPack()
);

Expand All @@ -473,15 +476,15 @@ app.post(
'/code/:repository/git-receive-pack',
authSK('git'),
authenticated(),
//authorize.owner(),
onlyOwner(),
git.receivePack()
);


app.get('/code/:repository/info/refs',
authSK('git'),
authenticated(),
//authorize.owner(),
onlyOwner(),
git.refs()
);

Expand Down
3 changes: 1 addition & 2 deletions lib/models/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ module.exports = function(app) {
else {
fs.realpath(source, function(err, path) {
if (err) return done(err);
console.log('linking ',path,'->',destination)
fs.symlink(path, destination, done);
});
}
Expand Down Expand Up @@ -129,7 +128,7 @@ module.exports = function(app) {
// FIXME: What's the best way of doing this? This is pretty ugly.
// FIXME: Method cannot be called hook
Repository.method('gitHook', function(type, name, script, args, next) {
console.log(arguments);
//console.log(arguments);
mongoose.model('RepositoryHook')({
repository: this,
kind: type,
Expand Down
45 changes: 23 additions & 22 deletions views/assignment.jade
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mixin boilerplate(context)
code
| git clone -o boilerplate #{url({ path: context.repository.url })} #{assignment.key}
| cd #{assignment.key}
| cat README.md

mixin submission(context)
h2 Submissions
Expand All @@ -24,33 +25,33 @@ mixin submission(context)
if context.key
p Settings:
code
| git remote add prelude #{url({ auth: 'submit:'+context.key.key, path: context.configuration.repository.url })}
| git push prelude master
| git remote add submit #{url({ auth: 'submit:'+context.key.key, path: context.configuration.repository.url })}
| git push submit master
else
p Unfortunately it looks like you're not logged in so you can't do this.

if context.submissions
table.submissions
thead
tr
th Submitter
th Received
th Commit
th
tbody
for submission in context.submissions
if context.submissions.length > 0
table.submissions
thead
tr
td.submitter
| #{submission.submitter}
td.received
time(datetime=submission.at) #{submission.at}
td.commit
+commit(submission)
td.evaluate
form(method="post",action="/submission/"+submission.id+"/evaluate")
input.button(type="submit",value="Evaluate")

unless context.submissions.length > 0
th Submitter
th Received
th Commit
th
tbody
for submission in context.submissions
tr
td.submitter
| #{submission.submitter}
td.received
time(datetime=submission.at) #{submission.at}
td.commit
+commit(submission)
td.evaluate
form(method="post",action="/submission/"+submission.id+"/evaluate")
input.button(type="submit",value="Evaluate")
else
p You haven't made any submissions yet. Get on it!

mixin evaluation(context)
Expand Down

0 comments on commit 45d1d42

Please sign in to comment.