humongous 0.1.5.pre → 0.1.6.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +6 -2
- data/lib/humongous.rb +1 -0
- data/lib/humongous/application.rb +49 -12
- data/lib/humongous/monkey_patch.rb +26 -0
- data/lib/humongous/public/javascripts/application.js +16 -0
- data/lib/humongous/public/javascripts/core.js +5 -0
- data/lib/humongous/version.rb +1 -1
- data/lib/humongous/views/index.erb +53 -1
- metadata +14 -14
- data/VERSION +0 -1
data/README.markdown
CHANGED
|
@@ -46,12 +46,16 @@ For detailed info visit my blog [http://BagwanPankaj.com](http://bagwanpankaj.co
|
|
|
46
46
|
|
|
47
47
|
For more info write me at me[at]bagwanpankaj.com
|
|
48
48
|
|
|
49
|
+
## Support
|
|
50
|
+
|
|
51
|
+
Currently it only supports Ruby version >= 1.9.2
|
|
52
|
+
|
|
49
53
|
## TODO's
|
|
50
54
|
|
|
51
55
|
There are lot of things and area to improve and develop. Since it in pre release now, any bug report, issues and feature request is highly appreciated.
|
|
52
56
|
|
|
53
|
-
* Error Handling
|
|
54
|
-
* Authentication module
|
|
57
|
+
* -Error Handling-
|
|
58
|
+
* -Authentication module-
|
|
55
59
|
* Better UI (need a real contribution here)
|
|
56
60
|
* Better documentation
|
|
57
61
|
* Example series
|
data/lib/humongous.rb
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
# require './monkey_patch'
|
|
1
2
|
module Humongous
|
|
3
|
+
|
|
4
|
+
MonkeyPatch.activate!
|
|
5
|
+
|
|
2
6
|
class Application < Sinatra::Base
|
|
3
7
|
DEFAULT_OPTIONS = {
|
|
4
8
|
url: "localhost",
|
|
@@ -6,7 +10,9 @@ module Humongous
|
|
|
6
10
|
username: "",
|
|
7
11
|
password: ""
|
|
8
12
|
}
|
|
9
|
-
|
|
13
|
+
|
|
14
|
+
use Rack::Session::Pool, :expire_after => 2592000
|
|
15
|
+
|
|
10
16
|
dir = File.dirname(File.expand_path(__FILE__))
|
|
11
17
|
|
|
12
18
|
set :views, "#{dir}/views"
|
|
@@ -20,15 +26,42 @@ module Humongous
|
|
|
20
26
|
set :static, true
|
|
21
27
|
|
|
22
28
|
before do
|
|
23
|
-
@connection =
|
|
29
|
+
@connection = connection(params)
|
|
30
|
+
autanticate!
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
error Mongo::ConnectionFailure do
|
|
27
34
|
[502, headers, "Humongous is unable to find MongoDB instance. Check your MongoDB connection."]
|
|
28
35
|
end
|
|
29
36
|
|
|
37
|
+
error Mongo::OperationFailure do
|
|
38
|
+
halt 401, {'Content-Type' => 'text/javascript'}, { :errmsg => "Need to login", :ok => false }.to_json
|
|
39
|
+
end
|
|
40
|
+
|
|
30
41
|
helpers do
|
|
31
42
|
|
|
43
|
+
def connection(params)
|
|
44
|
+
opts = opts_to_connect(params)
|
|
45
|
+
session[:connection] ||= Mongo::Connection.new(opts[:url], opts[:port])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def autanticate!
|
|
49
|
+
@connection.apply_saved_authentication and return unless @connection.auths.blank?
|
|
50
|
+
return if params[:auth].blank?
|
|
51
|
+
@connection.add_auth(params[:auth][:db], params[:auth][:username], params[:auth][:password])
|
|
52
|
+
@connection.apply_saved_authentication
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def opts_to_connect(params = {})
|
|
56
|
+
return @options if @options && @options[:freeze]
|
|
57
|
+
@options = DEFAULT_OPTIONS
|
|
58
|
+
return @options if params.blank?
|
|
59
|
+
@options[:url] = params[:url]
|
|
60
|
+
@options[:port] = params[:port]
|
|
61
|
+
@options[:freeze] = true
|
|
62
|
+
@options
|
|
63
|
+
end
|
|
64
|
+
|
|
32
65
|
def get_uri(params = {})
|
|
33
66
|
@options = DEFAULT_OPTIONS
|
|
34
67
|
@options = @options.merge(params)
|
|
@@ -64,8 +97,6 @@ module Humongous
|
|
|
64
97
|
case v
|
|
65
98
|
when Hash
|
|
66
99
|
send(converter, v )
|
|
67
|
-
# else
|
|
68
|
-
# b[v]
|
|
69
100
|
end
|
|
70
101
|
end
|
|
71
102
|
doc
|
|
@@ -79,19 +110,25 @@ module Humongous
|
|
|
79
110
|
options
|
|
80
111
|
end
|
|
81
112
|
|
|
82
|
-
def default_opts
|
|
83
|
-
{ skip: 0, limit: 10 }
|
|
84
|
-
end
|
|
85
|
-
|
|
86
113
|
end
|
|
87
114
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
115
|
+
reciever = lambda do
|
|
116
|
+
begin
|
|
117
|
+
@databases = @connection.database_info
|
|
118
|
+
@server_info = @connection.server_info
|
|
119
|
+
@header_string = "Server #{@connection.host}:#{@connection.port} stats"
|
|
120
|
+
rescue Mongo::OperationFailure => e
|
|
121
|
+
@databases = []
|
|
122
|
+
@server_info = { :errmsg => "Need to login", :ok => false }
|
|
123
|
+
@header_string = "Server #{@connection.host}:#{@connection.port} stats"
|
|
124
|
+
@force_login = true
|
|
125
|
+
end
|
|
92
126
|
erb :index
|
|
93
127
|
end
|
|
94
128
|
|
|
129
|
+
get "/", &reciever
|
|
130
|
+
post "/", &reciever
|
|
131
|
+
|
|
95
132
|
get "/database/:db_name" do
|
|
96
133
|
@database = @connection.db(params[:db_name])
|
|
97
134
|
@header_string = "Database #{@database.name} (#{@database.collection_names.size}) stats"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Humongous
|
|
2
|
+
|
|
3
|
+
module MonkeyPatch
|
|
4
|
+
|
|
5
|
+
module MonkeyObject
|
|
6
|
+
def blank?
|
|
7
|
+
self.respond_to?(:empty?) ? empty? : nil?
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.activate!
|
|
11
|
+
Object.send(:include, self)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#monkey patch for string
|
|
16
|
+
module MonkeyString
|
|
17
|
+
def self.activate!
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.activate!
|
|
22
|
+
[MonkeyObject, MonkeyString].collect(&:activate!)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -3,6 +3,12 @@ $(document).ready(function(){
|
|
|
3
3
|
keyboard: true,
|
|
4
4
|
backdrop: "static"
|
|
5
5
|
});
|
|
6
|
+
$("#login_dialog a").click( function(e){
|
|
7
|
+
if(validate("#login_dialog .modal-body form")){
|
|
8
|
+
$("#login_dialog .modal-body form").submit();
|
|
9
|
+
}
|
|
10
|
+
e.preventDefault();
|
|
11
|
+
});
|
|
6
12
|
$("#loader").bind("ajaxSend", function(){
|
|
7
13
|
$( this ).modal('show');
|
|
8
14
|
}).bind("ajaxComplete", function(){
|
|
@@ -268,4 +274,14 @@ app.html.modal_skeleton = {
|
|
|
268
274
|
_el: function(){
|
|
269
275
|
return $(this.selector);
|
|
270
276
|
}
|
|
277
|
+
}
|
|
278
|
+
var validate = function(anchor){
|
|
279
|
+
var error = false;
|
|
280
|
+
$(anchor).find("input").each(function(index, field){
|
|
281
|
+
if($(field).val() == "" || $(field).val() == null){
|
|
282
|
+
error = true;
|
|
283
|
+
$(field).parent().parent().addClass("error");
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
return !error;
|
|
271
287
|
}
|
|
@@ -53,6 +53,11 @@ app.ajax = app.ax = function( options ){
|
|
|
53
53
|
var defaults = {
|
|
54
54
|
type: 'POST',
|
|
55
55
|
dataType: 'JSON',
|
|
56
|
+
error: function(error){
|
|
57
|
+
console.log("Seems server has been reset since last request.")
|
|
58
|
+
console.log(error.responseText)
|
|
59
|
+
window.location = "/";
|
|
60
|
+
}
|
|
56
61
|
};
|
|
57
62
|
options = $.extend( defaults, options );
|
|
58
63
|
console.log("making request with " + JSON.stringify( options, null, '\t' ) );
|
data/lib/humongous/version.rb
CHANGED
|
@@ -172,12 +172,64 @@
|
|
|
172
172
|
<img src="/images/ajax-loader.gif"></img>
|
|
173
173
|
</div>
|
|
174
174
|
</div>
|
|
175
|
+
<div id="login_dialog" style="display:none" class="modal">
|
|
176
|
+
<div class="modal-header">
|
|
177
|
+
<!-- <a href="#" class="close">x</a> -->
|
|
178
|
+
<h3>Provide MongoDB Access Credentials</h3>
|
|
179
|
+
</div>
|
|
180
|
+
<div class="modal-body">
|
|
181
|
+
<form action="/" method="post">
|
|
182
|
+
<fieldset>
|
|
183
|
+
<div class="clearfix">
|
|
184
|
+
<label for="url">Host</label>
|
|
185
|
+
<div class="input">
|
|
186
|
+
<input type="text" placeholder="Host" value="localhost" name="url" size="30"></input>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
<div class="clearfix">
|
|
190
|
+
<label for="port">Port</label>
|
|
191
|
+
<div class="input">
|
|
192
|
+
<input type="text" placeholder="Port" value="27017" name="port" size="30"></input>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
<div class="clearfix">
|
|
196
|
+
<label for="auth_db">Database</label>
|
|
197
|
+
<div class="input">
|
|
198
|
+
<input type="text" placeholder="Database" name="auth[db]" size="30"></input>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
<div class="clearfix">
|
|
202
|
+
<label for="auth_username">Username</label>
|
|
203
|
+
<div class="input">
|
|
204
|
+
<input type="text" placeholder="Username" name="auth[username]" size="30"></input>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
<div class="clearfix">
|
|
208
|
+
<label for="auth_password">Password</label>
|
|
209
|
+
<div class="input">
|
|
210
|
+
<input type="password" placeholder="Password" name="auth[password]" size="30"></input>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</fieldset>
|
|
214
|
+
</form>
|
|
215
|
+
</div>
|
|
216
|
+
<div class="modal-footer">
|
|
217
|
+
<a href="#" class="btn primary">Login</a>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
175
220
|
|
|
176
221
|
<footer>
|
|
177
222
|
<p>© Bagwan Pankaj 2012</p>
|
|
178
223
|
</footer>
|
|
179
224
|
|
|
180
225
|
</div> <!-- /container -->
|
|
181
|
-
|
|
226
|
+
<% if @force_login %>
|
|
227
|
+
<script type="text/javascript">
|
|
228
|
+
$("#login_dialog").modal({
|
|
229
|
+
backdrop: "static",
|
|
230
|
+
show: true
|
|
231
|
+
})
|
|
232
|
+
</script>
|
|
233
|
+
<% end %>
|
|
182
234
|
</body>
|
|
183
235
|
</html>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: humongous
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6.pre
|
|
5
5
|
prerelease: 6
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -13,7 +13,7 @@ date: 2012-01-21 00:00:00.000000000Z
|
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: vegas
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &2161117040 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - =
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: 0.1.8
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *2161117040
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: sinatra
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &2161116520 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - =
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: 1.3.2
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *2161116520
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: bson_ext
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &2161116000 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - =
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: 1.5.2
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *2161116000
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: mongo
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &2161115460 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - =
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: 1.5.2
|
|
55
55
|
type: :runtime
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *2161115460
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: json
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &2161114980 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - =
|
|
@@ -65,10 +65,10 @@ dependencies:
|
|
|
65
65
|
version: 1.6.5
|
|
66
66
|
type: :runtime
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *2161114980
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: crack
|
|
71
|
-
requirement: &
|
|
71
|
+
requirement: &2161114460 !ruby/object:Gem::Requirement
|
|
72
72
|
none: false
|
|
73
73
|
requirements:
|
|
74
74
|
- - =
|
|
@@ -76,7 +76,7 @@ dependencies:
|
|
|
76
76
|
version: 0.3.1
|
|
77
77
|
type: :runtime
|
|
78
78
|
prerelease: false
|
|
79
|
-
version_requirements: *
|
|
79
|
+
version_requirements: *2161114460
|
|
80
80
|
description: ! 'Humongous: A Ruby way to browse and maintain mongo instance. Using
|
|
81
81
|
HTML5.'
|
|
82
82
|
email: bagwanpankaj@gmail.com
|
|
@@ -88,10 +88,10 @@ extra_rdoc_files:
|
|
|
88
88
|
- README.markdown
|
|
89
89
|
files:
|
|
90
90
|
- LICENSE.txt
|
|
91
|
-
- VERSION
|
|
92
91
|
- bin/humongous
|
|
93
92
|
- lib/humongous.rb
|
|
94
93
|
- lib/humongous/version.rb
|
|
94
|
+
- lib/humongous/monkey_patch.rb
|
|
95
95
|
- lib/humongous/application.rb
|
|
96
96
|
- lib/humongous/public/images/favicon.ico
|
|
97
97
|
- lib/humongous/public/images/ajax-loader.gif
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.1.3.pre
|