humongous 0.1.8.beta → 0.1.9.beta

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -15,7 +15,7 @@ and run on terminal/console
15
15
  humongous
16
16
 
17
17
  And you are good to go it will open this in a browser or you can navigate it on port [9000](http://0.0.0.0:9000)
18
- to stope the server run the command again with -K option
18
+ to stop the server run the command again with -K option
19
19
 
20
20
  humongous -K
21
21
 
@@ -48,7 +48,7 @@ For more info write me at me[at]bagwanpankaj.com
48
48
 
49
49
  ## Support
50
50
 
51
- Currently it only supports Ruby version >= 1.9.2
51
+ Currently it only supports Ruby version >= 1.8.7. Humongous has been tested on MRI 18, MRI 19 and JRuby.
52
52
 
53
53
  ## TODO's
54
54
 
@@ -56,7 +56,8 @@ There are lot of things and area to improve and develop. Since it in pre release
56
56
 
57
57
  * Error Handling [DONE]
58
58
  * Authentication module [DONE]
59
- * Better UI (need a real contribution here)
59
+ * Sophisticated Querying support [In Progress]
60
+ * Better UI (need a real contribution here) [In Progress]
60
61
  * Better documentation
61
62
  * Example series
62
63
 
data/lib/humongous.rb CHANGED
@@ -1,11 +1,7 @@
1
1
  require 'rubygems'
2
- # require 'bundler'
3
- # require "bundler/setup"
4
-
5
2
  require "sinatra/base"
6
3
  require "mongo"
7
4
  require "json"
8
- require "crack"
9
5
  require 'humongous/monkey_patch'
10
6
  require 'humongous/application'
11
7
  require 'humongous/version'
@@ -109,6 +109,10 @@ module Humongous
109
109
  end
110
110
  options
111
111
  end
112
+
113
+ def json_converter( params_json )
114
+ params_json.gsub(/(\w+):/, '"\1":')
115
+ end
112
116
 
113
117
  end
114
118
 
@@ -154,12 +158,14 @@ module Humongous
154
158
  post "/database/:db_name/collection/:collection_name/page/:page" do
155
159
  selector = {}
156
160
  opts = {}
157
- query = Crack::JSON.parse(params[:query])
158
- query["_id"] = BSON::ObjectId.from_string(query["_id"]) if query && !!query["_id"]
159
- selector = selector.merge(query) if !!query
160
- opts[:fields] = params[:fields].split(",").collect(&:strip) unless params[:fields].empty?
161
+ if params[:query].present?
162
+ query = JSON.parse(json_converter(params[:query]))
163
+ query["_id"] = BSON::ObjectId.from_string(query["_id"]) if query["_id"].present?
164
+ selector = selector.merge(query)
165
+ end
166
+ opts[:fields] = params[:fields].split(",").collect(&:strip) unless params[:fields].blank?
161
167
  opts[:skip] = params[:skip].to_i
162
- opts[:sort] = Crack::JSON.parse(params[:sort])
168
+ opts[:sort] = JSON.parse(json_converter(params[:sort])) if params[:sort].present?
163
169
  opts[:limit] = params[:limit].to_i
164
170
  opts = default_opts.merge(opts)
165
171
  @database = @connection.db(params[:db_name])
@@ -188,14 +194,41 @@ module Humongous
188
194
 
189
195
  post "/database" do
190
196
  @connection.db(params["database_name"]).create_collection("test");
197
+ content_type :json
191
198
  { :status => "OK", :created => true, :name => params["database_name"] }.to_json
192
199
  end
193
200
 
194
201
  post "/database/:database_name/collection" do
195
202
  @connection.db(params["database_name"]).create_collection(params[:collection_name]);
203
+ content_type :json
196
204
  { :status => "OK", :created => true, :name => params["collection_name"] }.to_json
197
205
  end
198
206
 
207
+ delete "/database/:database_name/collection/:collection_name/remove" do
208
+ selector = {}
209
+ opts = {}
210
+ query = JSON.parse(json_converter(params[:remove_query])) if params[:remove_query].present?
211
+ query["_id"] = BSON::ObjectId.from_string(query["_id"]) if query.present? && query["_id"].present?
212
+ selector = selector.merge(query) if !!query
213
+ @database = @connection.db(params["database_name"])
214
+ @collection = @database.collection(params["collection_name"])
215
+ content_type :json
216
+ { :removed => @collection.remove( selector, opts ), :status => "OK" }.to_json
217
+ end
218
+
219
+ post "/database/:database_name/collection/:collection_name/insert" do
220
+ created = false
221
+ @database = @connection.db(params[:database_name])
222
+ @collection = @database.collection(params[:collection_name])
223
+ if params[:doc].present?
224
+ doc = JSON.parse(json_converter(params[:doc]))
225
+ @collection.insert(doc)
226
+ created = true
227
+ end
228
+ content_type :json
229
+ { :created => created, :id => true, :status => "OK" }.to_json
230
+ end
231
+
199
232
  end
200
233
 
201
234
  end
@@ -7,6 +7,10 @@ module Humongous
7
7
  self.respond_to?(:empty?) ? empty? : nil?
8
8
  end
9
9
 
10
+ def present?
11
+ !blank?
12
+ end
13
+
10
14
  def self.activate!
11
15
  Object.send(:include, self)
12
16
  end
@@ -39,7 +39,7 @@ $(document).ready(function(){
39
39
  app.helpers.yielder( app.html.query_browser, {} );
40
40
  e.preventDefault();
41
41
  } );
42
- $( '.yielder form' ).live( 'submit', function( e ){
42
+ $( '.yielder form.find_form' ).live( 'submit', function( e ){
43
43
  var db = app.storage.get("database"), coll = app.storage.get("collection")
44
44
  if(db && !coll){
45
45
  alert("Please choose a collection first.")
@@ -7,41 +7,8 @@ app.html.query_browser = {
7
7
  this.clear();
8
8
  return(
9
9
  { tag: "DIV", cls: "query_browser", children: [
10
- { tag: "FORM", children:
11
- [
12
- { tag: "FIELDSET", children: [
13
- // this._get_legend(),
14
- { tag: "DIV", cls: "input_row", children: [
15
- { tag: "DIV", cls: "query_form", children: [
16
- { tag: "LABEL", "for": "query", text: "Query" },
17
- { tag: "INPUT", type: "text", placeholder: "Find All", id: "query", size: "41", name: "query" }
18
- ] },
19
- { tag: "DIV", cls: "sort_form", children: [
20
- { tag: "LABEL", "for": "sort", text: "Sort" },
21
- { tag: "INPUT", type: "text", placeholder: "[\"name\", \"asc\"]", id: "sort", name: "sort" }
22
- ] },
23
- { tag: "DIV", cls: "clear" }
24
- ] },
25
- // { tag: "DIV", cls: "clear" },
26
- { tag: "DIV", cls: "input_row", children: [
27
- { tag: "DIV", cls: "fields_form", children: [
28
- { tag: "LABEL", "for": "fields", text: "Fields" },
29
- { tag: "INPUT", type: "text", placeholder: "field1, field2", id: "fields", size: "30", name: "fields" }
30
- ] },
31
- { tag: "DIV", cls: "skip_form", children: [
32
- { tag: "LABEL", "for": "skip", text: "Skip" },
33
- { tag: "INPUT", type: "text", placeholder: "0", id: "skip", size: "5", name: "skip", value: "0", cls: 'number' }
34
- ] },
35
- { tag: "DIV", cls: "limit_form", children: [
36
- { tag: "LABEL", "for": "limit", text: "Limit" },
37
- { tag: "INPUT", type: "text", placeholder: "10", id: "limit", size: "5", name: "limit", value: "10", cls: 'number' }
38
- ] },
39
- { tag: "INPUT", type: 'submit', cls: "submit_btn btn", value: "Search" },
40
- { tag: "DIV", cls: "clear" }
41
- ] }
42
- ] }
43
- ]
44
- },
10
+ this._query_pills(),
11
+ { tag: "DIV", cls: "query_form_container", child: app.query_forms["find_form"] },
45
12
  { tag: "DIV", cls: "query_result" },
46
13
  { tag: "DIV", id: "object_modal", "style": "display: none; ", cls: "modal hide fade", children: [
47
14
  { tag: "DIV", cls: "modal-header", children: [
@@ -77,6 +44,23 @@ app.html.query_browser = {
77
44
  $('#object_modal').modal('toggle');
78
45
  }
79
46
  })
47
+ },
48
+ _query_pills: function(){
49
+ return(
50
+ { tag: "UL", cls: "pills", children: [
51
+ { tag: "LI", cls: "active", child: { tag: "A", href: "#", text: "Find", show: "find_form" }, onClick: this._pills_click_handler },
52
+ { tag: "LI", child: { tag: "A", href: "#", text: "Remove", show: "remove_form" }, onClick: this._pills_click_handler },
53
+ { tag: "LI", child: { tag: "A", href: "#", text: "Insert", show: "insert_form" }, onClick: this._pills_click_handler },
54
+ // { tag: "LI", child: { tag: "A", href: "#", text: "MapReduce", show: "mapreduce_form" }, onClick: this._pills_click_handler }
55
+ ]}
56
+ )
57
+ },
58
+ _pills_click_handler: function(e){
59
+ var click_container = $(e.target);
60
+ $( click_container ).parent().siblings().removeClass( "active" );
61
+ $( click_container ).parent().addClass( "active" );
62
+ $(".query_form_container").children().remove();
63
+ $( app.query_forms[click_container.attr("show")] ).appendTo(".query_form_container")
80
64
  }
81
65
  };
82
66
  app.html.build_results = {
@@ -185,4 +169,116 @@ app.html.template.select_field = app.merge( app.html.template.abstract_field, {
185
169
  };
186
170
  return res;
187
171
  }
188
- } );
172
+ } );
173
+ app.query_forms = {
174
+ find_form: { tag: "FORM", cls: "find_form", children:
175
+ [
176
+ { tag: "FIELDSET", children: [
177
+ // this._get_legend(),
178
+ { tag: "DIV", cls: "input_row", children: [
179
+ { tag: "DIV", cls: "query_form", children: [
180
+ { tag: "LABEL", "for": "query", text: "Query" },
181
+ { tag: "INPUT", type: "text", placeholder: "Find All", id: "query", size: "41", name: "query" }
182
+ ] },
183
+ { tag: "DIV", cls: "sort_form", children: [
184
+ { tag: "LABEL", "for": "sort", text: "Sort" },
185
+ { tag: "INPUT", type: "text", placeholder: "[\"name\", \"asc\"]", id: "sort", name: "sort" }
186
+ ] },
187
+ { tag: "DIV", cls: "clear" }
188
+ ] },
189
+ // { tag: "DIV", cls: "clear" },
190
+ { tag: "DIV", cls: "input_row", children: [
191
+ { tag: "DIV", cls: "fields_form", children: [
192
+ { tag: "LABEL", "for": "fields", text: "Fields" },
193
+ { tag: "INPUT", type: "text", placeholder: "field1, field2", id: "fields", size: "30", name: "fields" }
194
+ ] },
195
+ { tag: "DIV", cls: "skip_form", children: [
196
+ { tag: "LABEL", "for": "skip", text: "Skip" },
197
+ { tag: "INPUT", type: "text", placeholder: "0", id: "skip", size: "5", name: "skip", value: "0", cls: 'number' }
198
+ ] },
199
+ { tag: "DIV", cls: "limit_form", children: [
200
+ { tag: "LABEL", "for": "limit", text: "Limit" },
201
+ { tag: "INPUT", type: "text", placeholder: "10", id: "limit", size: "5", name: "limit", value: "10", cls: 'number' }
202
+ ] },
203
+ { tag: "INPUT", type: 'submit', cls: "submit_btn btn", value: "Search" },
204
+ { tag: "DIV", cls: "clear" }
205
+ ] }
206
+ ] }
207
+ ]
208
+ },
209
+ remove_form: { tag: "FORM", cls: "remove_form", method: "DELETE", child: {
210
+ tag: "FIELDSET", children: [
211
+ { tag: "DIV", cls: "input_row", children: [
212
+ { tag: "DIV", cls: "query_form", children: [
213
+ { tag: "LABEL", "for": "remove_query", text: "Query", style: "margin: 0 10px 0" },
214
+ { tag: "TEXTAREA", style: "height: 50px; width: 300px", placeholder: "{}", id: "remove_query", name: "remove_query" }
215
+ ] },
216
+ { tag: "INPUT", type: 'submit', cls: "submit_btn btn", value: "Remove" },
217
+ { tag: "DIV", cls: "clear" }
218
+ ] }
219
+ ]
220
+ }, onSubmit: function(e){
221
+ e.preventDefault();
222
+ app.ax({
223
+ url: "/database/" + app.storage.get("database") + "/collection/" + app.storage.get("collection") + "/remove",
224
+ data: $(this).serialize(),
225
+ type: $(this).attr("method"),
226
+ success: function( data ){
227
+ console.log(data);
228
+ if(data.removed){
229
+ var alert = { tag: "DIV", cls: "alert-message success fade in", "data-alert": "true", children: [
230
+ { tag: "A", cls: "close", href: "#", text: "x" },
231
+ { tag: "P", text: "Query ran successfully." }
232
+ ] };
233
+ }else{
234
+ var alert = { tag: "DIV", cls: "alert-message error fade in", "data-alert": "true", children: [
235
+ { tag: "A", cls: "close", href: "#", text: "x" },
236
+ { tag: "P", text: "Query has thrown error. Please check again." }
237
+ ] };
238
+ }
239
+ $( ".query_result" ).children().remove();
240
+ $( alert ).appendTo( '.query_result' );
241
+ }
242
+ })
243
+ }
244
+ },
245
+ insert_form: { tag: "FORM", cls: "insert_form", method: "POST", child: {
246
+ tag: "FIELDSET", children: [
247
+ { tag: "DIV", cls: "input_row", children: [
248
+ { tag: "DIV", cls: "query_form", children: [
249
+ { tag: "LABEL", "for": "insert_query", text: "Query", style: "margin: 0 10px 0" },
250
+ { tag: "TEXTAREA", style: "height: 100px; width: 400px", placeholder: "{}", id: "insert_query", name: "doc" }
251
+ ] },
252
+ { tag: "INPUT", type: 'submit', cls: "submit_btn btn", value: "Insert" },
253
+ { tag: "DIV", cls: "clear" }
254
+ ] }
255
+ ]
256
+ }, onSubmit: function(e){
257
+ e.preventDefault();
258
+ app.ax({
259
+ url: "/database/" + app.storage.get("database") + "/collection/" + app.storage.get("collection") + "/insert",
260
+ data: $(this).serialize(),
261
+ type: $(this).attr("method"),
262
+ success: function( data ){
263
+ console.log(data);
264
+ if(data.created){
265
+ var alert = { tag: "DIV", cls: "alert-message success fade in", "data-alert": "true", children: [
266
+ { tag: "A", cls: "close", href: "#", text: "x" },
267
+ { tag: "P", text: "Query ran successfully." }
268
+ ] };
269
+ }else{
270
+ var alert = { tag: "DIV", cls: "alert-message error fade in", "data-alert": "true", children: [
271
+ { tag: "A", cls: "close", href: "#", text: "x" },
272
+ { tag: "P", text: "Query has thrown error. Please check again." }
273
+ ] };
274
+ }
275
+ $( ".query_result" ).children().remove();
276
+ $( alert ).appendTo( '.query_result' );
277
+ }
278
+ });
279
+ }
280
+ }//,
281
+ // mapreduce_form: {
282
+ // tag: "DIV", cls: "mapreduce_form", text: "mapreduce_form"
283
+ // },
284
+ }
@@ -1,3 +1,3 @@
1
1
  module Humongous
2
- VERSION = "0.1.8.beta"
2
+ VERSION = "0.1.9.beta"
3
3
  end
@@ -24,6 +24,7 @@
24
24
  <script type='text/javascript' src='/javascripts/jquery.min.js'></script>
25
25
  <script type='text/javascript' src='/javascripts/jquery.nohtml.js'></script>
26
26
  <script type='text/javascript' src='/javascripts/bootstrap-modal.js'></script>
27
+ <script type='text/javascript' src='/javascripts/bootstrap-alerts.js'></script>
27
28
 
28
29
  <script type='text/javascript' src='/javascripts/core.js'></script>
29
30
  <script type='text/javascript' src='/javascripts/storage.js'></script>
metadata CHANGED
@@ -1,92 +1,113 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: humongous
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.8.beta
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1605700641
5
5
  prerelease: 6
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 9
10
+ - beta
11
+ version: 0.1.9.beta
6
12
  platform: ruby
7
- authors:
13
+ authors:
8
14
  - bagwanpankaj
9
15
  autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
- date: 2012-01-21 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2012-01-21 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: vegas
16
- requirement: &2160924140 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
19
- - - =
20
- - !ruby/object:Gem::Version
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 11
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 8
21
34
  version: 0.1.8
22
35
  type: :runtime
23
- prerelease: false
24
- version_requirements: *2160924140
25
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
26
38
  name: sinatra
27
- requirement: &2160923660 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
28
41
  none: false
29
- requirements:
30
- - - =
31
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 31
46
+ segments:
47
+ - 1
48
+ - 3
49
+ - 2
32
50
  version: 1.3.2
33
51
  type: :runtime
34
- prerelease: false
35
- version_requirements: *2160923660
36
- - !ruby/object:Gem::Dependency
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
37
54
  name: bson_ext
38
- requirement: &2160923120 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
39
57
  none: false
40
- requirements:
41
- - - =
42
- - !ruby/object:Gem::Version
58
+ requirements:
59
+ - - "="
60
+ - !ruby/object:Gem::Version
61
+ hash: 7
62
+ segments:
63
+ - 1
64
+ - 5
65
+ - 2
43
66
  version: 1.5.2
44
67
  type: :runtime
45
- prerelease: false
46
- version_requirements: *2160923120
47
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
48
70
  name: mongo
49
- requirement: &2160922380 !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
50
73
  none: false
51
- requirements:
52
- - - =
53
- - !ruby/object:Gem::Version
74
+ requirements:
75
+ - - "="
76
+ - !ruby/object:Gem::Version
77
+ hash: 7
78
+ segments:
79
+ - 1
80
+ - 5
81
+ - 2
54
82
  version: 1.5.2
55
83
  type: :runtime
56
- prerelease: false
57
- version_requirements: *2160922380
58
- - !ruby/object:Gem::Dependency
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
59
86
  name: json
60
- requirement: &2160921520 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - =
64
- - !ruby/object:Gem::Version
65
- version: 1.6.5
66
- type: :runtime
67
87
  prerelease: false
68
- version_requirements: *2160921520
69
- - !ruby/object:Gem::Dependency
70
- name: crack
71
- requirement: &2160920480 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
72
89
  none: false
73
- requirements:
74
- - - =
75
- - !ruby/object:Gem::Version
76
- version: 0.3.1
90
+ requirements:
91
+ - - "="
92
+ - !ruby/object:Gem::Version
93
+ hash: 5
94
+ segments:
95
+ - 1
96
+ - 6
97
+ - 5
98
+ version: 1.6.5
77
99
  type: :runtime
78
- prerelease: false
79
- version_requirements: *2160920480
80
- description: ! 'Humongous: A Ruby way to browse and maintain mongo instance. Using
81
- HTML5.'
100
+ version_requirements: *id005
101
+ description: "Humongous: A Ruby way to browse and maintain mongo instance. Using HTML5."
82
102
  email: bagwanpankaj@gmail.com
83
- executables:
103
+ executables:
84
104
  - humongous
85
105
  extensions: []
86
- extra_rdoc_files:
106
+
107
+ extra_rdoc_files:
87
108
  - LICENSE.txt
88
109
  - README.markdown
89
- files:
110
+ files:
90
111
  - LICENSE.txt
91
112
  - bin/humongous
92
113
  - lib/humongous.rb
@@ -107,28 +128,42 @@ files:
107
128
  - lib/humongous/views/index.erb
108
129
  - README.markdown
109
130
  homepage: http://github.com/bagwanpankaj/humongous
110
- licenses:
131
+ licenses:
111
132
  - MIT
112
133
  post_install_message:
113
134
  rdoc_options: []
114
- require_paths:
135
+
136
+ require_paths:
115
137
  - lib
116
- required_ruby_version: !ruby/object:Gem::Requirement
138
+ required_ruby_version: !ruby/object:Gem::Requirement
117
139
  none: false
118
- requirements:
119
- - - ! '>='
120
- - !ruby/object:Gem::Version
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ hash: 57
144
+ segments:
145
+ - 1
146
+ - 8
147
+ - 7
121
148
  version: 1.8.7
122
- required_rubygems_version: !ruby/object:Gem::Requirement
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
150
  none: false
124
- requirements:
125
- - - ! '>'
126
- - !ruby/object:Gem::Version
151
+ requirements:
152
+ - - ">"
153
+ - !ruby/object:Gem::Version
154
+ hash: 25
155
+ segments:
156
+ - 1
157
+ - 3
158
+ - 1
127
159
  version: 1.3.1
128
160
  requirements: []
161
+
129
162
  rubyforge_project:
130
163
  rubygems_version: 1.8.10
131
164
  signing_key:
132
165
  specification_version: 3
133
- summary: ! 'Humongous: A Mongo Browser for Ruby'
166
+ summary: "Humongous: A Mongo Browser for Ruby"
134
167
  test_files: []
168
+
169
+ has_rdoc: