-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcassadmin.rb
More file actions
40 lines (29 loc) · 1.29 KB
/
cassadmin.rb
File metadata and controls
40 lines (29 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Cassadmin < Sinatra::Base
Dir.glob('./{helpers,controllers}/*.rb').each { |file| require file }
include KeyspacesController
get '/' do
client = Cassandra.new('system')
@keyspaces = client.keyspaces #array
haml :home
end
helpers do
def title(value = nil)
@title = value if value
@title ? "Controller Demo - #{@title}" : "Controller Demo"
end
def nav
html = []
html << "<li class=\"page\"><a href=\"/\">Keyspaces</a></li>"
if @keyspace
html << "<li><span class=\"divider\">/</span><a href=\"/keyspaces/#{@keyspace}/columnfamilies\">#{@keyspace}</a></li>"
html << "<li class=\"page\"><span class=\"divider\">/</span><a href=\"/keyspaces/#{@keyspace}/columnfamilies\">Column families</a></li>"
end
if @cf
html << "<li><span class=\"divider\">/</span><a href=\"/keyspaces/#{@keyspace}/columnfamilies/#{@cf}/keys\">#{@cf}</a></li>"
html << "<li class=\"page\"><span class=\"divider\">/</span><a href=\"/keyspaces/#{@keyspace}/columnfamilies/#{@cf}/keys\">Keys</a></li>"
end
html << "<li><span class=\"divider\">/</span><a href=\"/keyspaces/#{@keyspace}/columnfamilies/#{@cf}/keys/#{@key}\">#{@key}</a></li>" if @key
"<ul class=\"breadcrumb\">#{html.join}</ul>"
end
end
end