aws-auth 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,117 @@
1
+ var UploadProgress = {
2
+ uploading: null,
3
+ monitor: function(upid) {
4
+ if(!this.periodicExecuter) {
5
+ $('upload-form').style.display = 'none';
6
+ $('progress-bar').style.display = 'block';
7
+ $('results').innerHTML = '<h3>Uploading File...</h3>';
8
+ this.periodicExecuter = new PeriodicalExecuter(function() {
9
+ if(!UploadProgress.uploading) return;
10
+ new Ajax.Request('/control/progress/' + upid, { method: 'get', onSuccess: function(response) { eval(response.responseText); } });
11
+ }, 3);
12
+ }
13
+
14
+ this.uploading = true;
15
+ this.StatusBar.create();
16
+ },
17
+
18
+ update: function(total, current) {
19
+ if(!this.uploading) return;
20
+ var status = current / total;
21
+ var statusHTML = status.toPercentage();
22
+ $('results').innerHTML = '<h3>Uploading File...</h3>' + statusHTML + "<br /><small>" + current.toHumanSize() + ' of ' + total.toHumanSize() + " uploaded.</small>";
23
+ this.StatusBar.update(status, statusHTML);
24
+ },
25
+
26
+ finish: function() {
27
+ this.uploading = false;
28
+ this.StatusBar.finish();
29
+ $('results').innerHTML = '<h3>Upload finished!</h3>';
30
+ setTimeout(function () { window.location.href=window.location.href; },2000);
31
+ },
32
+
33
+ cancel: function(msg) {
34
+ if(!this.uploading) return;
35
+ this.uploading = false;
36
+ if(this.StatusBar.statusText) this.StatusBar.statusText.innerHTML = msg || 'canceled';
37
+ },
38
+
39
+ StatusBar: {
40
+ statusBar: null,
41
+ statusText: null,
42
+ statusBarWidth: 500,
43
+
44
+ create: function() {
45
+ this.statusBar = this._createStatus('status-bar');
46
+ this.statusText = this._createStatus('status-text');
47
+ this.statusText.innerHTML = '0%';
48
+ this.statusBar.style.width = '0';
49
+ },
50
+
51
+ update: function(status, statusHTML) {
52
+ this.statusText.innerHTML = statusHTML;
53
+ this.statusBar.style.width = Math.floor(this.statusBarWidth * status) + 'px';
54
+ },
55
+
56
+ finish: function() {
57
+ this.statusText.innerHTML = '100%';
58
+ this.statusBar.style.width = '100%';
59
+ },
60
+
61
+ _createStatus: function(id) {
62
+ el = $(id);
63
+ if(!el) {
64
+ el = document.createElement('span');
65
+ el.setAttribute('id', id);
66
+ $('progress-bar').appendChild(el);
67
+ }
68
+ return el;
69
+ }
70
+ },
71
+
72
+ FileField: {
73
+ add: function() {
74
+ new Insertion.Bottom('file-fields', '<p style="display:none"><input id="data" name="data" type="file" /> <a href="#" onclick="UploadProgress.FileField.remove(this);return false;">x</a></p>')
75
+ $$('#file-fields p').last().visualEffect('blind_down', {duration:0.3});
76
+ },
77
+
78
+ remove: function(anchor) {
79
+ anchor.parentNode.visualEffect('drop_out', {duration:0.25});
80
+ }
81
+ }
82
+ }
83
+
84
+ Number.prototype.bytes = function() { return this; };
85
+ Number.prototype.kilobytes = function() { return this * 1024; };
86
+ Number.prototype.megabytes = function() { return this * (1024).kilobytes(); };
87
+ Number.prototype.gigabytes = function() { return this * (1024).megabytes(); };
88
+ Number.prototype.terabytes = function() { return this * (1024).gigabytes(); };
89
+ Number.prototype.petabytes = function() { return this * (1024).terabytes(); };
90
+ Number.prototype.exabytes = function() { return this * (1024).petabytes(); };
91
+ ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte', 'petabyte', 'exabyte'].each(function(meth) {
92
+ Number.prototype[meth] = Number.prototype[meth+'s'];
93
+ });
94
+
95
+ Number.prototype.toPrecision = function() {
96
+ var precision = arguments[0] || 2;
97
+ var s = Math.round(this * Math.pow(10, precision)).toString();
98
+ var pos = s.length - precision;
99
+ var last = s.substr(pos, precision);
100
+ return s.substr(0, pos) + (last.match("^0{" + precision + "}$") ? '' : '.' + last);
101
+ }
102
+
103
+ // (1/10).toPercentage()
104
+ // # => '10%'
105
+ Number.prototype.toPercentage = function() {
106
+ return (this * 100).toPrecision() + '%';
107
+ }
108
+
109
+ Number.prototype.toHumanSize = function() {
110
+ if(this < (1).kilobyte()) return this + " Bytes";
111
+ if(this < (1).megabyte()) return (this / (1).kilobyte()).toPrecision() + ' KB';
112
+ if(this < (1).gigabytes()) return (this / (1).megabyte()).toPrecision() + ' MB';
113
+ if(this < (1).terabytes()) return (this / (1).gigabytes()).toPrecision() + ' GB';
114
+ if(this < (1).petabytes()) return (this / (1).terabytes()).toPrecision() + ' TB';
115
+ if(this < (1).exabytes()) return (this / (1).petabytes()).toPrecision() + ' PB';
116
+ return (this / (1).exabytes()).toPrecision() + ' EB';
117
+ }
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aws-auth
3
+ version: !ruby/object:Gem::Version
4
+ hash: 59
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
+ platform: ruby
12
+ authors:
13
+ - David Ricciardi
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-24 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: sinatra
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: activerecord
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description: |
50
+ Rack middleware that provides AWS (Amazon Web Services) style authentication.
51
+
52
+ email: nricciar@gmail.com
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - README
59
+ files:
60
+ - lib/aws-auth/user.rb
61
+ - lib/aws-auth/admin.rb
62
+ - lib/aws-auth/tasks.rb
63
+ - lib/aws-auth.rb
64
+ - db/migrate/002_create_users.rb
65
+ - db/test.db
66
+ - db/aws-users.db
67
+ - public/js/upload_status.js
68
+ - public/js/prototype.js
69
+ - public/images/external-link.gif
70
+ - public/css/control.css
71
+ - Rakefile
72
+ - README
73
+ - aws-auth.yml
74
+ has_rdoc: true
75
+ homepage: http://github.com/nricciar/aws-auth
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options: []
80
+
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.7
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: AWS Style authentication middleware
108
+ test_files: []
109
+