mongov 0.0.3
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/.document +5 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +26 -0
- data/LICENSE.txt +0 -0
- data/README.md +13 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/bin/mongov +12 -0
- data/lib/mongov.rb +53 -0
- data/lib/public/bootstrap.css +2361 -0
- data/lib/public/favicon.ico +0 -0
- data/lib/public/mongov.css +95 -0
- data/lib/view_helpers.rb +55 -0
- data/lib/views/collection.erb +37 -0
- data/lib/views/database.erb +39 -0
- data/lib/views/document.erb +12 -0
- data/lib/views/embedded_collection.erb +5 -0
- data/lib/views/embedded_list.erb +5 -0
- data/lib/views/error.erb +8 -0
- data/lib/views/index.erb +14 -0
- data/lib/views/layout.erb +12 -0
- data/mongov.gemspec +71 -0
- metadata +144 -0
File without changes
|
@@ -0,0 +1,95 @@
|
|
1
|
+
.page-header {
|
2
|
+
padding: 20px 20px 10px;
|
3
|
+
}
|
4
|
+
|
5
|
+
section.collections ul {
|
6
|
+
margin:0;
|
7
|
+
}
|
8
|
+
|
9
|
+
section.collections ul li {
|
10
|
+
list-style:none;
|
11
|
+
padding:0;
|
12
|
+
}
|
13
|
+
|
14
|
+
section.collections table td:first-child {
|
15
|
+
width:150px;
|
16
|
+
}
|
17
|
+
|
18
|
+
|
19
|
+
table.document tr td.key {
|
20
|
+
width:150px;
|
21
|
+
color:#888;
|
22
|
+
font-family: Monaco, Andale Mono, Courier New, monospace;
|
23
|
+
font-size:11px;
|
24
|
+
text-align:right;
|
25
|
+
}
|
26
|
+
|
27
|
+
table.document h2 {
|
28
|
+
font-size:17px;
|
29
|
+
}
|
30
|
+
|
31
|
+
table.document table.document {
|
32
|
+
background-color:#f1f1f1;
|
33
|
+
}
|
34
|
+
|
35
|
+
table.document table.document table.document {
|
36
|
+
background-color:#fff;
|
37
|
+
}
|
38
|
+
|
39
|
+
table.document table.document table.document h2 {
|
40
|
+
font-size:16px;
|
41
|
+
}
|
42
|
+
|
43
|
+
section.collections ul.embedded-list {
|
44
|
+
margin-left:10px;
|
45
|
+
}
|
46
|
+
|
47
|
+
section.collections ul.embedded-list li {
|
48
|
+
list-style:square;
|
49
|
+
margin-left:10px;
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
caption {
|
56
|
+
text-align:left;
|
57
|
+
margin-left:20px;
|
58
|
+
padding:3px;
|
59
|
+
}
|
60
|
+
|
61
|
+
caption .label.mongo.id {
|
62
|
+
font-size:16px;
|
63
|
+
}
|
64
|
+
|
65
|
+
.label.mongo {
|
66
|
+
font-size:13px;
|
67
|
+
}
|
68
|
+
|
69
|
+
.label.mongo.id {
|
70
|
+
background-color: #62cffc;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
.mongo.label.error {
|
75
|
+
background-color: #f89406;
|
76
|
+
}
|
77
|
+
|
78
|
+
.mongo.label.true {
|
79
|
+
background-color: #46a546;
|
80
|
+
}
|
81
|
+
|
82
|
+
.mongo.label.false {
|
83
|
+
background-color: #c43c35;
|
84
|
+
}
|
85
|
+
|
86
|
+
.mongo.label.empty {
|
87
|
+
|
88
|
+
}
|
89
|
+
|
90
|
+
|
91
|
+
span.string {
|
92
|
+
color:#404040;
|
93
|
+
}
|
94
|
+
|
95
|
+
|
data/lib/view_helpers.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
helpers do
|
2
|
+
|
3
|
+
def flash?
|
4
|
+
session[:message]
|
5
|
+
end
|
6
|
+
|
7
|
+
def flash
|
8
|
+
message = session[:message]
|
9
|
+
session[:message] = nil
|
10
|
+
message
|
11
|
+
end
|
12
|
+
|
13
|
+
def display(value)
|
14
|
+
case value
|
15
|
+
when NilClass
|
16
|
+
label "Nil", :empty
|
17
|
+
when BSON::ObjectId
|
18
|
+
label value, :id
|
19
|
+
when TrueClass, FalseClass
|
20
|
+
label value, value
|
21
|
+
when Time, Fixnum, Float, Bignum
|
22
|
+
code value
|
23
|
+
when String
|
24
|
+
value.empty? ? label( "empty string", :empty) : format(value)
|
25
|
+
when BSON::OrderedHash
|
26
|
+
erb :document, :locals => {:d => value}
|
27
|
+
when Array
|
28
|
+
if value.empty?
|
29
|
+
label "empty array", :empty
|
30
|
+
elsif value.first.class == BSON::OrderedHash
|
31
|
+
erb :embedded_collection, :locals => {:documents => value}
|
32
|
+
else
|
33
|
+
erb :embedded_list, :locals => {:values => value}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def code(str)
|
39
|
+
"<code>#{str}</code>"
|
40
|
+
end
|
41
|
+
|
42
|
+
def format(text)
|
43
|
+
text = text.to_str.gsub(/\r\n?/, "\n").gsub(/([^\n]\n)(?=[^\n])/, '\1<br />')
|
44
|
+
"<span class='string'>#{text}</span>"
|
45
|
+
end
|
46
|
+
|
47
|
+
def label(str, type = :notice)
|
48
|
+
"<span class='label mongo #{type.to_s}'>#{str}</span>"
|
49
|
+
end
|
50
|
+
|
51
|
+
def title(d)
|
52
|
+
d['_id'].nil? ? "" : d['_id'].to_s
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<h1><a href="/">mongov</a> → <a href="/<%=@database.name%>"><%=@database.name%></a> → <%=@collection.name%></h1>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<% if @documents.count == 0 %>
|
6
|
+
<div class="alert-message block-message">
|
7
|
+
<h2>Sorry</h2>
|
8
|
+
<p>No documents here.</p>
|
9
|
+
</div>
|
10
|
+
<% else %>
|
11
|
+
|
12
|
+
<section class="collections">
|
13
|
+
<div class="pagination">
|
14
|
+
<ul>
|
15
|
+
<% @pages.times do |p| %>
|
16
|
+
<li class="<%="active" if p+1 == @page%>"><a href="/<%=@database.name%>/<%=@collection.name%>/<%=p+1%>"><%=p+1%></a></li>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
</div>
|
20
|
+
<ul>
|
21
|
+
<% @documents.each do |d| %>
|
22
|
+
<li class="well"><%=erb :document, :locals => {:d => d} %></li>
|
23
|
+
<% end %>
|
24
|
+
</ul>
|
25
|
+
</section>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<% unless @collection.name == "system.indexes" %>
|
29
|
+
<div class="actions form-stacked">
|
30
|
+
<h2>Danger Zone</h2>
|
31
|
+
<br/>
|
32
|
+
<form method="post" class="" action="/<%=@database.name%>/<%=@collection.name%>">
|
33
|
+
<input name='_method' value='delete' type='hidden' />
|
34
|
+
<input type="submit" value="Drop collection" class="btn danger large" onclick="return confirm('Really sure?');"/>
|
35
|
+
</form>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<h1><a href="/">mongov</a> → <%=@database.name%></h1>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<% if flash? %>
|
6
|
+
<div class="alert-message block-message success">
|
7
|
+
<h2><%=flash%></h2>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<section class="collections">
|
12
|
+
<% if @collections.empty? %>
|
13
|
+
<div class="alert-message block-message">
|
14
|
+
<h2>Sorry</h2>
|
15
|
+
<p>No collections here.</p>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<table class="zebra-striped">
|
20
|
+
<caption><h3>Collections</h3></caption>
|
21
|
+
<thead>
|
22
|
+
<tr>
|
23
|
+
<th>Collection</th>
|
24
|
+
<th>Documents</th>
|
25
|
+
</tr>
|
26
|
+
</thead>
|
27
|
+
<tbody>
|
28
|
+
<% @collections.each do |collection| next if collection == "system.indexes" %>
|
29
|
+
<tr>
|
30
|
+
<td><a href="/<%=@database.name%>/<%=collection%>"><%=collection%></a></td>
|
31
|
+
<td><%=@database[collection].count%></td>
|
32
|
+
</tr>
|
33
|
+
<% end %>
|
34
|
+
</tbody>
|
35
|
+
</table>
|
36
|
+
|
37
|
+
<h4>System</h4>
|
38
|
+
<a href="/<%=@database.name%>/system.indexes">→ system.indexes</a>
|
39
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<table class='document'>
|
2
|
+
|
3
|
+
<% unless title(d).empty? %>
|
4
|
+
<caption><h2><small>document #</small><%=label title(d), :id%></h2></caption>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<% d.each do |k,v| %>
|
8
|
+
<% next if k == "_id" %>
|
9
|
+
<tr><td class='key'><%=k%></td><td value='value'><%=display(v)%></td></tr>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
</table>
|
data/lib/views/error.erb
ADDED
data/lib/views/index.erb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="page-header">
|
2
|
+
<h1><a href="/">mongov</a></h1>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<table class="zebra-striped">
|
6
|
+
<thead>
|
7
|
+
<tr><th>Database</th><th>Size</th></tr>
|
8
|
+
</thead>
|
9
|
+
<tbody>
|
10
|
+
<% @databases.each do |db, size| %>
|
11
|
+
<tr><td><a href="/<%=db%>"><%=db%></a></td><td><%=size/1024/1024%>MB</td></tr>
|
12
|
+
<% end %>
|
13
|
+
</tbody>
|
14
|
+
</table>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>mongov</title>
|
4
|
+
<link rel="stylesheet" href="/bootstrap.css" type="text/css" />
|
5
|
+
<link rel="stylesheet" href="/mongov.css" type="text/css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div class="container-fluid">
|
9
|
+
<%= yield %>
|
10
|
+
</div>
|
11
|
+
</body>
|
12
|
+
</html>
|
data/mongov.gemspec
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "mongov"
|
8
|
+
s.version = "0.0.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tijmen Brommet"]
|
12
|
+
s.date = "2011-10-05"
|
13
|
+
s.description = "Simple data viewer for MongoDB with Sinatra"
|
14
|
+
s.email = "tijmen@gmail.com"
|
15
|
+
s.executables = ["mongov"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.md"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/mongov",
|
29
|
+
"lib/mongov.rb",
|
30
|
+
"lib/public/bootstrap.css",
|
31
|
+
"lib/public/favicon.ico",
|
32
|
+
"lib/public/mongov.css",
|
33
|
+
"lib/view_helpers.rb",
|
34
|
+
"lib/views/collection.erb",
|
35
|
+
"lib/views/database.erb",
|
36
|
+
"lib/views/document.erb",
|
37
|
+
"lib/views/embedded_collection.erb",
|
38
|
+
"lib/views/embedded_list.erb",
|
39
|
+
"lib/views/error.erb",
|
40
|
+
"lib/views/index.erb",
|
41
|
+
"lib/views/layout.erb",
|
42
|
+
"mongov.gemspec"
|
43
|
+
]
|
44
|
+
s.homepage = "http://github.com/tijmenb/mongov"
|
45
|
+
s.licenses = ["MIT"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = "1.8.10"
|
48
|
+
s.summary = "Simple data viewer for MongoDB"
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<mongo>, [">= 0"])
|
56
|
+
s.add_runtime_dependency(%q<bson>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<sinatra>, [">= 0"])
|
60
|
+
s.add_dependency(%q<mongo>, [">= 0"])
|
61
|
+
s.add_dependency(%q<bson>, [">= 0"])
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
63
|
+
end
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<sinatra>, [">= 0"])
|
66
|
+
s.add_dependency(%q<mongo>, [">= 0"])
|
67
|
+
s.add_dependency(%q<bson>, [">= 0"])
|
68
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongov
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Tijmen Brommet
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-10-05 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 3
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
version_requirements: *id001
|
31
|
+
name: sinatra
|
32
|
+
prerelease: false
|
33
|
+
type: :runtime
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
hash: 3
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
version_requirements: *id002
|
45
|
+
name: mongo
|
46
|
+
prerelease: false
|
47
|
+
type: :runtime
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
version_requirements: *id003
|
59
|
+
name: bson
|
60
|
+
prerelease: false
|
61
|
+
type: :runtime
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 7
|
69
|
+
segments:
|
70
|
+
- 1
|
71
|
+
- 6
|
72
|
+
- 4
|
73
|
+
version: 1.6.4
|
74
|
+
version_requirements: *id004
|
75
|
+
name: jeweler
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
description: Simple data viewer for MongoDB with Sinatra
|
79
|
+
email: tijmen@gmail.com
|
80
|
+
executables:
|
81
|
+
- mongov
|
82
|
+
extensions: []
|
83
|
+
|
84
|
+
extra_rdoc_files:
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.md
|
87
|
+
files:
|
88
|
+
- .document
|
89
|
+
- Gemfile
|
90
|
+
- Gemfile.lock
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- VERSION
|
95
|
+
- bin/mongov
|
96
|
+
- lib/mongov.rb
|
97
|
+
- lib/public/bootstrap.css
|
98
|
+
- lib/public/favicon.ico
|
99
|
+
- lib/public/mongov.css
|
100
|
+
- lib/view_helpers.rb
|
101
|
+
- lib/views/collection.erb
|
102
|
+
- lib/views/database.erb
|
103
|
+
- lib/views/document.erb
|
104
|
+
- lib/views/embedded_collection.erb
|
105
|
+
- lib/views/embedded_list.erb
|
106
|
+
- lib/views/error.erb
|
107
|
+
- lib/views/index.erb
|
108
|
+
- lib/views/layout.erb
|
109
|
+
- mongov.gemspec
|
110
|
+
homepage: http://github.com/tijmenb/mongov
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
hash: 3
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
version: "0"
|
136
|
+
requirements: []
|
137
|
+
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 1.8.10
|
140
|
+
signing_key:
|
141
|
+
specification_version: 3
|
142
|
+
summary: Simple data viewer for MongoDB
|
143
|
+
test_files: []
|
144
|
+
|