brew-server: add Bootstrap styling

Closes Homebrew/homebrew#18041.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jan-Henrik Bruhn 2013-02-23 21:08:00 +01:00 committed by Jack Nagel
parent b1bc967f23
commit e8503e9354
4 changed files with 90 additions and 70 deletions

View File

@ -27,33 +27,52 @@ def link_to_formula name
end
def css_style
"" # No CSS defined yet.
<<-CSS
<link href="/bootstrap.min.css" rel="stylesheet"/>
<style>
.container {
text-align: center;
}
dl {
text-align: left;
width: 500px;
margin: 0 auto;
}
table.table {
width: 500px;
margin: 0 auto;
}
</style>
CSS
end
def search_form
<<-EOS
<form action="/search">
Search: <input name="q" type="text"> <input type="submit">
<form action="/search" class="form-search">
<div class="input-append">
<input id="search" name="q" type="text" class="input-large">
<button class="btn btn-medium" type="submit"><i class="icon-search"></i>&nbsp;Search</button>
</div>
</form>
EOS
end
def html_page
def html_page(title)
body = <<-HTML
<!DOCTYPE html>
<html>
<head>
<title>Homebrew Menu</title>
<title>#{title}</title>
#{css_style}
</head>
<body>
<div id="wrap">
<div id="header">
<h1><a href="./">Homebrew</a></h1>
<p id="subtitle"><strong>The missing package manager for OS X</strong></p>
<p id="installed"><a href="/installed">Show installed packages</a></p>
</div>
<div class="container">
<div id="header">
<h1><a href="/">Homebrew</a></h1>
<p id="subtitle" class="lead"><strong>The missing package manager for OS X</strong></p>
</div>
<div id="informations">
<div id="informations">
HTML
yield body
body += <<-HTML
@ -66,9 +85,14 @@ def html_page
end
get '/' do
return html_page do |s|
return html_page("Homebrew Menu") do |s|
s << <<-HTML
<div class="row">#{search_form}</div>
<div class="row">
<div class="span12"><div class="row">#{search_form}</div></div>
</div>
<div class="row">
<div class="span12"><p id="installed"><a class="btn btn-primary" href="/installed">Show installed packages</a></p></div>
</div>
<div class="row">
<ul>
HTML
@ -86,30 +110,35 @@ get '/search' do
q = params['q']
results = search_brews(q)
s = <<-HTML
<html>
<head>
<title>Search Results</title>
#{css_style}
</head>
<body>
<h1>Results</h1>
#{search_form}
<h4>Searched for &ldquo;#{q}&rdquo;</h4>
<ul>
HTML
return html_page("Results") do |s|
s << <<-HTML
<div class="row">
<div class="span12">
<div class="row">#{search_form}</div>
</div>
</div>
<div class="row">
<div class="span12">
<div class="row"><h4>Searched for &ldquo;#{q}&rdquo;:</h4></div>
</div>
</div>
<div class="row">
<div class="span12">
<div class="row"> <table class="table"><tr><th>Name</th></tr>
HTML
results.each do |name|
s << "<tr><td>#{link_to_formula(name)}</td></tr>"
end
s << <<-HTML
</table>
</div>
</div>
</div>
HTML
results.each do |name|
s << "<li>#{link_to_formula(name)}</li>"
end
s += <<-HTML
</ul>
</body>
</html>
HTML
return s
end
get '/formula/:name' do
@ -119,16 +148,9 @@ get '/formula/:name' do
installed_dd = klass.installed? ? "<a href=\"file://#{klass.prefix}\">#{klass.prefix}</a>" : ""
s = ""
s << <<-HTML
<html>
<head>
<title>Formula: #{klass.name}</title>
#{css_style}
</head>
<body>
<div>&larr; <a href="/">Back to menu</a></div>
s << html_page("Formula: #{klass.name}") do |s| s << <<-HTML
<h1>#{klass.name}</h1>
<dl>
<dl class="dl-horizontal">
<dt>Version</dt>
<dd>#{klass.version}</dd>
@ -140,7 +162,7 @@ get '/formula/:name' do
<dt>#{installed}</dt>
<dd>#{installed_dd}</dd>
HTML
HTML
unless klass.deps.count == 0
s << <<-HTML
@ -151,7 +173,7 @@ get '/formula/:name' do
end
end
used_by = Formula.select{|ff| ff.deps.include?(klass.name)}.map{|f| f.name}.flatten.uniq.sort
used_by = Formula.select{|ff| ff.deps.include?(klass)}.map{|f| f.name}.flatten.uniq.sort
unless used_by.empty?
s << <<-HTML
<dt>Used by</td>
@ -165,10 +187,8 @@ get '/formula/:name' do
s += <<-HTML
</dl>
</body>
</html>
HTML
end
return s
end
@ -179,28 +199,19 @@ end
get '/installed' do
s = <<-HTML
<html>
<head>
<title>Installed formulae</title>
#{css_style}
</head>
<body>
<h1>Installed Fomulas</h1>
<ul>
HTML
s = html_page("Installed formulae") do |s| s << <<-HTML
<h3>Installed Fomulas:</h3>
<table class="table"><tr><th>Name</th><th>Version</th></tr>
HTML
installed_formulae.each do |formula|
s << "<li>#{link_to_formula(formula.name)}</li>"
installed_formulae.each do |formula|
s << "<tr><td>#{link_to_formula(formula.name)}</td><td>#{formula.version}</td></tr>"
end
s << <<-HTML
</table>
HTML
end
s += <<-HTML
</ul>
<div>&larr; <a href="/">Back to menu</a></div>
</body>
</html>
HTML
return s
end

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB