From a99285889c219f682945b37d6bda771fc98ec626 Mon Sep 17 00:00:00 2001 From: Kristaps Austers Date: Tue, 17 Feb 2015 21:00:49 +0200 Subject: [PATCH 1/5] Link static sites without a /public folder Pow supports hosting static sites under a ~/.pow/sitename/public symlink if the static site itself doesn't run under a "public" folder. This lets "powder link" support that feature. --- bin/powder | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/powder b/bin/powder index 4a47472..18623b9 100755 --- a/bin/powder +++ b/bin/powder @@ -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 @@ -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? + 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." From 5a04220970b90cbbd942145535dd5fba947bc49f Mon Sep 17 00:00:00 2001 From: Kristaps Austers Date: Tue, 17 Feb 2015 21:03:41 +0200 Subject: [PATCH 2/5] Don't require to be is_powable? to unlink --- bin/powder | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/powder b/bin/powder index 18623b9..e42e5a5 100755 --- a/bin/powder +++ b/bin/powder @@ -210,7 +210,6 @@ 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) say "Successfully removed #{(name || get_pow_name)}" if options[:delete] From d1cb3895f51ba6cdfcfbdc8e3c33547bb3590b4b Mon Sep 17 00:00:00 2001 From: Kristaps Austers Date: Tue, 17 Feb 2015 21:05:52 +0200 Subject: [PATCH 3/5] Unlink recursively --- bin/powder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/powder b/bin/powder index e42e5a5..c4df00d 100755 --- a/bin/powder +++ b/bin/powder @@ -210,7 +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) - 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 From 18e7b2bf25aa14b1ecd790e93f76867a303ca46e Mon Sep 17 00:00:00 2001 From: Kristaps Austers Date: Tue, 17 Feb 2015 21:12:15 +0200 Subject: [PATCH 4/5] Don't print rack message when linking a static site Add verbose flag to is_powable? (defaults to true) Don't print rack message when linking a static site --- bin/powder | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/powder b/bin/powder index c4df00d..1a822bf 100755 --- a/bin/powder +++ b/bin/powder @@ -120,7 +120,7 @@ module Powder symlink_path = "#{POW_PATH}/#{name}" FileUtils.rm_f(symlink_path) if options[:force] unless File.exists?(symlink_path) - unless is_powable? + unless is_powable?(false) FileUtils.mkdir_p(symlink_path) symlink_path = "#{symlink_path}/public" end @@ -459,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?) @@ -472,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 From 3b30c401540960083d0fd00a4d0acbfa754a1490 Mon Sep 17 00:00:00 2001 From: Kristaps Austers Date: Tue, 17 Feb 2015 21:00:55 +0200 Subject: [PATCH 5/5] Bump version to 0.3.1 --- lib/powder/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/powder/version.rb b/lib/powder/version.rb index 1571bf7..21f5213 100644 --- a/lib/powder/version.rb +++ b/lib/powder/version.rb @@ -1,3 +1,3 @@ module Powder - VERSION = "0.3.0" + VERSION = "0.3.1" end