From e33937a1e35e75dffae043f22e975bfd51dea409 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 18 Mar 2012 15:33:21 +1300 Subject: Rename external commands directory from examples. Fixes Homebrew/homebrew#10829. --- Library/Contributions/examples/brew-server | 208 ----------------------------- 1 file changed, 208 deletions(-) delete mode 100755 Library/Contributions/examples/brew-server (limited to 'Library/Contributions/examples/brew-server') 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 - "#{name}" -end - -def css_style - "" # No CSS defined yet. -end - -def search_form - <<-EOS -
- Search: -
- EOS -end - -def html_page - body = <<-HTML - - - Homebrew Menu - #{css_style} - - -
- - -
- HTML - yield body - body += <<-HTML -
-
- - - HTML - return body -end - -get '/' do - return html_page do |s| - s << <<-HTML -
#{search_form}
-
- -
- HTML - end -end - -get '/search' do - q = params['q'] - results = search_brews(q) - - s = <<-HTML - - - Search Results - #{css_style} - - -

Results

- #{search_form} -

Searched for “#{q}”

- - - - HTML - - return s -end - -get '/formula/:name' do - klass = Formula.factory(params[:name]) - - installed = klass.installed? ? "Installed at" : "Not installed." - installed_dd = klass.installed? ? "#{klass.prefix}" : "" - - s = "" - s << <<-HTML - - - Formula: #{klass.name} - #{css_style} - - -
Back to menu
-

#{klass.name}

-
-
Version
-
#{klass.version}
- -
Homepage
-
#{klass.homepage}
- -
Download
-
#{klass.url}
- -
#{installed}
-
#{installed_dd}
- HTML - - unless klass.deps.count == 0 - s << <<-HTML -
Depends on - HTML - klass.deps.each do |dep| - s << "
#{link_to_formula(dep.name)}
" - 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 -
Used by - HTML - if used_by != nil - used_by.each do |name| - s << "
#{link_to_formula(name)}
" - end - end - end - - s += <<-HTML -
- - - HTML - - return s -end - - -def installed_formulas - Formula.all.select{|formula| formula.installed?} -end - -get '/installed' do - - s = <<-HTML - - - Installed Formulas - #{css_style} - - -

Installed Fomulas

- -
Back to menu
- - - HTML - - return s -end - - -puts "View our tasting menu at http://localhost:4567/\nUse \"Control-C\" to exit.\n\n" -- cgit v1.2.3