This repository has been archived by the owner on Apr 11, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8f0df57
Showing
5 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#QuickGit | ||
|
||
Temporary (15 Mins) Git Host used for sending git repos quickly to users behind a firewall. | ||
|
||
![Example Image](http://cl.ly/image/0d2h1G0W2n3z/Screen%20Shot%202012-10-05%20at%2018.52.13.png) | ||
|
||
##Licence | ||
|
||
(The MIT Licence) | ||
|
||
Copyright (c) 2012 Ben Evans <ben@bensbit.co.uk> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Generic Requirements | ||
var fs = require('fs'); | ||
var tmp = require('tmp'); | ||
var wrench = require('wrench'); | ||
|
||
// Config | ||
var config = {}; | ||
config.repoPath = process.env.REPO_PATH || "/tmp/repos"; | ||
config.port = process.env.PORT || 3000; | ||
config.externalPort = process.env.EXTERNAL_PORT || config.port; | ||
config.externalHost = process.env.EXTERNAL_HOST || 'localhost'; | ||
|
||
// Web Server Requirements | ||
var http = require('http'); | ||
var Handlebars = require('handlebars'); | ||
|
||
// Git Server Requirements | ||
var pushover = require('pushover'); | ||
var repos = pushover(config.repoPath); | ||
|
||
repos.on('push', function (push) { | ||
// TODO: Reject if more than config.maxRepoSize | ||
// TODO: Reject if URL hasn't actually been generated | ||
console.log('push ' + push.repo + '/' + push.commit | ||
+ ' (' + push.branch + ')' | ||
); | ||
push.accept(); | ||
}); | ||
|
||
repos.on('fetch', function (fetch) { | ||
console.log('fetch ' + fetch.repo + '/' + fetch.commit); | ||
fetch.accept(); | ||
}); | ||
|
||
var server = http.createServer(function (req, res) { | ||
|
||
if(req.headers['user-agent'].match(/git/)) | ||
return repos.handle(req, res); | ||
|
||
if(req.url !== '/') { | ||
res.statusCode = 404; | ||
res.end('404'); | ||
} | ||
|
||
var locals = {} | ||
|
||
if(req.method == 'POST') { | ||
|
||
// Create(d) Repo Container Page | ||
tmp.dir({template: config.repoPath + '/XXXXXX.git'}, function (err, path) { | ||
if (err) throw err; | ||
locals.gitURL = 'http://' + config.externalHost + ':' + config.externalPort + path.replace(config.repoPath, ''); | ||
res.statusCode = 200; | ||
var source = fs.readFileSync(__dirname + '/index.html').toString(); | ||
var template = Handlebars.compile(source); | ||
res.end(template(locals)); | ||
|
||
setInterval(function() { | ||
wrench.rmdirRecursive(path); | ||
}, 900); | ||
}); | ||
|
||
} else { | ||
|
||
// Button Page | ||
res.statusCode = 200; | ||
var source = fs.readFileSync(__dirname + '/index.html').toString(); | ||
var template = Handlebars.compile(source); | ||
res.end(template(locals)); | ||
} | ||
|
||
}); | ||
|
||
server.listen(config.port); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>QuickGit</title> | ||
<style type="text/css"> | ||
body { | ||
color:#111; | ||
} | ||
.container { | ||
margin:auto; | ||
width:500px; | ||
} | ||
a { | ||
text-decoration: none; | ||
|
||
} | ||
a h1 { | ||
color:#000; | ||
font-family: 'Finger Paint', cursive; | ||
text-align:center; | ||
font-size: 40px; | ||
} | ||
.terminal { | ||
background-color:#222; | ||
box-shadow:inset 0 0 10px black; | ||
color:#ddd; | ||
font-family: monospace; | ||
padding:10px; | ||
|
||
} | ||
input { | ||
border: 1px solid black; | ||
background-color:#ccc; | ||
padding:20px; | ||
color:#111; | ||
width:100%; | ||
font-size:20px; | ||
font-family: 'Finger Paint', cursive; | ||
} | ||
|
||
h2 { | ||
font-family: 'Finger Paint', cursive; | ||
border-bottom:1px solid #aaa; | ||
} | ||
|
||
p { | ||
color:red; | ||
text-align:center; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class=container> | ||
<a href="/"><h1>QuickGit</h1></a> | ||
{{#if gitURL}} | ||
<p>Your Git Repo Container will collapse in <span id="timeLeft">900</span> seconds!</p> | ||
<h2>You:</h2> | ||
<div class="terminal">git push {{gitURL}} master</div><br/> | ||
<h2>Friend:</h2> | ||
<div class="terminal">git clone {{gitURL}} master</div> | ||
{{else}} | ||
<form method="POST" action="/"> | ||
<input type=submit value="Generate Git Repo Container"> | ||
<p>(Last for 15 minutes before self-destruction)</p> | ||
</form> | ||
{{/if}} | ||
</div> | ||
<link href='http://fonts.googleapis.com/css?family=Finger+Paint' rel='stylesheet' type='text/css'> | ||
{{#if gitURL}} | ||
<script type="text/javascript"> | ||
var timeLeftElement = document.getElementById('timeLeft'); | ||
var countdownInterval = setInterval(function() { | ||
if(timeLeftElement.innerHTML > 0) | ||
return timeLeftElement.innerHTML = parseInt(timeLeftElement.innerHTML) - 1; | ||
window.location = '/'; | ||
}, 1000); | ||
</script> | ||
{{/if}} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "quickgit", | ||
"version": "0.0.0", | ||
"private": "true", | ||
"description": "Temp Git Repo Host to Send a Git Repo to a Friend Quickly that's behind a firewall", | ||
"main": "app.js", | ||
"dependencies": { | ||
"handlebars": "~1.0.6-2", | ||
"mu": "~0.5.2", | ||
"wrench": "~1.3.9", | ||
"pushover": "~1.0.3", | ||
"tmp": "~0.0.14" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": "", | ||
"keywords": [ | ||
"git", | ||
"repo", | ||
"share", | ||
"quick", | ||
"host", | ||
"http" | ||
], | ||
"engines": { | ||
"node": "0.8.x", | ||
"npm": "1.1.x" | ||
}, | ||
"author": "Ben Evans <ben@bensbit.co.uk>", | ||
"license": "BSD" | ||
} |