Skip to content

Commit 80c6912

Browse files
committed
added layout-type option
1 parent 338222b commit 80c6912

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ If you want to generate the stylesheets of a specific theme without changing the
4444

4545
You can specify the text used in the header with the `--app-name` option:
4646

47-
script/generate theme --app_name="My New Application"
47+
rails g web_app_theme:theme --app-name="My New Application"
4848

4949
If you need a layout for login and signup pages, you can use the `--type` option with `sign` as value. Ìf not specified, the default value is `administration`
5050

51-
script/generate theme --type=sign
51+
rails g web_app_theme:theme sign --layout-type=sign
5252

5353
### Themed Generator
5454

lib/generators/web_app_theme/templates/layout_admin.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title><%= options.app_name %></title>
5-
<%%= stylesheet_link_tag "web-app-theme/base", "web-app-theme/override", "web-app-theme/themes/<%= options.theme %>/style", :cache => true %>
5+
<%%= stylesheet_link_tag "web-app-theme/base", "web-app-theme/themes/<%= options.theme %>/style", "web-app-theme/override", :cache => true %>
66
<%%= csrf_meta_tag %>
77
</head>
88
<body>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title><%= options.app_name %></title>
5+
<%%= stylesheet_link_tag "web-app-theme/base", "web-app-theme/themes/<%= options.theme %>/style", "web-app-theme/override", :cache => true %>
6+
<%%= csrf_meta_tag %>
7+
</head>
8+
<body>
9+
<div id="container">
10+
<div id="box">
11+
<%%= yield %>
12+
</div>
13+
</div>
14+
</body>
15+
</html>

lib/generators/web_app_theme/theme/theme_generator.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ class ThemeGenerator < Rails::Generators::Base
44

55
argument :layout_name, :type => :string, :default => 'application'
66

7-
class_option :theme, :type => :string, :default => :default, :desc => 'Specify the layout theme'
8-
class_option :app_name, :type => :string, :default => 'Web App', :desc => 'Specify the application name'
9-
class_option :engine, :type => :string, :default => 'erb', :desc => 'Specify the template engine'
10-
class_option :no_layout, :type => :boolean, :default => false, :desc => 'Use this option if you want to generate only stylesheets'
7+
class_option :theme, :type => :string, :default => :default, :desc => 'Specify the layout theme'
8+
class_option :app_name, :type => :string, :default => 'Web App', :desc => 'Specify the application name'
9+
class_option :engine, :type => :string, :default => 'erb', :desc => 'Specify the template engine'
10+
class_option :no_layout, :type => :boolean, :default => false, :desc => 'Use this option if you want to generate only stylesheets'
11+
class_option :layout_type, :type => :string, :default => 'admin', :desc => 'Layout type, admin or sign'
1112

1213
def copy_layout
13-
return if options.no_layout
14-
admin_layout_name = "layout_admin.html.erb"
14+
return if options.no_layout
15+
admin_layout_name = options.layout_type == 'sign' ? "layout_sign.html.erb" : "layout_admin.html.erb"
1516
case options.engine
1617
when 'erb'
1718
template admin_layout_name, "app/views/layouts/#{layout_name.underscore}.html.erb"

0 commit comments

Comments
 (0)