leonardo 1.3.1 → 1.4.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/CHANGELOG +15 -0
- data/README.rdoc +40 -23
- data/lib/generators/erb/leosca/leosca_generator.rb +5 -2
- data/lib/generators/erb/leosca/templates/_form.html.erb +1 -1
- data/lib/generators/erb/leosca/templates/_list.erb +4 -1
- data/lib/generators/erb/leosca/templates/formtastic/_form.html.erb +8 -3
- data/lib/generators/erb/leosca/templates/index.html.erb +3 -1
- data/lib/generators/erb/leosca/templates/show.html.erb +17 -5
- data/lib/generators/leolay/leolay_generator.rb +131 -26
- data/lib/generators/leolay/templates/app/assets/javascripts/custom.js +2 -0
- data/lib/generators/leolay/templates/config/locales/en.yml +179 -2
- data/lib/generators/leolay/templates/config/locales/it.yml +125 -20
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/Thumbs.db +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_flat_10_000000_40x100.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-icons_228ef1_256x240.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-icons_ef8c08_256x240.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-icons_ffd27a_256x240.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
- data/lib/generators/leolay/templates/vendor/assets/javascripts/jquery-ui/jquery.ui.datepicker-de.js +23 -0
- data/lib/generators/leolay/templates/vendor/assets/javascripts/jquery-ui/jquery.ui.datepicker-en.js +23 -0
- data/lib/generators/leolay/templates/vendor/assets/javascripts/jquery-ui/jquery.ui.datepicker-it.js +23 -0
- data/lib/generators/leolay/templates/vendor/assets/javascripts/vendor.js +2 -0
- data/lib/generators/leolay/templates/{app/assets/stylesheets → vendor/assets/stylesheets/formtastic}/formtastic.css +0 -0
- data/lib/generators/leolay/templates/{app/assets/stylesheets → vendor/assets/stylesheets/formtastic}/formtastic_changes.css +0 -0
- data/lib/generators/leolay/templates/vendor/assets/stylesheets/jquery-ui/jquery-ui-1.8.16.redcarpet.css +568 -0
- data/lib/generators/leolay/templates/vendor/assets/stylesheets/vendor.css +4 -0
- data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +17 -11
- data/template.rb +4 -2
- metadata +29 -7
data/CHANGELOG
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
1.4.0 (August 24th, 2011) Marco Mastrodonato
|
2
|
+
* New file custom.js to fill with your javascripts and use application.js as manifest file
|
3
|
+
* Two new files under vendor/assets folder: vendor.js and vendor.css to use as manifest file
|
4
|
+
* Now you can skip formtastic also with leosca generator (leolay already could) and though if it is installed.
|
5
|
+
* jQuery ui (1.8.16) support with a custom ligthness theme to combine with leonardo default style
|
6
|
+
* Filter fields labels on index views now have id linked to own text field.
|
7
|
+
* Remove underscore from fields labels on yaml i18n files.
|
8
|
+
* Fields labels on _form partial now use i18n tags. Who used formastic didn't need it.
|
9
|
+
* Now date use a text fields with calendar class for jquery ui calendar, if you chose it
|
10
|
+
* The three users created by leolay (admin, manager and user) have now a new password: abcd1234
|
11
|
+
* Association now generate a link to related object showing its name || id. These changes are in the _list and show which now use a table => will be changed with a tableless layout
|
12
|
+
* Minor improvement
|
13
|
+
|
14
|
+
|
15
|
+
|
1
16
|
1.3.1 (August 22th, 2011) Marco Mastrodonato
|
2
17
|
* Fixed csv name (to enable csv data export you have to set remote = false)
|
3
18
|
* Fixed seeds creation when references fields are used
|
data/README.rdoc
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
= Leolay Generators
|
2
2
|
|
3
3
|
A layout and customized scaffold generator for Rails 3.1
|
4
|
-
|
4
|
+
A generator for creating Rails 3.1 applications ready to go. It generates the layout, the style, the internationalization and manage external gems for authentication, authorization and other. It also provides a customized scaffold to generates cool sites ajax ready in few minutes. If you find a bug please report to m.mastrodonato@gmail.com
|
5
5
|
|
6
6
|
|
7
7
|
== Install
|
8
8
|
|
9
9
|
gem install leonardo
|
10
10
|
|
11
|
-
|
11
|
+
or
|
12
|
+
|
13
|
+
rails new NewApp -m http://cloud.github.com/downloads/marcomd/Leonardo/template.rb
|
12
14
|
|
13
15
|
|
14
16
|
== Usage
|
@@ -19,16 +21,19 @@ To run the generator, go to your rails project directory and call it using rails
|
|
19
21
|
rails g leolay or rails destroy leolay
|
20
22
|
rails g leosca or rails destroy leosca
|
21
23
|
|
22
|
-
PS:
|
24
|
+
PS: leosca destroy do not remove variables parts like the attributes inserted into i18n yaml
|
25
|
+
|
23
26
|
PPS: You can run it more times and right like scaffold, is smart and won't generate tons of identical code
|
24
27
|
|
25
28
|
=== Step by step
|
26
29
|
|
27
30
|
1. Firstly, create layout and initialize your project:
|
28
|
-
rails new AppExample -m template.rb
|
29
|
-
(You
|
31
|
+
rails new AppExample -m http://cloud.github.com/downloads/marcomd/Leonardo/template.rb
|
32
|
+
(You can also find a template into gem root folder)
|
30
33
|
|
31
|
-
|
34
|
+
Answer y for the gem you need.
|
35
|
+
After the question will start generations.
|
36
|
+
There will be a conflict on locales/en.yml which you must force if it is the first generation.
|
32
37
|
|
33
38
|
Will be:
|
34
39
|
* Created an application layout with a nice and dynamic stylesheet based on sass
|
@@ -36,43 +41,45 @@ Will be:
|
|
36
41
|
* Customized application.rb to exclude javascript and stylesheet for every resource you will create
|
37
42
|
* Customized application controller to manage i18n and others stuff like authentication, authorization ecc [optionals]
|
38
43
|
* Created customized partials for pagination with kaminari [optional]
|
44
|
+
* Added jQuery-ui with a custom ligthness layout
|
39
45
|
|
40
46
|
2. If you have used my template you have an application ready to work:
|
41
|
-
run rails s and try it on localhost:3000
|
42
|
-
if you
|
43
|
-
email: admin@AppExample.com, password:
|
47
|
+
run rails s and try it on http://localhost:3000
|
48
|
+
if you chose authentication you have to sign in, try with this different profile:
|
49
|
+
email: admin@AppExample.com, password: abcd1234
|
44
50
|
[this profile can do everything]
|
45
51
|
or
|
46
|
-
email: manager@AppExample.com, password:
|
52
|
+
email: manager@AppExample.com, password: abcd1234
|
47
53
|
[can read, create and update]
|
48
54
|
or
|
49
|
-
email: user@AppExample.com, password:
|
55
|
+
email: user@AppExample.com, password: abcd1234
|
50
56
|
[can read, create, update and destroy]
|
51
57
|
|
52
|
-
Profile exists only if you
|
53
|
-
That are default and ready to be customized to suit your needs.
|
58
|
+
Profile exists only if you chose authorization as well.
|
54
59
|
|
55
60
|
3. Create your resource:
|
56
61
|
rails g leosca product name:string description:text active:boolean items:integer price:decimal
|
57
62
|
|
58
|
-
This will act as a normal scaffold more new
|
63
|
+
This will act as a normal scaffold and has more new features:
|
59
64
|
* will be invoked new leosca_controller which is a customized scaffold_controller
|
60
|
-
* customized views with new layout and ajax ready
|
61
|
-
* attributes will be insert into i18n files for fast translation
|
65
|
+
* customized views with new layout and ajax ready (only destroy atm)
|
66
|
+
* attributes will be insert into i18n files for a fast translation
|
62
67
|
* seeds will be created for you to populate new table
|
68
|
+
* ...and other stuff
|
63
69
|
|
64
|
-
4. Apply
|
70
|
+
4. Apply to db
|
65
71
|
rake db:migrate
|
66
72
|
rake db:seed
|
67
73
|
|
68
|
-
|
69
|
-
|
74
|
+
That's all!
|
75
|
+
The new application is ready to be customized and to suit your needs.
|
70
76
|
|
71
|
-
You could also customize
|
77
|
+
You could also customize templates: both views and controller.
|
78
|
+
To copy under your project folder run:
|
72
79
|
rails g leosca:install
|
73
80
|
|
74
|
-
Then go to lib\generators\erb to
|
75
|
-
|
81
|
+
Then go to lib\generators\erb to edit erb views like you would do with original scaffold.
|
82
|
+
Go to lib\generators\rails if you want to customize more.
|
76
83
|
|
77
84
|
|
78
85
|
For more information about usage:
|
@@ -102,7 +109,13 @@ PS: Of course, these options are in addition to those provided by the original s
|
|
102
109
|
|
103
110
|
=== Available layout
|
104
111
|
|
105
|
-
*
|
112
|
+
* cloudy [default]
|
113
|
+
|
114
|
+
|
115
|
+
== Tutorial
|
116
|
+
|
117
|
+
http://mastrodonato.info/index.php/2011/08/leonardo-generatore-di-applicazioni-rails-3-1/
|
118
|
+
|
106
119
|
|
107
120
|
|
108
121
|
== Found a bug?
|
@@ -113,3 +126,7 @@ If you are having a problem please submit an issue at m.mastrodonato@gmail.com
|
|
113
126
|
== Rails 2 and Rails 3.0.x
|
114
127
|
|
115
128
|
This Generators does not work with versions earlier 3.1
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
@@ -11,6 +11,7 @@ module Erb
|
|
11
11
|
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
12
12
|
class_option :authorization, :type => :boolean, :default => true, :description => "Add code to manage authorization with cancan"
|
13
13
|
class_option :remote, :type => :boolean, :default => true, :description => "Enable ajax. You can also do later set remote to true into index view."
|
14
|
+
class_option :formtastic, :type => :boolean, :default => true, :description => "Create forms to manage with formtastic gem"
|
14
15
|
|
15
16
|
def create_root_folder
|
16
17
|
empty_directory File.join("app/views", controller_file_path)
|
@@ -63,11 +64,13 @@ module Erb
|
|
63
64
|
def authorization?
|
64
65
|
File.exists? "app/models/ability.rb"
|
65
66
|
end
|
66
|
-
|
67
67
|
def formtastic?
|
68
|
+
return false unless options.formtastic?
|
68
69
|
File.exists? "config/initializers/formtastic.rb"
|
69
70
|
end
|
70
|
-
|
71
|
+
def jquery_ui?
|
72
|
+
File.exists? "vendor/assets/javascripts/jquery-ui"
|
73
|
+
end
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
<% attributes.each do |attribute| -%>
|
15
15
|
<div class="field">
|
16
|
-
<%%= f.label :<%= attribute.name %> %><br />
|
16
|
+
<%%= f.label :<%= attribute.name %>, t('attributes.<%= singular_table_name %>.<%= attribute.name %>') %><br />
|
17
17
|
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
18
18
|
</div>
|
19
19
|
<% end -%>
|
@@ -17,8 +17,11 @@
|
|
17
17
|
<tr id="tr<%%= <%= singular_table_name %>.id %>" class="<%%= cycle("odd", "even")%>">
|
18
18
|
<%- attributes.each do |attribute| -%>
|
19
19
|
<%- case attribute.type
|
20
|
-
|
20
|
+
when :boolean -%>
|
21
21
|
<td><%%= <%= singular_table_name %>.<%= attribute.name %> ? style_image_tag("ico_v.png") : style_image_tag('ico_x.png') %></td>
|
22
|
+
<%- when :references, :belongs_to -%>
|
23
|
+
<%% link_name = <%= singular_table_name %>.<%= attribute.name %>.try(:name) || <%= singular_table_name %>.<%= attribute.name %>.try(:id) %>
|
24
|
+
<td><%%= link_to(link_name, <%= singular_table_name %>.<%= attribute.name %> ) %></td>
|
22
25
|
<%- else -%>
|
23
26
|
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
24
27
|
<%- end -%>
|
@@ -1,8 +1,13 @@
|
|
1
1
|
<%%= semantic_form_for(@<%= singular_table_name %>) do |f| %>
|
2
2
|
<%%= f.inputs do %>
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
<%- attributes.each do |attribute| -%>
|
4
|
+
<%- case attribute.type
|
5
|
+
when :date -%>
|
6
|
+
<%%= f.input :<%= attribute.name %>, :as => :string, :input_html => { :class => 'calendar', :maxlength => 10 } %>
|
7
|
+
<%- else -%>
|
8
|
+
<%%= f.input :<%= attribute.name %> %>
|
9
|
+
<%- end -%>
|
10
|
+
<%- end -%>
|
6
11
|
<%% end %>
|
7
12
|
<%%= f.buttons do %>
|
8
13
|
<%%= f.commit_button :button_html => { :class => "button large" } %>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<div class="filter-container">
|
10
10
|
<%- attributes.each do |attribute| -%>
|
11
11
|
<div class="filter-field">
|
12
|
-
<b><%%= f.label t('attributes.<%= singular_table_name %>.<%= attribute.name %>') %></b><br />
|
12
|
+
<b><%%= f.label :<%= attribute.name %>, t('attributes.<%= singular_table_name %>.<%= attribute.name %>') %></b><br />
|
13
13
|
<%- case attribute.type -%>
|
14
14
|
<%- when :boolean -%>
|
15
15
|
<%%= radio_button("<%= singular_table_name %>", "<%= attribute.name %>", "1", {:checked => (@<%= singular_table_name %>.<%= attribute.name %>)}) %><%%= label_tag "<%= singular_table_name %>_<%= attribute.name %>_1", t(:yes) %><br />
|
@@ -17,6 +17,8 @@
|
|
17
17
|
<%%= radio_button("<%= singular_table_name %>", "<%= attribute.name %>", "") %><%%= label_tag "<%= singular_table_name %>_<%= attribute.name %>_", t(:all) %>
|
18
18
|
<%- when :text -%>
|
19
19
|
<%%= f.text_field :<%= attribute.name %> %>
|
20
|
+
<%- when :date -%>
|
21
|
+
<%%= f.text_field :<%= attribute.name %><%=", :class => \"calendar\"" if jquery_ui?%> %>
|
20
22
|
<%- else -%>
|
21
23
|
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
22
24
|
<%- end -%>
|
@@ -4,10 +4,22 @@
|
|
4
4
|
{:value => link_to(t(:show), @<%= singular_table_name %>), :active => true}
|
5
5
|
)%>
|
6
6
|
|
7
|
+
<table>
|
7
8
|
<% attributes.each do |attribute| -%>
|
8
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
<tr>
|
10
|
+
<%- case attribute.type
|
11
|
+
when :boolean -%>
|
12
|
+
<td><b><%%= t('attributes.<%= singular_table_name %>.<%= attribute.name %>') %>:</b></td>
|
13
|
+
<td><%%= @<%= singular_table_name %>.<%= attribute.name %> ? style_image_tag("ico_v.png") : style_image_tag('ico_x.png') %></td>
|
14
|
+
<%- when :references, :belongs_to -%>
|
15
|
+
<%% link_name = @<%= singular_table_name %>.<%= attribute.name %>.try(:name) || @<%= singular_table_name %>.<%= attribute.name %>.try(:id) %>
|
16
|
+
<td><b><%%= t('attributes.<%= singular_table_name %>.<%= attribute.name %>') %>:</b></td>
|
17
|
+
<td><%%= link_to(link_name, @<%= singular_table_name %>.<%= attribute.name %> ) %></td>
|
18
|
+
<%- else -%>
|
19
|
+
<td><b><%%= t('attributes.<%= singular_table_name %>.<%= attribute.name %>') %>:</b></td>
|
20
|
+
<td><%%= @<%= singular_table_name %>.<%= attribute.name %> %></td>
|
21
|
+
<%- end -%>
|
22
|
+
</tr>
|
13
23
|
<% end -%>
|
24
|
+
</table>
|
25
|
+
|
@@ -8,45 +8,64 @@ class LeolayGenerator < Rails::Generators::Base
|
|
8
8
|
class_option :authorization, :type => :boolean, :default => true, :description => "Add code to manage authorization with cancan"
|
9
9
|
class_option :user_class, :type => :boolean, :default => 'user', :description => "Set the user class name"
|
10
10
|
class_option :formtastic, :type => :boolean, :default => true, :description => "Copy formtastic files into leosca custom folder (inside project)"
|
11
|
+
class_option :jquery_ui, :type => :boolean, :default => true, :description => "To use jQuery ui improvement"
|
11
12
|
|
12
13
|
|
13
14
|
def generate_layout
|
14
15
|
template "config.rb", "config/initializers/config.rb"
|
15
16
|
|
16
|
-
template "styles/#{style_name}/stylesheet.sass",
|
17
|
-
"app/assets/stylesheets/#{style_name}.sass"
|
17
|
+
template "styles/#{style_name}/stylesheet.sass", "app/assets/stylesheets/#{style_name}.sass"
|
18
18
|
|
19
19
|
copy_file "layout_helper.rb", "app/helpers/layout_helper.rb"
|
20
20
|
|
21
21
|
copy_file "styles/#{style_name}/views/layout/application.html.erb", "app/views/layouts/application.html.erb", :force => true
|
22
22
|
template "styles/#{style_name}/views/layout/_layout.html.erb", "app/views/layouts/_#{style_name}.html.erb"
|
23
|
-
#{:authentication => options.authentication?,
|
24
|
-
#:authorization => options.authorization?}
|
25
23
|
copy_file "styles/#{style_name}/views/layout/_message.html.erb", "app/views/application/_message.html.erb"
|
26
24
|
copy_file "styles/#{style_name}/views/layout/_session.html.erb", "app/views/application/_session.html.erb" if options.authentication?
|
27
25
|
|
28
|
-
|
29
|
-
|
26
|
+
locale_path = "config/locales"
|
27
|
+
source_paths.each do |source_path|
|
28
|
+
files = Dir["#{source_path}/#{locale_path}/??.yml"]
|
29
|
+
files.each do |f|
|
30
|
+
copy_file f, "#{locale_path}/#{File.basename(f)}"
|
31
|
+
end
|
32
|
+
break if files.any?
|
33
|
+
end
|
30
34
|
|
31
35
|
copy_file "lib/utility.rb", "lib/extras/utility.rb"
|
32
36
|
|
33
37
|
if options.pagination?
|
34
|
-
|
35
|
-
|
38
|
+
source_paths.each do |source_path|
|
39
|
+
files = Dir["#{source_path}/#{locale_path}/kaminari.??.yml"]
|
40
|
+
files.each do |f|
|
41
|
+
copy_file f, "#{locale_path}/#{File.basename(f)}"
|
42
|
+
end
|
43
|
+
break if files.any?
|
44
|
+
end
|
36
45
|
|
37
|
-
copy_file "styles/#{style_name}/views/kaminari/_next_page.html.erb", "app/views/kaminari/_next_page.html.erb"
|
38
|
-
copy_file "styles/#{style_name}/views/kaminari/_page.html.erb", "app/views/kaminari/_page.html.erb"
|
39
|
-
copy_file "styles/#{style_name}/views/kaminari/_paginator.html.erb", "app/views/kaminari/_paginator.html.erb"
|
40
|
-
copy_file "styles/#{style_name}/views/kaminari/_prev_page.html.erb", "app/views/kaminari/_prev_page.html.erb"
|
46
|
+
#copy_file "styles/#{style_name}/views/kaminari/_next_page.html.erb", "app/views/kaminari/_next_page.html.erb"
|
47
|
+
#copy_file "styles/#{style_name}/views/kaminari/_page.html.erb", "app/views/kaminari/_page.html.erb"
|
48
|
+
#copy_file "styles/#{style_name}/views/kaminari/_paginator.html.erb", "app/views/kaminari/_paginator.html.erb"
|
49
|
+
#copy_file "styles/#{style_name}/views/kaminari/_prev_page.html.erb", "app/views/kaminari/_prev_page.html.erb"
|
50
|
+
directory "styles/#{style_name}/views/kaminari", "app/views/kaminari"
|
41
51
|
|
42
|
-
|
52
|
+
|
53
|
+
#copy_file "styles/#{style_name}/images/kaminari/nav.png", "app/assets/images/styles/#{style_name}/kaminari/nav.png"
|
54
|
+
directory "styles/#{style_name}/images/kaminari", "app/assets/images/styles/#{style_name}/kaminari"
|
43
55
|
end
|
44
56
|
|
45
57
|
directory "styles/#{style_name}/images/style", "app/assets/images/styles/#{style_name}"
|
46
58
|
|
59
|
+
directory "styles/#{style_name}/images/jquery-ui", "app/assets/images/styles/#{style_name}/jquery-ui" if options.jquery_ui?
|
60
|
+
|
47
61
|
if options.authentication?
|
48
|
-
|
49
|
-
|
62
|
+
source_paths.each do |source_path|
|
63
|
+
files = Dir["#{source_path}/#{locale_path}/devise.??.yml"]
|
64
|
+
files.each do |f|
|
65
|
+
copy_file f, "#{locale_path}/#{File.basename(f)}"
|
66
|
+
end
|
67
|
+
break if files.any?
|
68
|
+
end
|
50
69
|
directory "app/views/devise", "app/views/devise"
|
51
70
|
end
|
52
71
|
end
|
@@ -135,19 +154,19 @@ class LeolayGenerator < Rails::Generators::Base
|
|
135
154
|
def create_admin_migration
|
136
155
|
file = "db/migrate/*_create_admin.rb"
|
137
156
|
return unless options.authentication? and Dir[file].empty?
|
138
|
-
file = file.sub('*', Time.now.strftime("%Y%m%d%
|
157
|
+
file = file.sub('*', Time.now.strftime("%Y%m%d%H%M99"))
|
139
158
|
create_file file do
|
140
159
|
<<-FILE.gsub(/^ /, '')
|
141
160
|
class CreateAdmin < ActiveRecord::Migration
|
142
161
|
def self.up
|
143
162
|
add_column :users, :roles_mask, :integer
|
144
|
-
user=User.new :email => 'admin@#{app_name}.com', :password => '
|
163
|
+
user=User.new :email => 'admin@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
|
145
164
|
user.roles=['admin']
|
146
165
|
user.save
|
147
|
-
user=User.new :email => 'manager@#{app_name}.com', :password => '
|
166
|
+
user=User.new :email => 'manager@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
|
148
167
|
user.roles=['manager']
|
149
168
|
user.save
|
150
|
-
user=User.new :email => 'user@#{app_name}.com', :password => '
|
169
|
+
user=User.new :email => 'user@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
|
151
170
|
user.roles=['user']
|
152
171
|
user.save
|
153
172
|
end
|
@@ -160,20 +179,20 @@ class LeolayGenerator < Rails::Generators::Base
|
|
160
179
|
end
|
161
180
|
FILE
|
162
181
|
end
|
182
|
+
|
163
183
|
end
|
164
184
|
|
165
185
|
def setup_formtastic
|
166
186
|
return unless options.formtastic?
|
167
187
|
|
168
|
-
|
169
|
-
|
170
|
-
file
|
188
|
+
path = "vendor/assets/stylesheets/formtastic"
|
189
|
+
file = "#{path}/formtastic.css"
|
190
|
+
copy_file file, file unless File.exists?(file)
|
191
|
+
file = "#{path}/formtastic_changes.css"
|
171
192
|
copy_file file, file
|
172
193
|
|
173
|
-
|
174
|
-
|
175
|
-
#file_destination = "lib/templates/erb/leosca/_form.html.erb"
|
176
|
-
#copy_file file_source, file_destination if File.exists?(file_source) and not File.exists?(file_destination)
|
194
|
+
path = "vendor/assets/stylesheets/jquery-ui"
|
195
|
+
directory path, path
|
177
196
|
|
178
197
|
file = "config/initializers/formtastic.rb"
|
179
198
|
inject_into_file file, :after => "# Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false" do
|
@@ -184,6 +203,91 @@ class LeolayGenerator < Rails::Generators::Base
|
|
184
203
|
end if File.exists?(file)
|
185
204
|
end
|
186
205
|
|
206
|
+
def setup_javascript
|
207
|
+
app_path = "app/assets/javascripts"
|
208
|
+
vendor_path = "vendor/assets/javascripts"
|
209
|
+
|
210
|
+
file = "#{app_path}/custom.js"
|
211
|
+
copy_file file, file
|
212
|
+
|
213
|
+
file = "#{vendor_path}/vendor.js"
|
214
|
+
copy_file file, file
|
215
|
+
|
216
|
+
file = "#{app_path}/application.js"
|
217
|
+
append_file file do
|
218
|
+
<<-FILE.gsub(/^ /, '')
|
219
|
+
|
220
|
+
//= require vendor
|
221
|
+
FILE
|
222
|
+
end
|
223
|
+
|
224
|
+
if options.jquery_ui?
|
225
|
+
file = "#{app_path}/custom.js"
|
226
|
+
append_file file do
|
227
|
+
<<-FILE.gsub(/^ /, '')
|
228
|
+
|
229
|
+
$(function (){
|
230
|
+
$('.calendar').datepicker();
|
231
|
+
});
|
232
|
+
FILE
|
233
|
+
end
|
234
|
+
|
235
|
+
file = "#{app_path}/application.js"
|
236
|
+
inject_into_file file, :after => "//= require jquery_ujs" do
|
237
|
+
<<-FILE.gsub(/^ /, '')
|
238
|
+
|
239
|
+
//= require jquery-ui
|
240
|
+
FILE
|
241
|
+
end
|
242
|
+
|
243
|
+
#files = Dir["#{vendor_path}/jquery-ui/jquery.ui.datepicker-??.js"]
|
244
|
+
#files.each do |f|
|
245
|
+
# copy_file f, f
|
246
|
+
#end
|
247
|
+
directory "#{vendor_path}/jquery-ui", "#{vendor_path}/jquery-ui"
|
248
|
+
|
249
|
+
file = "#{vendor_path}/vendor.js"
|
250
|
+
append_file file do
|
251
|
+
<<-FILE.gsub(/^ /, '')
|
252
|
+
|
253
|
+
//= require_tree ./jquery-ui
|
254
|
+
FILE
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def setup_stylesheets
|
261
|
+
app_path = "app/assets/stylesheets"
|
262
|
+
vendor_path = "vendor/assets/stylesheets"
|
263
|
+
|
264
|
+
file = "#{vendor_path}/vendor.css"
|
265
|
+
copy_file file, file
|
266
|
+
|
267
|
+
if options.jquery_ui?
|
268
|
+
file = "#{app_path}/application.css"
|
269
|
+
inject_into_file file, :before => "*/" do
|
270
|
+
<<-FILE.gsub(/^ /, '')
|
271
|
+
*= require vendor
|
272
|
+
FILE
|
273
|
+
end
|
274
|
+
|
275
|
+
file = "#{vendor_path}/vendor.css"
|
276
|
+
inject_into_file file, :before => "*/" do
|
277
|
+
<<-FILE.gsub(/^ /, '')
|
278
|
+
*= require_tree ./jquery-ui
|
279
|
+
FILE
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
file = "#{vendor_path}/vendor.css"
|
284
|
+
inject_into_file file, :before => "*/" do
|
285
|
+
<<-FILE.gsub(/^ /, '')
|
286
|
+
*= require_tree ./formtastic
|
287
|
+
FILE
|
288
|
+
end if options.formtastic?
|
289
|
+
end
|
290
|
+
|
187
291
|
private
|
188
292
|
def style_name
|
189
293
|
style.underscore
|
@@ -192,4 +296,5 @@ class LeolayGenerator < Rails::Generators::Base
|
|
192
296
|
def app_name
|
193
297
|
File.basename(Dir.pwd)
|
194
298
|
end
|
299
|
+
|
195
300
|
end
|