diff options
author | Mark Longair <mhl@pobox.com> | 2013-12-05 10:30:05 +0000 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-12-05 10:30:05 +0000 |
commit | 985abf16bed94092e4cd206352253eabe85a55d1 (patch) | |
tree | 6ca025dc16dafde5522cb8fe0bafb59d2e6b25c8 /script/switch-theme.rb | |
parent | d35b7fec9ad723496c95791ae314964f4d3360dd (diff) | |
parent | 2bc00ec896b955ba87faf2c051517d26635f80a3 (diff) |
Merge branch 'feature/switch-theme-none-option' into rails-3-develop
Conflicts:
script/switch-theme.rb
Diffstat (limited to 'script/switch-theme.rb')
-rwxr-xr-x | script/switch-theme.rb | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/script/switch-theme.rb b/script/switch-theme.rb index e6afcebb9..980853687 100755 --- a/script/switch-theme.rb +++ b/script/switch-theme.rb @@ -31,6 +31,7 @@ require 'tempfile' +$no_theme_name = 'none' theme_directory = ENV['ALAVETELI_THEMES_DIR'] alaveteli_directory = File.expand_path(File.join(File.dirname(__FILE__), "..")) @@ -53,7 +54,9 @@ $available_themes = Dir.entries(theme_directory).find_all do |local_theme_name| next unless File.directory? full_path next unless File.directory? File.join(full_path, '.git') local_theme_name -end +end.sort + +$available_themes.unshift $no_theme_name if $available_themes.empty? STDERR.puts "There were no theme directories found in '#{theme_directory}'" @@ -62,7 +65,7 @@ end def usage_and_exit STDERR.puts "Usage: #{$0} <THEME-NAME>" - $available_themes.sort.each do |theme_name| + $available_themes.each do |theme_name| STDERR.puts " #{theme_name}" end exit 1 @@ -108,13 +111,19 @@ symlink(File.basename(theme_filename), config_directory, "general.yml") -symlink(File.join(full_theme_path, 'public'), - File.join(alaveteli_directory, 'public'), - 'alavetelitheme') +public_directory = File.join(alaveteli_directory, 'public') -symlink(full_theme_path, - File.join(alaveteli_directory, 'lib', 'themes'), - requested_theme) +if requested_theme == $no_theme_name + File.unlink File.join(public_directory, 'alavetelitheme') +else + symlink(File.join(full_theme_path, 'public'), + public_directory, + 'alavetelitheme') + + symlink(full_theme_path, + File.join(alaveteli_directory, 'lib', 'themes'), + requested_theme) +end STDERR.puts """Switched to #{requested_theme}! You will need to: |