web-app-theme 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/README.md +24 -23
- data/VERSION +1 -1
- data/index.html +1 -0
- data/{rails_generators/theme/templates/view_layout_administration.html.erb → lib/generators/web_app_theme/theme/templates/layout_admin.html.erb} +9 -8
- data/lib/generators/web_app_theme/theme/templates/layout_sign.html.erb +15 -0
- data/lib/generators/web_app_theme/theme/theme_generator.rb +61 -0
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_edit.html.erb +1 -1
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_form.html.erb +2 -2
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_new.html.erb +1 -1
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_show.html.erb +2 -2
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_sidebar.html.erb +0 -0
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_signin.html.erb +0 -0
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_signup.html.erb +0 -0
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_tables.html.erb +1 -1
- data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_text.html.erb +0 -0
- data/lib/generators/web_app_theme/themed/themed_generator.rb +126 -0
- data/stylesheets/base.css +2 -2
- data/stylesheets/override.css +1 -0
- data/stylesheets/themes/activo/style.css +466 -0
- data/stylesheets/themes/amro/style.css +1 -1
- data/stylesheets/themes/bec-green/style.css +1 -1
- data/stylesheets/themes/bec/style.css +1 -1
- data/stylesheets/themes/blue/style.css +1 -1
- data/stylesheets/themes/default/style.css +1 -1
- data/stylesheets/themes/djime-cerulean/style.css +1 -1
- data/stylesheets/themes/drastic-dark/style.css +1 -1
- data/stylesheets/themes/kathleene/style.css +1 -1
- data/stylesheets/themes/olive/style.css +1 -1
- data/stylesheets/themes/orange/style.css +1 -1
- data/stylesheets/themes/reidb-greenish/style.css +1 -1
- data/stylesheets/themes/warehouse/style.css +1 -1
- data/web-app-theme.gemspec +17 -29
- metadata +20 -32
- data/rails_generators/theme/USAGE +0 -5
- data/rails_generators/theme/templates/view_layout_administration.html.haml +0 -30
- data/rails_generators/theme/templates/view_layout_sign.html.erb +0 -15
- data/rails_generators/theme/templates/view_layout_sign.html.haml +0 -10
- data/rails_generators/theme/templates/web_app_theme_override.css +0 -1
- data/rails_generators/theme/theme_generator.rb +0 -45
- data/rails_generators/themed/USAGE +0 -5
- data/rails_generators/themed/templates/view_edit.html.haml +0 -13
- data/rails_generators/themed/templates/view_form.html.haml +0 -11
- data/rails_generators/themed/templates/view_new.html.haml +0 -12
- data/rails_generators/themed/templates/view_show.html.haml +0 -18
- data/rails_generators/themed/templates/view_sidebar.html.haml +0 -10
- data/rails_generators/themed/templates/view_signin.html.haml +0 -22
- data/rails_generators/themed/templates/view_signup.html.haml +0 -32
- data/rails_generators/themed/templates/view_tables.html.haml +0 -36
- data/rails_generators/themed/templates/view_text.html.haml +0 -15
- data/rails_generators/themed/themed_generator.rb +0 -107
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -8,13 +8,12 @@ it wants to be an idea to start developing a complete web application layout.
|
|
8
8
|
Installation
|
9
9
|
------------
|
10
10
|
|
11
|
-
|
11
|
+
You can use web-app-theme >= 0.6.0 with Rails 3. If you want to use it with rails 2, use web-app-theme 0.5.3
|
12
|
+
Specify the web-app-theme gem in your Gemfile, only for :development and :test
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
script/plugin install git://github.com/pilu/web-app-theme.git
|
14
|
+
group :development, :test do
|
15
|
+
gem 'web-app-theme', '>= 0.6.0'
|
16
|
+
end
|
18
17
|
|
19
18
|
Usage
|
20
19
|
-----
|
@@ -22,33 +21,33 @@ Usage
|
|
22
21
|
### Theme Generator
|
23
22
|
|
24
23
|
Used without parameters, it generates the layout inside the application.html.erb file using the default theme.
|
25
|
-
|
26
|
-
|
24
|
+
|
25
|
+
rails g web_app_theme:theme
|
27
26
|
|
28
27
|
You can specify the layout file name in the first parameter:
|
29
28
|
|
30
|
-
|
29
|
+
rails g web_app_theme:theme admin # it will generate a layout called `admin.html.erb`
|
31
30
|
|
32
31
|
If you want to use another theme, instead of the default, you can use the `--theme` option:
|
33
32
|
|
34
|
-
|
33
|
+
rails g web_app_theme:theme admin --theme="drastic-dark"
|
35
34
|
|
36
35
|
You can specify the template engine with `--engine=name` option, where name can be erb (default) or haml:
|
37
36
|
|
38
|
-
|
37
|
+
rails g web_app_theme:theme --engine=haml # you must specify haml in your Gemfile
|
39
38
|
|
40
39
|
If you want to generate the stylesheets of a specific theme without changing the previously generated layout you can pass the `--no-layout` option:
|
41
40
|
|
42
|
-
|
41
|
+
rails g web_app_theme:theme --theme=bec --no-layout
|
43
42
|
|
44
43
|
|
45
44
|
You can specify the text used in the header with the `--app-name` option:
|
46
45
|
|
47
|
-
|
46
|
+
rails g web_app_theme:theme --app-name="My New Application"
|
48
47
|
|
49
48
|
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`
|
50
49
|
|
51
|
-
|
50
|
+
rails g web_app_theme:theme sign --layout-type=sign
|
52
51
|
|
53
52
|
### Themed Generator
|
54
53
|
|
@@ -56,43 +55,44 @@ Start creating your controllers manually or with a scaffold, and then use the `t
|
|
56
55
|
|
57
56
|
If you have a controller named like the plural of the used model you can specify just the first parameter:
|
58
57
|
|
59
|
-
|
58
|
+
rails g web_app_theme:themed posts # you have a model named Post and a controller named PostsController
|
60
59
|
|
61
|
-
|
60
|
+
rails g web_app_theme:themed admin/gallery_pictures # you have a model named GalleryPicture and a controller named Admin::GalleryPicturesController
|
62
61
|
|
63
62
|
Use the `--layout` option specifying the previously generated layout to add a link to the controller you are working on:
|
64
63
|
|
65
|
-
|
64
|
+
rails g web_app_theme:themed posts --layout=admin # you will see the `Posts` link in the navigation
|
66
65
|
|
67
66
|
If the controller has a name different to the model used, specify the controller path in the first parameter and the model name in the second one:
|
68
67
|
|
69
|
-
|
68
|
+
rails g web_app_theme:themed items post
|
70
69
|
|
71
|
-
|
70
|
+
rails g web_app_theme:themed admin/items post
|
72
71
|
|
73
72
|
If you use `will_paginate` for pagination use the `--with_will_paginate`:
|
74
73
|
|
75
|
-
|
74
|
+
rails g web_app_theme:themed items post --will-paginate
|
76
75
|
|
77
76
|
You can specify the template engine with `--engine=name` option, where name can be erb (default) or haml:
|
78
77
|
|
79
|
-
|
78
|
+
rails g web_app_theme:themed posts --engine=haml
|
80
79
|
|
81
80
|
If you have something like `map.resource :dashboard` in your `routes.rb` file, you can use the `--type=text` to generate a view with just text:
|
82
81
|
|
83
|
-
|
82
|
+
rails g web_app_theme:themed dashboards --themed-type=text
|
84
83
|
|
85
84
|
If you want to show form error messages inside the generated forms, use the following code inside your `environment.rb`
|
86
85
|
|
87
86
|
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
|
88
87
|
if html_tag =~ /<label/
|
89
|
-
%|<div class="fieldWithErrors">#{html_tag} <span class="error">#{[instance.error_message].join(', ')}</span></div
|
88
|
+
%|<div class="fieldWithErrors">#{html_tag} <span class="error">#{[instance.error_message].join(', ')}</span></div>|.html_safe
|
90
89
|
else
|
91
90
|
html_tag
|
92
91
|
end
|
93
92
|
end
|
94
93
|
|
95
94
|
If you want to have translated pages, simple create in your locale.yml the keys just like config/locales/en_us.yml example.
|
95
|
+
|
96
96
|
en_us:
|
97
97
|
web-app-theme:
|
98
98
|
save: Save
|
@@ -150,6 +150,7 @@ Contributors
|
|
150
150
|
* Roberto Klein
|
151
151
|
* Bryan Woods
|
152
152
|
* Sandro Duarte
|
153
|
+
* David Francisco
|
153
154
|
|
154
155
|
Credits
|
155
156
|
-------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/index.html
CHANGED
@@ -344,6 +344,7 @@
|
|
344
344
|
<h3>Switch Theme</h3>
|
345
345
|
<ul class="navigation">
|
346
346
|
<li><a href="#" onclick="Theme.activate('default'); return false;">Default</a></li>
|
347
|
+
<li><a href="#" onclick="Theme.activate('activo'); return false;">Activo</a></li>
|
347
348
|
<li><a href="#" onclick="Theme.activate('amro'); return false;">Amro</a></li>
|
348
349
|
<li><a href="#" onclick="Theme.activate('bec'); return false;">Bec</a></li>
|
349
350
|
<li><a href="#" onclick="Theme.activate('bec-green'); return false;">Bec-Green</a></li>
|
@@ -1,21 +1,22 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
<html
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
3
|
<head>
|
4
|
-
<
|
5
|
-
|
6
|
-
<%%=
|
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
|
+
<%%= javascript_include_tag :defaults, :cache => true %>
|
7
|
+
<%%= csrf_meta_tag %>
|
7
8
|
</head>
|
8
9
|
<body>
|
9
10
|
<div id="container">
|
10
11
|
<div id="header">
|
11
|
-
<h1><a href="/"><%= options
|
12
|
+
<h1><a href="/"><%= options.app_name %></a></h1>
|
12
13
|
<div id="user-navigation">
|
13
14
|
<ul class="wat-cf">
|
14
15
|
<li><a href="#"><%%= t("web-app-theme.profile", :default => "Profile") %></a></li>
|
15
16
|
<li><a href="#"><%%= t("web-app-theme.settings", :default => "Settings") %></a></li>
|
16
17
|
<li><a href="/logout" class="logout"><%%= t("web-app-theme.logout", :default => "Logout") %></a></li>
|
17
18
|
</ul>
|
18
|
-
</div>
|
19
|
+
</div>
|
19
20
|
<div id="main-navigation">
|
20
21
|
<ul class="wat-cf"></ul>
|
21
22
|
</div>
|
@@ -32,7 +33,7 @@
|
|
32
33
|
<%%= yield %>
|
33
34
|
<div id="footer">
|
34
35
|
<div class="block">
|
35
|
-
<p>Copyright © <%%= Time.now.year %> <%= options
|
36
|
+
<p>Copyright © <%%= Time.now.year %> <%= options.app_name %>.</p>
|
36
37
|
</div>
|
37
38
|
</div>
|
38
39
|
</div>
|
@@ -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>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module WebAppTheme
|
2
|
+
class ThemeGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
argument :layout_name, :type => :string, :default => 'application'
|
6
|
+
|
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'
|
12
|
+
|
13
|
+
def copy_layout
|
14
|
+
return if options.no_layout
|
15
|
+
admin_layout_name = options.layout_type == 'sign' ? "layout_sign.html.erb" : "layout_admin.html.erb"
|
16
|
+
case options.engine
|
17
|
+
when 'erb'
|
18
|
+
template admin_layout_name, "app/views/layouts/#{layout_name.underscore}.html.erb"
|
19
|
+
when 'haml'
|
20
|
+
generate_haml_layout(admin_layout_name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_base_stylesheets
|
25
|
+
copy_file "#{stylesheets_path}/base.css", "public/stylesheets/web-app-theme/base.css"
|
26
|
+
copy_file "#{stylesheets_path}/override.css", "public/stylesheets/web-app-theme/override.css"
|
27
|
+
end
|
28
|
+
|
29
|
+
def copy_theme_stylesheets
|
30
|
+
directory "#{stylesheets_path}/themes/#{options.theme}", "public/stylesheets/web-app-theme/themes/#{options.theme}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def copy_images
|
34
|
+
directory "#{images_path}", "public/images/web-app-theme"
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def stylesheets_path
|
40
|
+
"../../../../../stylesheets"
|
41
|
+
end
|
42
|
+
|
43
|
+
def images_path
|
44
|
+
"../../../../../images"
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_haml_layout(admin_layout_name)
|
48
|
+
require 'haml'
|
49
|
+
Dir.mktmpdir('web-app-theme-haml') do |haml_root|
|
50
|
+
tmp_html_path = "#{haml_root}/#{admin_layout_name}"
|
51
|
+
tmp_haml_path = "#{haml_root}/#{admin_layout_name}.haml"
|
52
|
+
template admin_layout_name, tmp_html_path, :verbose => false
|
53
|
+
`html2haml -r #{tmp_html_path} #{tmp_haml_path}`
|
54
|
+
copy_file tmp_haml_path, "app/views/layouts/#{layout_name.underscore}.html.haml"
|
55
|
+
end
|
56
|
+
rescue LoadError
|
57
|
+
say "HAML is not installed, or it is not specified in your Gemfile."
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<div class="content">
|
10
10
|
<h2 class="title"><%%= t("web-app-theme.edit", :default => "Edit") %> <%= model_name %></h2>
|
11
11
|
<div class="inner">
|
12
|
-
|
12
|
+
<%%= form_for @<%= model_name.underscore %>, :url => <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :html => { :class => :form } do |f| -%>
|
13
13
|
<%%= render :partial => "form", :locals => {:f => f} %>
|
14
14
|
<%% end -%>
|
15
15
|
</div>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<%- end -%>
|
8
8
|
<div class="group navform wat-cf">
|
9
9
|
<button class="button" type="submit">
|
10
|
-
<%%= image_tag("web-app-theme/tick.png", :alt => "#{t("web-app-theme.save", :default => "Save")}") %> <%%= t("web-app-theme.save", :default => "Save") %>
|
10
|
+
<%%= image_tag("web-app-theme/icons/tick.png", :alt => "#{t("web-app-theme.save", :default => "Save")}") %> <%%= t("web-app-theme.save", :default => "Save") %>
|
11
11
|
</button>
|
12
|
-
<%%= link_to
|
12
|
+
<%%= link_to image_tag("web-app-theme/icons/cross.png", :alt => "#{t("web-app-theme.cancel", :default => "Cancel")}") + " " + t("web-app-theme.cancel", :default => "Cancel"), <%= controller_routing_path %>_path, :class => "button" %>
|
13
13
|
</div>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<div class="content">
|
9
9
|
<h2 class="title"><%%= t("web-app-theme.new", :default => "New")%> <%= model_name %></h2>
|
10
10
|
<div class="inner">
|
11
|
-
|
11
|
+
<%%= form_for :<%= model_name.underscore %>, :url => <%= controller_routing_path %>_path, :html => { :class => :form } do |f| -%>
|
12
12
|
<%%= render :partial => "form", :locals => {:f => f} %>
|
13
13
|
<%% end -%>
|
14
14
|
</div>
|
@@ -15,8 +15,8 @@
|
|
15
15
|
</p>
|
16
16
|
<%- end -%>
|
17
17
|
<div class="wat-cf">
|
18
|
-
<%%= link_to
|
19
|
-
<%%= link_to
|
18
|
+
<%%= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => "#{t("web-app-theme.edit", :default=> "Edit")}") + " " + t("web-app-theme.edit", :default=> "Edit"), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => "button" %>
|
19
|
+
<%%= link_to image_tag("web-app-theme/icons/cross.png", :alt => "#{t("web-app-theme.delete", :default=> "Delete")}") + " " + t("web-app-theme.delete", :default => "Delete"), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :class => "button", :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}" %>
|
20
20
|
</div>
|
21
21
|
</div>
|
22
22
|
</div>
|
data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_sidebar.html.erb
RENAMED
File without changes
|
data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_signin.html.erb
RENAMED
File without changes
|
data/{rails_generators → lib/generators/web_app_theme}/themed/templates/view_signup.html.erb
RENAMED
File without changes
|
File without changes
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'rails/generators/generated_attribute'
|
2
|
+
|
3
|
+
module WebAppTheme
|
4
|
+
class ThemedGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
argument :controller_path, :type => :string
|
8
|
+
argument :model_name, :type => :string, :required => false
|
9
|
+
|
10
|
+
class_option :layout, :type => :string, :desc => 'Specify the layout name'
|
11
|
+
class_option :engine, :type => :string, :default => 'erb', :desc => 'Specify the template engine'
|
12
|
+
class_option :will_paginate, :type => :boolean, :default => false, :desc => 'Specify if you use will_paginate'
|
13
|
+
class_option :themed_type, :type => :string, :default => 'crud', :desc => 'Specify the themed type, crud or text. Default is crud'
|
14
|
+
|
15
|
+
def initialize(args, *options)
|
16
|
+
super(args, *options)
|
17
|
+
initialize_views_variables
|
18
|
+
end
|
19
|
+
|
20
|
+
def copy_views
|
21
|
+
generate_views
|
22
|
+
unless options.layout.blank?
|
23
|
+
gsub_file(File.join('app/views/layouts', "#{options[:layout]}.html.#{options.engine}"), /\<div\s+id=\"main-navigation\">.*\<\/ul\>/mi) do |match|
|
24
|
+
match.gsub!(/\<\/ul\>/, "")
|
25
|
+
if @engine.to_s =~ /haml/
|
26
|
+
%|#{match}
|
27
|
+
%li{:class => controller.controller_path == '#{@controller_file_path}' ? 'active' : '' }
|
28
|
+
%a{:href => #{controller_routing_path}_path} #{plural_model_name}
|
29
|
+
</ul>|
|
30
|
+
else
|
31
|
+
%|#{match} <li class="<%= controller.controller_path == '#{@controller_file_path}' ? 'active' : '' %>"><a href="<%= #{controller_routing_path}_path %>">#{plural_model_name}</a></li></ul>|
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def initialize_views_variables
|
40
|
+
@base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
|
41
|
+
@controller_routing_path = @controller_file_path.gsub(/\//, '_')
|
42
|
+
@model_name = @base_name.singularize unless @model_name
|
43
|
+
@model_name = @model_name.camelize
|
44
|
+
end
|
45
|
+
|
46
|
+
def controller_routing_path
|
47
|
+
@controller_routing_path
|
48
|
+
end
|
49
|
+
|
50
|
+
def singular_controller_routing_path
|
51
|
+
@controller_routing_path.singularize
|
52
|
+
end
|
53
|
+
|
54
|
+
def model_name
|
55
|
+
@model_name
|
56
|
+
end
|
57
|
+
|
58
|
+
def plural_model_name
|
59
|
+
@model_name.pluralize
|
60
|
+
end
|
61
|
+
|
62
|
+
def resource_name
|
63
|
+
@model_name.underscore
|
64
|
+
end
|
65
|
+
|
66
|
+
def plural_resource_name
|
67
|
+
resource_name.pluralize
|
68
|
+
end
|
69
|
+
|
70
|
+
def columns
|
71
|
+
excluded_column_names = %w[id created_at updated_at]
|
72
|
+
Kernel.const_get(@model_name).columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
|
73
|
+
end
|
74
|
+
|
75
|
+
def extract_modules(name)
|
76
|
+
modules = name.include?('/') ? name.split('/') : name.split('::')
|
77
|
+
name = modules.pop
|
78
|
+
path = modules.map { |m| m.underscore }
|
79
|
+
file_path = (path + [name.underscore]).join('/')
|
80
|
+
nesting = modules.map { |m| m.camelize }.join('::')
|
81
|
+
[name, path, file_path, nesting, modules.size]
|
82
|
+
end
|
83
|
+
|
84
|
+
def generate_views
|
85
|
+
views = {
|
86
|
+
'crud' => {
|
87
|
+
'view_tables.html.erb' => File.join('app/views', @controller_file_path, "index.html.#{options.engine}"),
|
88
|
+
'view_new.html.erb' => File.join('app/views', @controller_file_path, "new.html.#{options.engine}"),
|
89
|
+
'view_edit.html.erb' => File.join('app/views', @controller_file_path, "edit.html.#{options.engine}"),
|
90
|
+
'view_form.html.erb' => File.join('app/views', @controller_file_path, "_form.html.#{options.engine}"),
|
91
|
+
'view_show.html.erb' => File.join('app/views', @controller_file_path, "show.html.#{options.engine}"),
|
92
|
+
'view_sidebar.html.erb' => File.join('app/views', @controller_file_path, "_sidebar.html.#{options.engine}")
|
93
|
+
},
|
94
|
+
'text' => {
|
95
|
+
'view_text.html.erb' => File.join('app/views', @controller_file_path, "show.html.#{options.engine}"),
|
96
|
+
'view_sidebar.html.erb' => File.join('app/views', @controller_file_path, "_sidebar.html.#{options.engine}")
|
97
|
+
}
|
98
|
+
}
|
99
|
+
selected_views = views[options.themed_type]
|
100
|
+
options.engine == 'haml' ? generate_haml_views(selected_views) : generate_erb_views(selected_views)
|
101
|
+
end
|
102
|
+
|
103
|
+
def generate_erb_views(views)
|
104
|
+
views.each do |template_name, output_path|
|
105
|
+
template template_name, output_path
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def generate_haml_views(views)
|
110
|
+
require 'haml'
|
111
|
+
Dir.mktmpdir('web-app-theme-haml') do |haml_root|
|
112
|
+
views.each do |template_name, output_path|
|
113
|
+
tmp_html_path = "#{haml_root}/#{template_name}"
|
114
|
+
tmp_haml_path = "#{haml_root}/#{template_name}.haml"
|
115
|
+
template template_name, tmp_html_path, :verbose => false
|
116
|
+
`html2haml -r #{tmp_html_path} #{tmp_haml_path}`
|
117
|
+
copy_file tmp_haml_path, output_path
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
rescue LoadError
|
122
|
+
say "HAML is not installed, or it is not specified in your Gemfile."
|
123
|
+
exit
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|