From 2bc00ec896b955ba87faf2c051517d26635f80a3 Mon Sep 17 00:00:00 2001 From: Mark Longair Date: Mon, 25 Nov 2013 17:53:30 +0000 Subject: Update the switch-theme.rb script allow switching to no theme --- script/switch-theme.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'script/switch-theme.rb') diff --git a/script/switch-theme.rb b/script/switch-theme.rb index 47f81c7a8..f6ecc80b1 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} " - $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, 'vendor', 'plugins'), - 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, 'vendor', 'plugins'), + requested_theme) +end STDERR.puts """Switched to #{requested_theme}! You will need to restart any development server you have running.""" -- cgit v1.2.3 From 20089cf7b5045d504b7240bc92e2b6068fcc2246 Mon Sep 17 00:00:00 2001 From: Mark Longair Date: Fri, 29 Nov 2013 10:41:32 +0000 Subject: With Rails 3.2, switching theme requires asset recompilation --- script/switch-theme.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'script/switch-theme.rb') diff --git a/script/switch-theme.rb b/script/switch-theme.rb index 47f81c7a8..03d59a2f9 100755 --- a/script/switch-theme.rb +++ b/script/switch-theme.rb @@ -117,4 +117,8 @@ symlink(full_theme_path, requested_theme) STDERR.puts """Switched to #{requested_theme}! -You will need to restart any development server you have running.""" +You will need to: + 1. restart any development server you have running. + 2. run: bundle exec rake assets:clean + 3. run: bundle exec rake assets:precompile +""" -- cgit v1.2.3 From aa9c6b15d3a021709ad5f7b3b653ca914a8c40b8 Mon Sep 17 00:00:00 2001 From: Mark Longair Date: Fri, 29 Nov 2013 08:28:20 +0000 Subject: Move themes from vendor/plugins to lib/themes These are essentially required in exactly the same way as before, but from lib/themes rather than vendor/plugins. This is the simplest possible change in order make the themes work outside vendor/plugins, I think, but it's not necessarily ideal. It would be worth considering whether these should be changed to Rails engines, as described here: http://guides.rubyonrails.org/engines.html --- script/switch-theme.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'script/switch-theme.rb') diff --git a/script/switch-theme.rb b/script/switch-theme.rb index 03d59a2f9..e6afcebb9 100755 --- a/script/switch-theme.rb +++ b/script/switch-theme.rb @@ -113,7 +113,7 @@ symlink(File.join(full_theme_path, 'public'), 'alavetelitheme') symlink(full_theme_path, - File.join(alaveteli_directory, 'vendor', 'plugins'), + File.join(alaveteli_directory, 'lib', 'themes'), requested_theme) STDERR.puts """Switched to #{requested_theme}! -- cgit v1.2.3