Skip to content

Commit

Permalink
added implementation for heroku_secure command. Setups Rack::Auth::Ba…
Browse files Browse the repository at this point in the history
…sic to prompt the user using HTTP Authentication for username and password in order to view the presentation. (Username field is ignored, only the password is checked)
  • Loading branch information
hundredwatt committed Sep 15, 2010
1 parent 45a7f89 commit 0a9aea8
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lib/showoff_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def self.create(dirname,create_samples,dir='one')
end
end

# Setup presentation to run on Heroku
def self.heroku(name)
if !File.exists?(SHOWOFF_JSON_FILE)
puts "fail. not a showoff directory"
Expand All @@ -47,6 +48,42 @@ def self.heroku(name)
f.puts 'run ShowOff.new'
end if !File.exists?('config.ru')

puts "herokuized. run something like this to launch your heroku presentation:
heroku create #{name}
git add .gems config.ru
git commit -m 'herokuized'
git push heroku master
"
end

# Setup the presentation to run on Heroku with password protection
def self.heroku_secure(name, password)
if !File.exists?(SHOWOFF_JSON_FILE)
puts "fail. not a showoff directory"
return false
end
# create .gems file
File.open('.gems', 'w+') do |f|
f.puts "bluecloth"
f.puts "nokogiri"
f.puts "showoff"
f.puts "gli"
f.puts "rack"
end if !File.exists?('.gems')

# create config.ru file
File.open('config.ru', 'w+') do |f|
f.puts 'require "rack"'
f.puts 'require "showoff"'
f.puts 'showoff_app = ShowOff.new'
f.puts 'protected_showoff = Rack::Auth::Basic.new(showoff_app) do |username, password|'
f.puts "\tpassword == '#{password}'"
f.puts 'end'
f.puts 'run protected_showoff'

end if !File.exists?('config.ru')

puts "herokuized. run something like this to launch your heroku presentation:
heroku create #{name}
Expand Down

0 comments on commit 0a9aea8

Please sign in to comment.