-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ben Speakman
committed
Aug 5, 2015
1 parent
d90c627
commit a2427d9
Showing
36 changed files
with
1,097 additions
and
12,671 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 |
---|---|---|
@@ -1,29 +1,5 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
public/build | ||
.bower-*/ | ||
bower_components | ||
public/css/styles.css | ||
public/js/scripts.js |
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 |
---|---|---|
@@ -1,47 +1,66 @@ | ||
var gulp = require("gulp"); | ||
var uglify = require("gulp-uglify"); | ||
var concat = require("gulp-concat"); | ||
var streamqueue = require('streamqueue'); | ||
var minifyCSS = require("gulp-minify-css"); | ||
|
||
gulp.task("js", function () { | ||
|
||
var stream = streamqueue({ objectMode: true }); | ||
|
||
stream.queue( | ||
gulp.src([ | ||
"public/js/vendor/*.min.js" | ||
]) | ||
); | ||
|
||
stream.queue( | ||
gulp.src([ | ||
"public/js/vendor/*.js", | ||
"!public/js/vendor/*.min.js", | ||
"public/js/script.js" | ||
]) | ||
.pipe(uglify({preserveComments: "some"})) | ||
); | ||
|
||
return stream.done() | ||
.pipe(concat("scripts.js")) | ||
.pipe(gulp.dest("public/build/")); | ||
var gulp = require('gulp'); | ||
var uglify = require('gulp-uglify'); | ||
var concat = require('gulp-concat'); | ||
var minifyCSS = require('gulp-minify-css'); | ||
var bower = require('gulp-bower'); | ||
var mainBowerFiles = require('main-bower-files'); | ||
var order = require('gulp-order'); | ||
|
||
gulp.task('js', function () { | ||
|
||
// Angular app | ||
var scripts = [ | ||
'app/**/*.js' | ||
] | ||
|
||
return gulp | ||
.src(scripts) | ||
.pipe(concat('app.js')) | ||
.pipe(gulp.dest('public/js/')) | ||
|
||
}); | ||
|
||
gulp.task('vendor', ['bower'], function () { | ||
|
||
// Bower dependencies | ||
var bowerScripts = mainBowerFiles('**/*.js'); | ||
|
||
return gulp | ||
.src(bowerScripts) | ||
.pipe(order([ | ||
'*angular.js', | ||
'*angular-sanitize.js' | ||
])) | ||
.pipe(concat('vendor.js')) | ||
.pipe(uglify()) | ||
.pipe(gulp.dest('public/js/')) | ||
|
||
}); | ||
|
||
gulp.task("css", function () { | ||
gulp.task('css', ['bower'], function () { | ||
|
||
var stream = streamqueue({ objectMode: true }); | ||
// Bower dependencies | ||
var bowerStyles = mainBowerFiles('**/*.css'); | ||
|
||
stream.queue( | ||
gulp.src("public/css/*.css") | ||
); | ||
// App styles | ||
var styles = [ | ||
'public/css/style.css' | ||
] | ||
|
||
return stream.done() | ||
.pipe(concat("style.css")) | ||
return gulp | ||
.src(bowerStyles.concat(styles)) | ||
.pipe(concat('styles.css')) | ||
.pipe(minifyCSS()) | ||
.pipe(gulp.dest("public/build/")); | ||
.pipe(gulp.dest('public/css/')) | ||
|
||
}); | ||
|
||
gulp.task('bower', function() { | ||
return bower(); | ||
}); | ||
|
||
gulp.task('watch', function() { | ||
gulp.watch('app/**/*.js', ['js']); | ||
}); | ||
|
||
gulp.task('default', ['js', 'css']); | ||
gulp.task('default', ['bower', 'vendor', 'js', 'css']); |
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
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,100 @@ | ||
var sendshit = angular.module('sendsh.it', ['ngRoute', 'ngSanitize', 'ngProgressLite']); | ||
|
||
sendshit.config(['$routeProvider', 'ngProgressLiteProvider', function($routeProvider, ngProgressLiteProvider) { | ||
|
||
if(!window.FileReader || !window.FormData || !window.Blob) { | ||
throw new Error('Your browser does not support required features.'); | ||
} | ||
|
||
$routeProvider.when('/', { | ||
|
||
controller: 'UploadController', | ||
templateUrl: 'views/upload.html' | ||
|
||
}).when('/:downloadId/:downloadPassword', { | ||
|
||
controller: 'DownloadController', | ||
templateUrl: 'views/download.html' | ||
|
||
}).otherwise({ | ||
|
||
redirectTo: '/' | ||
|
||
}); | ||
|
||
ngProgressLiteProvider.settings.speed = 1; | ||
ngProgressLiteProvider.settings.minimum = 0.1; | ||
ngProgressLiteProvider.settings.ease = 'linear'; | ||
|
||
}]); | ||
|
||
sendshit.factory('messages', ['$rootScope', function($rootScope){ | ||
|
||
var message = ''; | ||
var messages = {}; | ||
|
||
messages.addMsg = function(msg, ellipsis) { | ||
|
||
ellipsis = typeof ellipsis !== 'undefined' ? ellipsis : false; | ||
|
||
if(ellipsis === true) { | ||
msg = msg + '<i class="ellipsis"><i>.</i><i>.</i><i>.</i></i>'; | ||
} | ||
|
||
message = msg; | ||
|
||
$rootScope.$broadcast('message:updated', message); | ||
|
||
}; | ||
|
||
messages.getMsg = function() { | ||
return message; | ||
}; | ||
|
||
return messages; | ||
|
||
}]); | ||
|
||
sendshit.factory('triplesecProgress', ['$log', 'ngProgressLite', function($log, ngProgressLite) { | ||
|
||
var triplesecProgress = {}; | ||
|
||
triplesecProgress.updateProgress = function(obj) { | ||
|
||
var percent = obj.i / obj.total; | ||
|
||
if(obj.what == 'pbkdf2 (pass 1)' || obj.what == 'pbkdf2 (pass 2)'){ | ||
this.logProgress('Running PBKDF2', percent); | ||
} | ||
|
||
if(obj.what == 'scrypt'){ | ||
this.logProgress('Scrypt', percent); | ||
} | ||
|
||
if(obj.what == 'salsa20'){ | ||
this.logProgress('Salsa20', percent); | ||
} | ||
|
||
if(obj.what == 'twofish'){ | ||
this.logProgress('Twofish-CTR', percent); | ||
} | ||
|
||
if(obj.what == 'aes'){ | ||
this.logProgress('AES-256-CTR', percent); | ||
} | ||
|
||
if(obj.what == 'HMAC-SHA512-SHA3'){ | ||
this.logProgress('Generating HMAC', percent); | ||
} | ||
|
||
}; | ||
|
||
triplesecProgress.logProgress = function(text, percent) | ||
{ | ||
$log.log(text + ': ' + Math.round(percent * 100) + '%'); | ||
ngProgressLite.set(parseFloat(percent.toFixed(1))); | ||
}; | ||
|
||
return triplesecProgress; | ||
|
||
}]); |
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,30 @@ | ||
sendshit.controller('DownloadController', ['$scope', '$routeParams', 'decryptor', 'fileReader', 'messages', function($scope, $routeParams, decryptor, fileReader, messages) { | ||
|
||
var password = $routeParams.downloadPassword; | ||
|
||
decryptor.downloadFile('download?id=' + $routeParams.downloadId).then(function(data) { | ||
|
||
var blob = new Blob([data], {type: 'application/octet-stream'}); | ||
|
||
return fileReader.readAsText(blob); | ||
|
||
}).then(function(file) { | ||
|
||
return decryptor.decryptFile(file, password); | ||
|
||
}).then(function(decrypted) { | ||
|
||
messages.addMsg('Done'); | ||
saveAs(decrypted.blob, decrypted.name); | ||
|
||
}, function(error) { | ||
|
||
messages.addMsg(error); | ||
|
||
}); | ||
|
||
$scope.$on('message:updated', function(event, message) { | ||
$scope.message = message; | ||
}); | ||
|
||
}]); |
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,41 @@ | ||
sendshit.controller('UploadController', ['$scope', '$q', 'encryptor', 'fileReader', 'messages', function($scope, $q, encryptor, fileReader, messages) { | ||
|
||
$scope.fileUploaded = false; | ||
|
||
$scope.uploadFile = function(event) { | ||
|
||
var file = $scope.uploadedFile; | ||
|
||
if(file.size > 5000000) { | ||
messages.addMsg('File must be under 5MB'); | ||
return false; | ||
} | ||
|
||
$scope.uploadFieldText = file.name; | ||
|
||
$q.all([fileReader.readAsDataUrl(file), encryptor.generateKey()]).then(function(data){ | ||
|
||
return encryptor.encryptFile(data[0].name, data[0].reader, data[1]); | ||
|
||
}).then(function(encrypted) { | ||
|
||
return encryptor.uploadFile(encrypted); | ||
|
||
}).then(function(link) { | ||
|
||
$scope.fileUploaded = true; | ||
$scope.uploadLink = link; | ||
|
||
}, function(error) { | ||
|
||
messages.addMsg(error); | ||
|
||
}); | ||
|
||
}; | ||
|
||
$scope.$on('message:updated', function(event, message) { | ||
$scope.message = message; | ||
}); | ||
|
||
}]); |
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 @@ | ||
sendshit.directive('selectOnClick', function () { | ||
return { | ||
restrict: 'A', | ||
link: function (scope, element) { | ||
var focusedElement; | ||
element.on('click', function () { | ||
if (focusedElement != this) { | ||
this.select(); | ||
focusedElement = this; | ||
} | ||
}); | ||
element.on('blur', function () { | ||
focusedElement = null; | ||
}); | ||
} | ||
}; | ||
}); |
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,12 @@ | ||
sendshit.directive('uploadOnChange', function() { | ||
return { | ||
require:"ngModel", | ||
restrict: 'A', | ||
link: function($scope, el, attrs, ngModel){ | ||
el.bind('change', function(event){ | ||
ngModel.$setViewValue(event.target.files[0]); | ||
$scope.$apply(); | ||
}); | ||
} | ||
}; | ||
}); |
Oops, something went wrong.