Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link static sites without requiring a /public folder #115

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 13 additions & 7 deletions bin/powder
Expand Up @@ -110,7 +110,6 @@ module Powder
method_option :force, :type => :boolean, :default => false, :alias => '-f', :desc => "remove the old configuration, overwrite .powder"
method_option :"no-config", :type => :boolean, :default => false, :alias => '-n', :desc => "do not write a .powder file"
def link(name=nil)
return unless is_powable?
if File.symlink?(POW_PATH)
current_path = %x{pwd}.chomp
if name
Expand All @@ -120,7 +119,13 @@ module Powder
end
symlink_path = "#{POW_PATH}/#{name}"
FileUtils.rm_f(symlink_path) if options[:force]
FileUtils.ln_s(current_path, symlink_path) unless File.exists?(symlink_path)
unless File.exists?(symlink_path)
unless is_powable?(false)
FileUtils.mkdir_p(symlink_path)
symlink_path = "#{symlink_path}/public"
end
FileUtils.ln_s(current_path, symlink_path)
end
say "Your application is now available at http://#{name}.#{domain}/"
else
say "Pow is not installed. That is, the ${HOME}/.pow symlink does not exist."
Expand Down Expand Up @@ -205,8 +210,7 @@ module Powder
desc "unlink", "Unlink a pow app"
method_option :delete, :type => :boolean, :default => false, :alias => '-e', :desc => "delete .powder"
def unlink(name=nil)
return unless is_powable?
FileUtils.rm_f POW_PATH + '/' + (name || get_pow_name)
FileUtils.rm_rf POW_PATH + '/' + (name || get_pow_name)
say "Successfully removed #{(name || get_pow_name)}"
if options[:delete]
FileUtils.rm_f POWDER_CONFIG
Expand Down Expand Up @@ -455,7 +459,7 @@ module Powder
end
end

def is_powable?
def is_powable?(verbose=true)
if File.exists?('config.ru') || File.exists?('public/index.html')
true
elsif legacy = (is_rails2_app? || is_radiant_app?)
Expand All @@ -468,8 +472,10 @@ module Powder
return false
end
else
say "This does not appear to be a rack app as there is no config.ru."
say "Pow can also host static apps if there is an index.html in public/"
if verbose
say "This does not appear to be a rack app as there is no config.ru."
say "Pow can also host static apps if there is an index.html in public/"
end
return false
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/powder/version.rb
@@ -1,3 +1,3 @@
module Powder
VERSION = "0.3.0"
VERSION = "0.3.1"
end