Skip to content

Commit

Permalink
update generators to add theme choice, and rename application.css et…
Browse files Browse the repository at this point in the history
… al to application.scss
  • Loading branch information
bryanlarsen committed Sep 11, 2012
1 parent 83399c4 commit 23feee4
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 6 deletions.
Expand Up @@ -5,6 +5,9 @@ class AdminSubsiteGenerator < Rails::Generators::NamedBase
# overrides the default
argument :name, :type => :string, :default => 'admin', :optional => true

class_option :theme, :type => :string, :desc => "Theme", :default => 'clean_admin'
class_option :ui_theme, :type => :string, :desc => "jQuery-UI Theme", :default => 'flick'

include Generators::Hobo::InviteOnly
include Generators::HoboSupport::EvalTemplate

Expand Down
4 changes: 2 additions & 2 deletions hobo/lib/generators/hobo/assets/assets_generator.rb
Expand Up @@ -14,9 +14,9 @@ def copy_rapid_files
copy_file 'guest.rb', 'app/models/guest.rb'

FileUtils.mv 'app/assets/stylesheets/application.css', 'app/assets/stylesheets/application.css.orig'
copy_file 'application.css', 'app/assets/stylesheets/application.css'
copy_file 'application.scss', 'app/assets/stylesheets/application.scss'
copy_file 'gitkeep', 'app/assets/stylesheets/application/.gitkeep'
copy_file 'front.css', 'app/assets/stylesheets/front.css'
copy_file 'front.scss', 'app/assets/stylesheets/front.scss'
copy_file 'gitkeep', 'app/assets/stylesheets/front/.gitkeep'

FileUtils.mv 'app/assets/javascripts/application.js', 'app/assets/javascripts/application.js.orig'
Expand Down
38 changes: 36 additions & 2 deletions hobo/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb
Expand Up @@ -25,12 +25,24 @@ def self.banner
class_option :front_controller_name, :type => :string,
:desc => "Front Controller Name", :default => 'front'

class_option :front_theme, :type => :string,
:desc => "Front Theme", :default => 'clean'

class_option :front_ui_theme, :type => :string,
:desc => "Front jQuery-UI Theme", :default => 'redmond'

class_option :add_admin_subsite, :type => :boolean,
:desc => "Add an Admin Subsite"

class_option :admin_subsite_name, :type => :string,
:desc => "Admin Subsite Name", :default => 'admin'

class_option :admin_theme, :type => :string,
:desc => "Admin Theme", :default => 'clean'

class_option :admin_ui_theme, :type => :string,
:desc => "Admin jQuery-UI Theme", :default => 'redmond'

class_option :invite_only, :type => :boolean,
:desc => "Require invitation to join site"

Expand Down Expand Up @@ -154,18 +166,38 @@ def front_controller
end

def install_default_plugins
invoke 'hobo:install_default_plugins', [], {:subsite => 'front', :theme => 'hobo_clean', :ui_theme => 'redmond', :skip_gem => false}
if wizard?
say_title 'Front Theme'
say "The currently available themes are clean, clean_admin, clean_sidemenu and bootstrap."
@front_theme = ask("Choose a theme for the front site: [<enter>=clean|<custom_name>]", 'clean')

say_title 'Front jQuery-UI Theme'
say "The currently available jQuery-UI themes are listed here: https://github.com/fatdude/jquery-ui-themes-rails/blob/master/README.markdown"
@front_ui_theme = ask("Choose a jQuery-UI theme for the front site: [<enter>=redmond|<custom_name>]", 'redmond')
else
@front_theme = options[:front_theme]
@front_ui_theme = options[:front_ui_theme]
end
invoke 'hobo:install_default_plugins', [], {:subsite => 'front', :theme => "hobo_#{@front_theme}", :ui_theme => @front_ui_theme, :skip_gem => false}
end

def admin_subsite
if wizard?
say_title 'Admin Subsite'
if @invite_only || (@add_admin_subsite = yes_no?("Do you want an admin subsite?"))
@admin_subsite_name = ask("Choose a name for the admin subsite: [<enter>=admin|<custom_name>]", 'admin')

say "The currently available themes are clean, clean_admin, clean_sidemenu and bootstrap."
@admin_theme = ask("Choose a theme for the #{@admin_subsite_name} site: [<enter>=clean_admin|<custom_name>]", 'clean_admin')

say "The currently available jQuery-UI themes are listed here: https://github.com/fatdude/jquery-ui-themes-rails/blob/master/README.markdown"
@admin_ui_theme = ask("Choose a jQuery-UI theme for the admin site: [<enter>=flick|<custom_name>]", 'flick')
end
else
if @invite_only || (@add_admin_subsite = options[:add_admin_subsite])
@admin_subsite_name = options[:admin_subsite_name]
@admin_theme = options[:front_theme]
@admin_ui_theme = options[:front_ui_theme]
end
end
end
Expand All @@ -180,7 +212,9 @@ def invoking_user_and_admin
say "Installing admin subsite..."
invoke 'hobo:admin_subsite', [@admin_subsite_name],
:user_resource_name => @user_resource_name,
:invite_only => @invite_only
:invite_only => @invite_only,
:theme => @admin_theme,
:ui_theme => @admin_ui_theme
end
end

Expand Down
2 changes: 1 addition & 1 deletion hobo/lib/generators/hobo/subsite.rb
Expand Up @@ -19,7 +19,7 @@ def move_and_generate_files
end
end

template "site.css.erb", File.join('app/assets/stylesheets', "#{file_name}.css")
template "site.scss.erb", File.join('app/assets/stylesheets', "#{file_name}.scss")
copy_file "gitkeep", "app/assets/stylesheets/#{file_name}/.gitkeep"
template "site.js.erb", File.join('app/assets/javascripts', "#{file_name}.js")
copy_file "gitkeep", "app/assets/javascripts/#{file_name}/.gitkeep"
Expand Down
3 changes: 3 additions & 0 deletions hobo/lib/generators/hobo/subsite/subsite_generator.rb
Expand Up @@ -2,6 +2,9 @@ module Hobo
class SubsiteGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)

class_option :theme, :type => :string, :desc => "Theme", :default => 'clean_admin'
class_option :ui_theme, :type => :string, :desc => "jQuery-UI Theme", :default => 'flick'

def self.banner
"rails generate hobo:subsite NAME [options]"
end
Expand Down
Expand Up @@ -4,13 +4,16 @@ class SubsiteTaglibGenerator < Rails::Generators::NamedBase
include Generators::Hobo::InviteOnly
include Generators::Hobo::Taglib

class_option :theme, :type => :string, :desc => "Theme", :default => 'clean_admin'
class_option :ui_theme, :type => :string, :desc => "jQuery-UI Theme", :default => 'flick'

def self.banner
"rails generate hobo:subsite_taglib NAME [options]"
end

def generate_taglib
template "taglib.dryml.erb", File.join('app/views/taglibs', "#{file_name}_site.dryml")
Rails::Generators.invoke('hobo:install_default_plugins', ["--subsite=#{file_name}", "--theme=hobo_clean_admin", "--ui_theme=flick"])
Rails::Generators.invoke('hobo:install_default_plugins', ["--subsite=#{file_name}", "--theme=hobo_#{options[:theme]}", "--ui_theme=#{options[:ui_theme]}"])
end

end
Expand Down

0 comments on commit 23feee4

Please sign in to comment.