mongo_browser 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,6 +6,8 @@ log/*.log
6
6
  tmp
7
7
  reports
8
8
 
9
+ Gemfile.lock
10
+
9
11
  .idea
10
12
  *.iml
11
13
  *.gem
@@ -1,32 +1,7 @@
1
- #= require vendor/jquery
2
- #= require vendor/bootstrap
3
- #= require vendor/bootbox
4
- #
1
+ #= require ujs
5
2
  #= require app/table_filter
6
3
 
7
4
  $(document).ready ->
8
5
  $("form.filter").each (index, form) ->
9
6
  $form = $(form)
10
7
  filter = new TableFilter($form)
11
-
12
- $("a[data-method]").click (event) ->
13
- event.preventDefault()
14
-
15
- $link = $(event.target)
16
-
17
- createAndSubmitForm = ->
18
- action = $link.attr("href")
19
- $form = $("<form />").attr("method", "post").attr("action", action)
20
-
21
- method = $link.data("method")
22
- $metadataInput = $("<input />").attr("type", "hidden").attr("name", "_method").val(method)
23
-
24
- $form.hide().append($metadataInput).appendTo("body");
25
- $form.submit()
26
-
27
- confirmationMessage = $link.data("confirm")
28
- if confirmationMessage?
29
- bootbox.confirm confirmationMessage, (confirmed) =>
30
- createAndSubmitForm() if confirmed
31
- else
32
- createAndSubmitForm()
@@ -0,0 +1,23 @@
1
+ $(document).ready ->
2
+ # Handles PUT, DELETE, POST methods inside links
3
+ $("a[data-method]").click (event) ->
4
+ event.preventDefault()
5
+
6
+ $link = $(event.target)
7
+
8
+ createAndSubmitForm = ->
9
+ action = $link.attr("href")
10
+ $form = $("<form />").attr("method", "post").attr("action", action)
11
+
12
+ method = $link.data("method")
13
+ $metadataInput = $("<input />").attr("type", "hidden").attr("name", "_method").val(method)
14
+
15
+ $form.hide().append($metadataInput).appendTo("body");
16
+ $form.submit()
17
+
18
+ confirmationMessage = $link.data("confirm")
19
+ if confirmationMessage?
20
+ bootbox.confirm confirmationMessage, (confirmed) =>
21
+ createAndSubmitForm() if confirmed
22
+ else
23
+ createAndSubmitForm()
@@ -0,0 +1,3 @@
1
+ #= require jquery
2
+ #= require bootstrap
3
+ #= require bootbox
@@ -1,8 +1,8 @@
1
1
  /*
2
- *= require_self
3
- *= require vendor/bootstrap
4
- *= require vendor/bootstrap-responsive
5
- */
2
+ *= require bootstrap
3
+ *= require_self
4
+ */
5
+
6
6
  body {
7
7
  position: relative;
8
8
  padding-top: 40px;
@@ -16,6 +16,7 @@ table.table {
16
16
  &.document pre {
17
17
  background: none;
18
18
  border: 0px;
19
+ padding: 0px;
19
20
  display: inline;
20
21
  }
21
22
 
@@ -25,7 +25,7 @@
25
25
  <% @documents.each do |document| %>
26
26
  <tr class="document">
27
27
  <td><%= document['_id'] %></td>
28
- <td><%= document.ai(html: true) %></td>
28
+ <td><%= document.ai(html: true).gsub("BSON::", "") %></td>
29
29
  <td>
30
30
  <a href="/databases/<%= params[:db_name] %>/collections/<%= params[:collection_name] %>/<%= document['_id'] %>" class="btn btn-danger" data-method="delete" data-confirm="Are you sure?">
31
31
  <i class="icon-remove-circle"></i>
@@ -1,18 +1,7 @@
1
1
  <div class="navbar-inner">
2
2
  <div class="container">
3
- <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
4
- <span class="icon-bar"></span>
5
- <span class="icon-bar"></span>
6
- <span class="icon-bar"></span>
7
- </a>
8
3
  <a class="brand" href="/">MongoBrowser</a>
9
4
  <div class="nav-collapse collapse">
10
- <!--<ul class="nav">-->
11
- <!--<li class="dropdown-toggle">-->
12
- <!--<a class="dropdown">Test</a>-->
13
- <!--</li>-->
14
- <!--</ul>-->
15
-
16
5
  <% if params[:db_name] %>
17
6
  <ul class="nav breadcrumbs">
18
7
  <% unless params[:collection_name] %>
data/app/views/layout.erb CHANGED
@@ -14,6 +14,7 @@
14
14
  <%= yield %>
15
15
  </div>
16
16
 
17
+ <script src="/assets/vendor.js"></script>
17
18
  <script src="/assets/application.js"></script>
18
19
  </body>
19
20
  </html>
@@ -1,3 +1,14 @@
1
+ require "sinatra"
2
+ require "sinatra/reloader"
3
+ require "sinatra/flash"
4
+ require "will_paginate-bootstrap"
5
+
6
+ require "sprockets"
7
+ require "sass"
8
+ require "coffee_script"
9
+
10
+ require "mongo_browser/middleware/sprockets_sinatra"
11
+
1
12
  module MongoBrowser
2
13
  class Application < Sinatra::Base
3
14
  configure :development do
@@ -10,7 +21,7 @@ module MongoBrowser
10
21
  set :root, File.join(File.dirname(__FILE__), "../../app")
11
22
  set :method_override, true
12
23
 
13
- use MongoBrowser::Middleware::SprocketsSinatra, :root => settings.root, :path => "assets"
24
+ use Middleware::SprocketsSinatra, :root => File.join(settings.root, "..")
14
25
  register WillPaginate::Sinatra
15
26
 
16
27
  # Databases list
@@ -7,11 +7,16 @@ module MongoBrowser
7
7
  path = options[:path] || "assets"
8
8
  @matcher = /^\/#{path}\/*/
9
9
  @environment = ::Sprockets::Environment.new(@root)
10
- @environment.append_path "assets/javascripts"
11
- @environment.append_path "assets/javascripts/vendor"
12
- @environment.append_path "assets/stylesheets"
13
- @environment.append_path "assets/stylesheets/vendor"
14
- @environment.append_path "assets/images"
10
+
11
+ # Application assets
12
+ @environment.append_path "app/assets/javascripts"
13
+ @environment.append_path "app/assets/stylesheets"
14
+ @environment.append_path "app/assets/images"
15
+
16
+ # Vendor assets
17
+ @environment.append_path "vendor/assets/javascripts"
18
+ @environment.append_path "vendor/assets/stylesheets"
19
+ @environment.append_path "vendor/assets/images"
15
20
  end
16
21
 
17
22
  def call(env)
@@ -1,3 +1,3 @@
1
1
  module MongoBrowser
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/mongo_browser.rb CHANGED
@@ -1,32 +1,25 @@
1
1
  require "mongo_browser/version"
2
2
 
3
- require "sinatra"
4
- require "sinatra/reloader"
5
- require "sinatra/flash"
6
-
7
- require "sprockets"
8
- require "sass"
9
- require "coffee_script"
10
-
11
- require "will_paginate-bootstrap"
12
3
  require "mongo"
13
4
  require "json"
14
5
  require "ap"
15
6
 
16
7
  module MongoBrowser
8
+ DEFAULT_HOST = "127.0.0.1"
9
+ DEFAULT_PORT = 27017
10
+
17
11
  class << self
18
12
  attr_writer :mongodb_host
19
13
  attr_writer :mongodb_port
20
14
 
21
15
  def mongodb_host
22
- @mongodb_host || "localhost"
16
+ @mongodb_host || DEFAULT_HOST
23
17
  end
24
18
 
25
19
  def mongodb_port
26
- @mongodb_port || 27017
20
+ @mongodb_port || DEFAULT_PORT
27
21
  end
28
22
  end
29
23
  end
30
24
 
31
- require "mongo_browser/middleware/sprockets_sinatra"
32
25
  require "mongo_browser/application"
@@ -28,7 +28,7 @@ class Fixtures
28
28
 
29
29
  def connection
30
30
  @connection ||= begin
31
- Mongo::Connection.new(MongoBrowser.mongodb_host, MongoBrowser.mongodb_port)
31
+ Mongo::Connection.new(MongoBrowser::DEFAULT_HOST, MongoBrowser.mongodb_port)
32
32
  end
33
33
  end
34
34
  end
@@ -32,7 +32,7 @@ class Mongod
32
32
 
33
33
  # Returns true is mongodb server is ready to use
34
34
  def responsive?
35
- Mongo::Connection.new(MongoBrowser.mongodb_host, port)
35
+ Mongo::Connection.new(MongoBrowser::DEFAULT_HOST, port)
36
36
  true
37
37
  rescue Mongo::ConnectionFailure
38
38
  false
@@ -45,7 +45,7 @@ class Mongod
45
45
  private
46
46
 
47
47
  def find_available_port
48
- server = TCPServer.new("127.0.0.1", 0)
48
+ server = TCPServer.new(MongoBrowser::DEFAULT_HOST, 0)
49
49
  server.addr[1]
50
50
  ensure
51
51
  server.close if server
@@ -66,7 +66,7 @@ class Mongod
66
66
  timeout = 10
67
67
 
68
68
  until responsive?
69
- raise "Could not start mongd" if Time.now - start_time >= timeout
69
+ raise "Could not start mongod" if Time.now - start_time >= timeout
70
70
 
71
71
  sleep wait_time
72
72
  wait_time *= 2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_browser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-21 00:00:00.000000000 Z
12
+ date: 2012-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -379,17 +379,12 @@ files:
379
379
  - LICENSE
380
380
  - README.md
381
381
  - Rakefile
382
- - app/assets/images/bootstrap/glyphicons-halflings-white.png
383
- - app/assets/images/bootstrap/glyphicons-halflings.png
384
382
  - app/assets/images/breadcrumb-separator.png
385
383
  - app/assets/javascripts/app/table_filter.js.coffee
386
384
  - app/assets/javascripts/application.js.coffee
387
- - app/assets/javascripts/vendor/bootbox.js
388
- - app/assets/javascripts/vendor/bootstrap.js
389
- - app/assets/javascripts/vendor/jquery.js
385
+ - app/assets/javascripts/ujs.js.coffee
386
+ - app/assets/javascripts/vendor.js.coffee
390
387
  - app/assets/stylesheets/application.css.scss
391
- - app/assets/stylesheets/vendor/bootstrap-responsive.css
392
- - app/assets/stylesheets/vendor/bootstrap.css
393
388
  - app/views/collections/index.erb
394
389
  - app/views/databases/index.erb
395
390
  - app/views/documents/index.erb
@@ -420,6 +415,13 @@ files:
420
415
  - spec/support/fixtures/databases.json
421
416
  - spec/support/matchers/have_flash_message.rb
422
417
  - spec/support/mongod.rb
418
+ - vendor/assets/images/bootstrap/glyphicons-halflings-white.png
419
+ - vendor/assets/images/bootstrap/glyphicons-halflings.png
420
+ - vendor/assets/javascripts/bootbox.js
421
+ - vendor/assets/javascripts/bootstrap.js
422
+ - vendor/assets/javascripts/jquery.js
423
+ - vendor/assets/stylesheets/bootstrap-responsive.css
424
+ - vendor/assets/stylesheets/bootstrap.css
423
425
  homepage: https://github.com/lucassus/mongo_browser
424
426
  licenses: []
425
427
  post_install_message: