aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Contributions/examples/brew-server
diff options
context:
space:
mode:
authorMike McQuaid2012-03-18 15:33:21 +1300
committerMike McQuaid2012-03-18 15:34:41 +1300
commite33937a1e35e75dffae043f22e975bfd51dea409 (patch)
tree0c04edf7d597577808d5dc72a68718e047052168 /Library/Contributions/examples/brew-server
parentd47cf55f68fb1d381cfbdc9de905dc33c7ce5a83 (diff)
downloadbrew-e33937a1e35e75dffae043f22e975bfd51dea409.tar.bz2
Rename external commands directory from examples.
Fixes Homebrew/homebrew#10829.
Diffstat (limited to 'Library/Contributions/examples/brew-server')
-rwxr-xr-xLibrary/Contributions/examples/brew-server208
1 files changed, 0 insertions, 208 deletions
diff --git a/Library/Contributions/examples/brew-server b/Library/Contributions/examples/brew-server
deleted file mode 100755
index bcc15c257..000000000
--- a/Library/Contributions/examples/brew-server
+++ /dev/null
@@ -1,208 +0,0 @@
-#!/usr/bin/ruby
-
-## brew server: Run a local webserver for browsing available and installed brews.
-# Note: this external command is ruby, but set up as a shell script, so that it gets exec'd.
-# This is required for sinatra's run-loop to take over.
-
-$:.unshift(ENV['HOMEBREW_LIBRARY_PATH'])
-
-require 'global'
-require 'formula'
-
-require 'rubygems'
-
-begin
- require 'sinatra'
-rescue LoadError
- onoe 'Sinatra required but not found'
- puts 'To install: /usr/bin/gem install sinatra'
- exit 1
-end
-
-require 'cgi'
-
-
-def link_to_formula name
- "<a href=\"/formula/#{CGI.escape(name)}\">#{name}</a>"
-end
-
-def css_style
- "" # No CSS defined yet.
-end
-
-def search_form
- <<-EOS
- <form action="/search">
- Search: <input name="q" type="text"> <input type="submit">
- </form>
- EOS
-end
-
-def html_page
- body = <<-HTML
- <html>
- <head>
- <title>Homebrew Menu</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 id="informations">
- HTML
- yield body
- body += <<-HTML
- </div>
- </div>
- </body>
- </html>
- HTML
- return body
-end
-
-get '/' do
- return html_page do |s|
- s << <<-HTML
- <div class="row">#{search_form}</div>
- <div class="row">
- <ul>
- HTML
- Formula.names do |name|
- s << "<li>#{link_to_formula(name)}</li>"
- end
- s << <<-HTML
- </ul>
- </div>
- HTML
- end
-end
-
-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
-
- 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
- klass = Formula.factory(params[:name])
-
- installed = klass.installed? ? "Installed at" : "Not installed."
- 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>
- <h1>#{klass.name}</h1>
- <dl>
- <dt>Version</dt>
- <dd>#{klass.version}</dd>
-
- <dt>Homepage</dt>
- <dd><a href="#{klass.homepage}">#{klass.homepage}</a></dd>
-
- <dt>Download</dt>
- <dd><a href="#{klass.url}">#{klass.url}</a></dd>
-
- <dt>#{installed}</dt>
- <dd>#{installed_dd}</dd>
- HTML
-
- unless klass.deps.count == 0
- s << <<-HTML
- <dt>Depends on</td>
- HTML
- klass.deps.each do |dep|
- s << "<dd>#{link_to_formula(dep.name)}</dd>"
- end
- end
-
- used_by = Formula.all.select{|ff| ff.deps.include?(klass.name)}.map{|f| f.name}.flatten.uniq.sort
- unless used_by.empty?
- s << <<-HTML
- <dt>Used by</td>
- HTML
- if used_by != nil
- used_by.each do |name|
- s << "<dd>#{link_to_formula(name)}</dd>"
- end
- end
- end
-
- s += <<-HTML
- </dl>
- </body>
- </html>
- HTML
-
- return s
-end
-
-
-def installed_formulas
- Formula.all.select{|formula| formula.installed?}
-end
-
-get '/installed' do
-
- s = <<-HTML
- <html>
- <head>
- <title>Installed Formulas</title>
- #{css_style}
- </head>
- <body>
- <h1>Installed Fomulas</h1>
- <ul>
- HTML
-
- installed_formulas.each do |formula|
- s << "<li>#{link_to_formula(formula.name)}</li>"
- end
-
- s += <<-HTML
- </ul>
- <div>&larr; <a href="/">Back to menu</a></div>
- </body>
- </html>
- HTML
-
- return s
-end
-
-
-puts "View our tasting menu at http://localhost:4567/\nUse \"Control-C\" to exit.\n\n"