Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 976d7bd
Showing
5 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
config/apache.conf | ||
config/htpasswd | ||
projects | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
desc "Add a new repo." | ||
task :add, [:repo, :name] => %w(env add:before) | ||
|
||
desc "Start over." | ||
task :clean do | ||
File.read(".gitignore").split("\n").each { |f| rm_rf f } | ||
end | ||
|
||
desc "Remove a repo." | ||
task :rm, [:name] => %w(env rm:before) | ||
|
||
task :default do | ||
puts "Hi! Read the README." | ||
end | ||
|
||
# No public tasks below here. If you're not using Passenger (or basic | ||
# auth or whatever) you're probably going to want to start hacking | ||
# somewhere around the :env and :templates tasks. | ||
|
||
task "add:before", [:repo, :name] do |_, args| | ||
repo = args.repo || abort("Need repo!") | ||
name = args.name || File.basename(repo, ".git") | ||
tasks = Rake::Task[:add].prerequisites | ||
|
||
directory a("projects/#{name}/public") | ||
|
||
file a("projects/#{name}/repo/.git") do |t| | ||
mkdir_p dest = File.dirname(t.name) | ||
sh "git clone #{repo} #{dest}" | ||
end | ||
|
||
file a("projects/#{name}/config.ru") do |t| | ||
ln_s File.expand_path("config/config.ru"), t.name | ||
end | ||
|
||
file a("public/#{name}") do |t| | ||
ln_s File.expand_path("projects/#{name}/public"), t.name | ||
end | ||
|
||
a :templates | ||
end | ||
|
||
task "rm:before", [:name] => :env do |_, args| | ||
name = args.name || abort("Need name!") | ||
%W(projects/#{name} public/#{name}).each { |n| rm_rf n } | ||
Rake::Task[:rm].prerequisites << :templates | ||
end | ||
|
||
task :env => %w(config/htpasswd projects public) | ||
|
||
task :templates do | ||
require "erb" | ||
|
||
@htpasswd = File.expand_path("config/htpasswd") | ||
@projects = Dir["projects/*"].map { |d| File.basename d } | ||
|
||
r "config/templates/apache.conf.erb", "config/apache.conf" | ||
r "config/templates/index.html.erb", "public/index.html" | ||
end | ||
|
||
directory "projects" | ||
directory "public" | ||
|
||
file "config/htpasswd" do |t| | ||
puts "Creating #{t.name} entry for #{ENV['USER']}." | ||
sh "htpasswd -c config/htpasswd #{ENV['USER']}" | ||
end | ||
|
||
def a *t; Rake::Task[:add].prerequisites.concat t; t.first end | ||
def r s, t; File.open(t,"wb"){|f|f<< ERB.new(File.read(s)).result} end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<VirtualHost *:80> | ||
DocumentRoot <%= @public %> | ||
<% @projects.each do |name| %> | ||
RackBaseURI /<%= name %> | ||
<% end %> | ||
|
||
PassengerMaxInstancesPerApp 1 | ||
PassengerMaxPoolSize <%= @projects.size %> | ||
|
||
<Directory "/"> | ||
AuthName "Fortress" | ||
AuthType Basic | ||
AuthUserFile <%= @htpasswd %> | ||
require valid-user | ||
</Directory> | ||
|
||
SetEnv RAILS_RELATIVE_URL_ROOT | ||
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<title>fuck you</title> | ||
</head> | ||
|
||
<body> | ||
<h1>fuck you</h1> | ||
|
||
<ul> | ||
<% @projects.each do |p| %> | ||
<li><a href="/<%= p %>"><%= p %></a></li> | ||
<% end %> | ||
</ul> | ||
</body> | ||
</html> |