beautiful_scaffold 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +19 -0
- data/Rakefile +9 -0
- data/beautiful_scaffold.gemspec +2 -2
- data/lib/generators/beautiful_devisecancan_generator.rb +1 -1
- data/lib/generators/beautiful_jointable_generator.rb +1 -1
- data/lib/generators/beautiful_locale_generator.rb +95 -94
- data/lib/generators/beautiful_migration_generator.rb +1 -1
- data/lib/generators/beautiful_scaffold_common_methods.rb +4 -3
- data/lib/generators/beautiful_scaffold_generator.rb +18 -33
- data/lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js +20 -2
- data/lib/generators/templates/app/assets/stylesheets/application-bs.css +2 -1
- data/lib/generators/templates/app/assets/stylesheets/beautiful-scaffold.css.scss +1 -1
- data/lib/generators/templates/app/controllers/base.rb +7 -2
- data/lib/generators/templates/app/controllers/master_base.rb +1 -1
- data/lib/generators/templates/app/views/_form.html.erb +3 -0
- data/lib/generators/templates/app/views/edit.html.erb +1 -3
- data/lib/generators/templates/app/views/new.html.erb +0 -2
- data/test/scaffold_test.rb +68 -0
- metadata +6 -4
- data/lib/generators/templates/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e51faa22a7e9fbad343b1597ca5bb417c144476b
|
4
|
+
data.tar.gz: fb09b6d7228778e26ec391109ab77e35f8839f29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa11569d24429d62e3f5f3ba79db359921bbcd70c233aa7a1730973468d861b6a7967e2f0aa56a4efd114bb9c8fb7977fa75f3c0073f2e41f9e8f48862dbab5a
|
7
|
+
data.tar.gz: 1a59f7aaad1ea361376af40e7fd8f16713e3ce61473aa39cbcd41063524ca14467478878405d29724d983d63978f7cf396c0b528c8a94ef8112fd895579cd310
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
== master
|
2
|
+
|
3
|
+
* enhancement
|
4
|
+
|
5
|
+
* bugfix
|
6
|
+
|
7
|
+
== 1.0.2
|
8
|
+
|
9
|
+
* enhancement
|
10
|
+
* Using static twitter bootstrap files
|
11
|
+
* UI : button back & submit on the same line
|
12
|
+
* Add tests (better late than never :/)
|
13
|
+
|
14
|
+
* bugfix
|
15
|
+
* Fix #18 : Responsive Theme Navbar Overlaps Content When Resizing Below ~979px
|
16
|
+
* Fix generator locales
|
17
|
+
* Fix icon datetimepicker
|
18
|
+
* render nothing: true replace with head :ok
|
19
|
+
|
1
20
|
== 1.0.1
|
2
21
|
|
3
22
|
* enhancement
|
data/Rakefile
ADDED
data/beautiful_scaffold.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "beautiful_scaffold"
|
6
|
-
s.version = "1.0.
|
6
|
+
s.version = "1.0.2"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.summary = "Beautiful Scaffold generate fully customizable scaffold"
|
9
9
|
s.email = "claudel.sylvain@gmail.com"
|
@@ -15,5 +15,5 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.rubyforge_project = "beautiful_scaffold"
|
17
17
|
|
18
|
-
s.require_paths = ["lib","lib/generators"]
|
18
|
+
s.require_paths = ["lib","lib/generators","test/*"]
|
19
19
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding : utf-8
|
2
2
|
class BeautifulDevisecancanGenerator < Rails::Generators::Base
|
3
|
-
|
3
|
+
require_relative 'beautiful_scaffold_common_methods'
|
4
4
|
include BeautifulScaffoldCommonMethods
|
5
5
|
|
6
6
|
source_root File.expand_path('../templates', __FILE__)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding : utf-8
|
2
2
|
class BeautifulJointableGenerator < Rails::Generators::Base
|
3
|
-
|
3
|
+
require_relative 'beautiful_scaffold_common_methods'
|
4
4
|
include BeautifulScaffoldCommonMethods
|
5
5
|
|
6
6
|
source_root File.expand_path('../templates', __FILE__)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding : utf-8
|
2
2
|
class BeautifulLocaleGenerator < Rails::Generators::Base
|
3
|
-
|
3
|
+
require_relative 'beautiful_scaffold_common_methods'
|
4
4
|
include BeautifulScaffoldCommonMethods
|
5
5
|
|
6
6
|
source_root File.expand_path('../templates', __FILE__)
|
@@ -8,21 +8,16 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
|
|
8
8
|
argument :name, :type => :string, :desc => "type of locale : fr OR en OR de OR ja all..."
|
9
9
|
|
10
10
|
class_option :mountable_engine, :default => nil
|
11
|
-
|
12
|
-
def
|
11
|
+
|
12
|
+
def list_locales
|
13
13
|
availablelocale = ["fr", "en", "ja"]
|
14
|
-
|
15
|
-
localestr = name.downcase
|
16
|
-
|
17
|
-
locale_to_process = []
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
locale_to_process.each{ |temp_locale|
|
15
|
+
localestr = name.downcase
|
16
|
+
(localestr == 'all' ? availablelocale : [localestr])
|
17
|
+
end
|
18
|
+
|
19
|
+
def install_locale
|
20
|
+
list_locales.each{ |temp_locale|
|
26
21
|
filename = "beautiful_scaffold.#{temp_locale}.yml"
|
27
22
|
gem_localepath = "app/locales/#{filename}"
|
28
23
|
app_localepath = "config/locales/#{filename}"
|
@@ -56,105 +51,112 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
|
|
56
51
|
def regenerate_app_locale
|
57
52
|
require 'net/http'
|
58
53
|
|
59
|
-
already_processed = { name.downcase => {}}
|
60
|
-
|
61
54
|
app_name = (Rails.root || engine_opt)
|
62
55
|
engine_or_apps = (Rails.application.class.parent_name || engine_opt).downcase
|
56
|
+
prefix = engine_opt.blank? ? '' : "#{engine_opt.camelize}::"
|
63
57
|
|
64
|
-
|
65
|
-
|
66
|
-
puts "=======>"
|
67
|
-
puts engine_or_apps
|
58
|
+
already_processed = {}
|
59
|
+
hi18n = {}
|
68
60
|
|
69
|
-
|
70
|
-
|
71
|
-
hi18n = YAML.load_file(filepath)
|
72
|
-
rescue
|
73
|
-
puts "Error loading locale file : #{filepath}"
|
74
|
-
end
|
61
|
+
list_locales.each do |locale_str|
|
62
|
+
locale = locale_str.downcase
|
75
63
|
|
76
|
-
|
77
|
-
hi18n[name.downcase] ||= { 'app' => {} }
|
78
|
-
hi18n[name.downcase]['app'] ||= { 'models' => {} }
|
79
|
-
hi18n[name.downcase]['app']['models'] ||= {}
|
80
|
-
|
81
|
-
# Feed data already translated
|
82
|
-
hi18n[name.downcase]['app']['models'].each{ |modelname,hshtranslations|
|
83
|
-
hshtranslations['bs_attributes'].each{ |attr, translated_attr|
|
84
|
-
already_processed[name.downcase][attr] = translated_attr
|
85
|
-
}
|
86
|
-
}
|
64
|
+
already_processed[locale] ||= {}
|
87
65
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
66
|
+
filepath = File.join(app_name, 'config', 'locales', "#{engine_or_apps}.#{locale}.yml")
|
67
|
+
begin
|
68
|
+
if File.exist?(filepath)
|
69
|
+
hi18n = YAML.load_file(filepath)
|
70
|
+
end
|
71
|
+
rescue
|
72
|
+
puts "Error loading locale file (YAML invalid?) : #{filepath}"
|
73
|
+
end
|
95
74
|
|
96
|
-
|
75
|
+
hi18n[locale] ||= { 'app' => {} }
|
76
|
+
hi18n[locale]['app'] ||= { 'models' => {} }
|
77
|
+
hi18n[locale]['app']['models'] ||= {}
|
97
78
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
79
|
+
# Feed data already translated
|
80
|
+
hi18n[locale]['app']['models'].each do |modelname, hshtranslations|
|
81
|
+
hshtranslations['bs_attributes'].each do |attr, translated_attr|
|
82
|
+
already_processed[locale][attr] = translated_attr
|
83
|
+
end
|
102
84
|
end
|
103
|
-
klass = "#{prefix}#{model.camelize.constantize}"
|
104
85
|
|
105
|
-
|
86
|
+
Dir.glob("app/models/**/*").each do |model_file|
|
87
|
+
puts model_file
|
88
|
+
|
89
|
+
next if File.directory?(model_file) or
|
90
|
+
File.basename(model_file).first == '.' or
|
91
|
+
model_file.include?('/concerns/') or
|
92
|
+
model_file.include?('pdf_report.rb') or
|
93
|
+
model_file.include?('application_record.rb')
|
94
|
+
|
95
|
+
model = File.basename(model_file, File.extname(model_file))
|
96
|
+
|
97
|
+
klass = "#{prefix}#{model}".camelize.constantize
|
106
98
|
sorted_attr = klass.attribute_names.sort
|
107
|
-
rescue
|
108
|
-
next
|
109
|
-
end
|
110
99
|
|
111
|
-
|
100
|
+
newmodel = !hi18n[locale]['app']['models'].has_key?(model)
|
112
101
|
|
113
|
-
|
102
|
+
hi18n[locale]['app']['models'][model] ||= {
|
114
103
|
'bs_caption' => model,
|
115
104
|
'bs_caption_plural' => model.pluralize,
|
116
105
|
'bs_attributes' => {},
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
106
|
+
}
|
107
|
+
|
108
|
+
if newmodel then
|
109
|
+
bs_caption = ""
|
110
|
+
begin
|
111
|
+
bs_caption = translate_string(locale, model)
|
112
|
+
rescue Exception => e
|
113
|
+
puts "Erreur traduction #{e.backtrace}"
|
114
|
+
bs_caption = model
|
115
|
+
end
|
116
|
+
bs_caption_plural = ""
|
117
|
+
begin
|
118
|
+
bs_caption_plural = translate_string(locale, model.pluralize)
|
119
|
+
rescue Exception => e
|
120
|
+
puts "Erreur traduction #{e.backtrace}"
|
121
|
+
bs_caption_plural = model.pluralize
|
122
|
+
end
|
122
123
|
|
123
|
-
|
124
|
-
|
125
|
-
|
124
|
+
hi18n[locale]['app']['models'][model]['bs_caption'] = bs_caption
|
125
|
+
hi18n[locale]['app']['models'][model]['bs_caption_plural'] = bs_caption_plural
|
126
|
+
end
|
126
127
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
128
|
+
hi18n[locale]['app']['models'][model]['bs_attributes'] ||= {}
|
129
|
+
|
130
|
+
sorted_attr.each do |k|
|
131
|
+
# Si pas déjà renseigné
|
132
|
+
if hi18n[locale]['app']['models'][model]['bs_attributes'][k].blank?
|
133
|
+
# Si pas déjà traduit
|
134
|
+
if already_processed[locale][k].blank?
|
135
|
+
begin
|
136
|
+
attr_translate = translate_string(locale, k)
|
137
|
+
already_processed[locale][k] = attr_translate
|
138
|
+
rescue
|
139
|
+
puts "Plantage translate API"
|
140
|
+
attr_translate = k
|
141
|
+
end
|
142
|
+
else
|
143
|
+
attr_translate = already_processed[locale][k]
|
140
144
|
end
|
141
145
|
else
|
142
|
-
|
146
|
+
# Récupère l'attribut traduit
|
147
|
+
attr_translate = hi18n[locale]['app']['models'][model]['bs_attributes'][k]
|
143
148
|
end
|
144
|
-
else
|
145
|
-
# Récupère l'attribut traduit
|
146
|
-
attr_translate = hi18n[name.downcase]['app']['models'][model]['bs_attributes'][k]
|
147
|
-
end
|
148
149
|
|
149
|
-
|
150
|
-
|
151
|
-
|
150
|
+
hi18n[locale]['app']['models'][model]['bs_attributes'][k] = attr_translate
|
151
|
+
end
|
152
|
+
end
|
152
153
|
|
153
|
-
|
154
|
+
File.unlink(filepath) if File.exist?(filepath)
|
154
155
|
|
155
|
-
|
156
|
-
|
157
|
-
|
156
|
+
file = File.open(filepath, "w")
|
157
|
+
file.write(hi18n.to_yaml)
|
158
|
+
file.close
|
159
|
+
end
|
158
160
|
end
|
159
161
|
|
160
162
|
private
|
@@ -162,14 +164,13 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
|
|
162
164
|
def translate_string(locale, str)
|
163
165
|
# See http://www.microsofttranslator.com/dev/
|
164
166
|
#
|
165
|
-
if locale == "en"
|
167
|
+
if locale == "en"
|
166
168
|
attr_translate = "#{str.gsub(/_/, " ")}"
|
167
169
|
else
|
168
|
-
url_domain
|
169
|
-
|
170
|
+
url_domain = "api.mymemory.translated.net"
|
171
|
+
url_query = "/get?q=#{str.gsub(/_/, "%20")}&langpair=en%7C#{locale}"
|
170
172
|
|
171
|
-
|
172
|
-
json = JSON.parse(Net::HTTP.get(url_domain, urlstr))
|
173
|
+
json = JSON.parse(Net::HTTP.get(url_domain, url_query))
|
173
174
|
attr_translate = json["responseData"]["translatedText"].strip.downcase
|
174
175
|
end
|
175
176
|
raise 'Free Limit' if attr_translate =~ /mymemory/
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding : utf-8
|
2
2
|
class BeautifulMigrationGenerator < Rails::Generators::Base
|
3
|
-
|
3
|
+
require_relative 'beautiful_scaffold_common_methods'
|
4
4
|
include BeautifulScaffoldCommonMethods
|
5
5
|
|
6
6
|
#include Rails::Generators::ResourceHelpers
|
@@ -181,18 +181,19 @@ module BeautifulScaffoldCommonMethods
|
|
181
181
|
|
182
182
|
def require_gems
|
183
183
|
gems = {
|
184
|
-
'less-rails' => '2.8.0',
|
185
184
|
'will_paginate' => nil, # v 3.1.5
|
186
|
-
'ransack' => '1.8.
|
185
|
+
'ransack' => '1.8.4',
|
187
186
|
'polyamorous' => '1.3.1',
|
188
187
|
'jquery-ui-rails' => nil,
|
189
188
|
'prawn' => '2.1.0',
|
190
189
|
'prawn-table' => '0.2.2',
|
191
190
|
'sanitize' => nil,
|
192
191
|
'twitter-bootstrap-rails' => '3.2.2',
|
192
|
+
'font-awesome-rails' => '4.7.0.2',
|
193
193
|
'chardinjs-rails' => nil,
|
194
194
|
'momentjs-rails' => '>= 2.9.0',
|
195
|
-
'bootstrap3-datetimepicker-rails' => '~> 4.17.47'
|
195
|
+
'bootstrap3-datetimepicker-rails' => '~> 4.17.47',
|
196
|
+
'jquery-rails' => '4.3.1'
|
196
197
|
}
|
197
198
|
|
198
199
|
# Si engine il faut mettre les gems dans le gemspec et faire le require
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding : utf-8
|
2
2
|
class BeautifulScaffoldGenerator < Rails::Generators::Base
|
3
|
-
|
3
|
+
require_relative 'beautiful_scaffold_common_methods'
|
4
4
|
include BeautifulScaffoldCommonMethods
|
5
5
|
|
6
6
|
# Resources
|
@@ -13,12 +13,12 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
13
13
|
|
14
14
|
source_root File.expand_path('../templates', __FILE__)
|
15
15
|
|
16
|
-
argument :model_opt, :
|
17
|
-
argument :myattributes, :
|
18
|
-
|
19
|
-
class_option :namespace, :
|
20
|
-
class_option :donttouchgem, :
|
21
|
-
class_option :mountable_engine, :
|
16
|
+
argument :model_opt, type: :string, desc: "Name of model (singular)"
|
17
|
+
argument :myattributes, type: :array, default: [], banner: "field:type field:type"
|
18
|
+
|
19
|
+
class_option :namespace, default: nil
|
20
|
+
class_option :donttouchgem, default: nil
|
21
|
+
class_option :mountable_engine, default: nil
|
22
22
|
|
23
23
|
def install_gems
|
24
24
|
if options[:donttouchgem].blank? then
|
@@ -54,11 +54,11 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def generate_assets
|
59
59
|
stylesheetspath = "app/assets/stylesheets/"
|
60
60
|
stylesheetspath_dest = "#{stylesheetspath}#{engine_name}"
|
61
|
-
|
61
|
+
|
62
62
|
# Css
|
63
63
|
reset = "reset.css"
|
64
64
|
bc_css = [
|
@@ -75,7 +75,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
75
75
|
[reset, bc_css].flatten.each{ |path|
|
76
76
|
copy_file "#{stylesheetspath}#{path}", "#{stylesheetspath_dest}#{path}"
|
77
77
|
}
|
78
|
-
|
78
|
+
|
79
79
|
# Js
|
80
80
|
bc_js = [
|
81
81
|
"application-bs.js",
|
@@ -102,12 +102,6 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
102
102
|
dir_image_dest = "app/assets/images/#{engine_opt}"
|
103
103
|
directory dir_image, dir_image_dest
|
104
104
|
|
105
|
-
# Old method
|
106
|
-
#generate("bootstrap:install","static")
|
107
|
-
# New method
|
108
|
-
copy_file "#{stylesheetspath}bootstrap_and_overrides.css.less",
|
109
|
-
"#{stylesheetspath_dest}bootstrap_and_overrides.css.less"
|
110
|
-
|
111
105
|
# Precompile BS assets
|
112
106
|
if File.exist?("config/initializers/assets.rb") then # For mountable engine
|
113
107
|
inject_into_file("config/initializers/assets.rb", "Rails.application.config.assets.precompile += ['#{engine_name}application-bs.css','#{engine_name}application-bs.js']", after: /\z/m)
|
@@ -115,7 +109,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
115
109
|
puts "============> Engine : You must add `Rails.application.config.assets.precompile += ['#{engine_name}application-bs.css','#{engine_name}application-bs.js']` to your config/initializers/assets.rb main app !"
|
116
110
|
end
|
117
111
|
end
|
118
|
-
|
112
|
+
|
119
113
|
def generate_layout
|
120
114
|
template "app/views/layout.html.erb", "app/views/layouts/beautiful_layout.html.erb"
|
121
115
|
if not File.exist?("app/views/layouts/_beautiful_menu.html.erb") then
|
@@ -126,7 +120,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
126
120
|
template "app/views/dashboard.html.erb", "app/views/#{engine_name}beautiful/dashboard.html.erb"
|
127
121
|
copy_file "app/views/_modal_columns.html.erb", "app/views/layouts/_modal_columns.html.erb"
|
128
122
|
copy_file "app/views/_mass_inserting.html.erb", "app/views/layouts/_mass_inserting.html.erb"
|
129
|
-
|
123
|
+
|
130
124
|
inject_into_file("app/views/layouts/_beautiful_menu.html.erb",'
|
131
125
|
<li class="<%= "active" if params[:controller] == "' + namespace_for_url + model.pluralize + '" %>">
|
132
126
|
<%= link_to ' + i18n_t_m_p(model) + '.capitalize, ' + namespace_for_route + model.pluralize + '_path %>
|
@@ -177,7 +171,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
177
171
|
dest_ctrl_file = File.join([dirs, "#{model_pluralize}_controller.rb"].flatten)
|
178
172
|
template "app/controllers/base.rb", dest_ctrl_file
|
179
173
|
end
|
180
|
-
|
174
|
+
|
181
175
|
def generate_helper
|
182
176
|
dest_bs_helper_file = "app/helpers/#{engine_name}beautiful_helper.rb"
|
183
177
|
template "app/helpers/beautiful_helper.rb", dest_bs_helper_file
|
@@ -191,15 +185,14 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
191
185
|
def generate_views
|
192
186
|
namespacedirs = ["app", "views", engine_name, options[:namespace]].compact
|
193
187
|
empty_directory File.join(namespacedirs)
|
194
|
-
|
188
|
+
|
195
189
|
dirs = [namespacedirs, model_pluralize]
|
196
190
|
empty_directory File.join(dirs)
|
197
|
-
|
191
|
+
|
198
192
|
[available_views, 'treeview'].flatten.each do |view|
|
199
193
|
filename = view + ".html.erb"
|
200
194
|
current_template_path = File.join([dirs, filename].flatten)
|
201
195
|
empty_template_path = File.join(["app", "views", filename].flatten)
|
202
|
-
|
203
196
|
template empty_template_path, current_template_path
|
204
197
|
end
|
205
198
|
|
@@ -215,12 +208,8 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
215
208
|
end
|
216
209
|
|
217
210
|
def routes
|
218
|
-
|
219
|
-
|
220
|
-
if not routes_in_text[/beautiful#dashboard/] and not routes_in_text[/beautiful#select_fields/] then
|
221
|
-
|
222
|
-
myroute = <<EOF
|
223
|
-
root :to => 'beautiful#dashboard'
|
211
|
+
myroute = <<EOF
|
212
|
+
root :to => 'beautiful#dashboard'
|
224
213
|
match ':model_sym/select_fields' => 'beautiful#select_fields', :via => [:get, :post]
|
225
214
|
|
226
215
|
concern :bs_routes do
|
@@ -237,11 +226,7 @@ root :to => 'beautiful#dashboard'
|
|
237
226
|
# Add route with concerns: :bs_routes here # Do not remove
|
238
227
|
EOF
|
239
228
|
|
240
|
-
|
241
|
-
end
|
242
|
-
|
243
|
-
search_namespace = namespace_alone + "/" if not namespace_alone.blank?
|
244
|
-
search_namespace ||= ""
|
229
|
+
inject_into_file("config/routes.rb", myroute, :after => "routes.draw do\n")
|
245
230
|
|
246
231
|
myroute = "\n "
|
247
232
|
myroute += "namespace :#{namespace_alone} do\n " if not namespace_alone.blank?
|
@@ -2,7 +2,16 @@ function datetimepicker_init(){
|
|
2
2
|
$(document).on('click', '.dpicker', function(e){
|
3
3
|
e.stopPropagation();
|
4
4
|
e.stopImmediatePropagation();
|
5
|
-
$(this).datetimepicker({
|
5
|
+
$(this).datetimepicker({
|
6
|
+
format : 'DD/MM/YYYY',
|
7
|
+
locale : 'en',
|
8
|
+
icons: {
|
9
|
+
time: "fa fa-clock-o",
|
10
|
+
date: "fa fa-calendar",
|
11
|
+
up: "fa fa-arrow-up",
|
12
|
+
down: "fa fa-arrow-down"
|
13
|
+
}
|
14
|
+
}).on('dp.change', function(elt){
|
6
15
|
var eltid = elt.currentTarget.dataset.id;
|
7
16
|
$('#' + eltid + '_3i').val(elt.date.date());
|
8
17
|
$('#' + eltid + '_2i').val(elt.date.month()+1);
|
@@ -15,7 +24,16 @@ function datetimepicker_init(){
|
|
15
24
|
$(document).on('click', '.tpicker', function(e){
|
16
25
|
e.stopPropagation();
|
17
26
|
e.stopImmediatePropagation();
|
18
|
-
$(this).datetimepicker({
|
27
|
+
$(this).datetimepicker({
|
28
|
+
format : 'HH:mm',
|
29
|
+
locale : 'en',
|
30
|
+
icons: {
|
31
|
+
time: "fa fa-clock-o",
|
32
|
+
date: "fa fa-calendar",
|
33
|
+
up: "fa fa-arrow-up",
|
34
|
+
down: "fa fa-arrow-down"
|
35
|
+
}
|
36
|
+
}).on('dp.change', function(elt){
|
19
37
|
var eltid = elt.currentTarget.dataset.id;
|
20
38
|
$('#' + eltid + '_4i').val(elt.date.hour());
|
21
39
|
$('#' + eltid + '_5i').val(elt.date.minute());
|
@@ -11,11 +11,12 @@
|
|
11
11
|
*= require_self
|
12
12
|
*= require reset
|
13
13
|
*= require jquery-ui
|
14
|
+
*= require twitter-bootstrap-static/bootstrap
|
15
|
+
*= require font-awesome
|
14
16
|
*= require bootstrap-datetimepicker
|
15
17
|
*= require beautiful-scaffold
|
16
18
|
*= require tagit-dark-grey
|
17
19
|
*= require colorpicker
|
18
20
|
*= require bootstrap-wysihtml5
|
19
|
-
*= require bootstrap_and_overrides
|
20
21
|
*= require chardinjs
|
21
22
|
*/
|
@@ -58,7 +58,7 @@ class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < Beau
|
|
58
58
|
csv << <%= model_camelize %>.attribute_names.map{ |a| o[a] }
|
59
59
|
}
|
60
60
|
end
|
61
|
-
render :
|
61
|
+
render :plain => csvstr
|
62
62
|
}
|
63
63
|
format.xml{
|
64
64
|
render :xml => @<%= model %>_scope.to_a
|
@@ -189,7 +189,12 @@ class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < Beau
|
|
189
189
|
modelclass = <%= model_camelize %>
|
190
190
|
foreignkey = :<%= model %>_id
|
191
191
|
|
192
|
-
|
192
|
+
|
193
|
+
if update_treeview(modelclass, foreignkey)
|
194
|
+
head :ok
|
195
|
+
else
|
196
|
+
head :internal_server_error
|
197
|
+
end
|
193
198
|
end
|
194
199
|
|
195
200
|
private
|
@@ -17,6 +17,9 @@ end
|
|
17
17
|
<%% end %>
|
18
18
|
<%= render_partial 'app/views/partials/_form_field.html.erb' %><!-- Beautiful_scaffold - AddField - Do not remove -->
|
19
19
|
<div>
|
20
|
+
<%%= link_to <%= namespace_for_route %><%= plural_table_name %>_path, :class => "btn btn-default" do %>
|
21
|
+
<i class="fa fa-chevron-left"></i> <%%= t(:back, :default => "Back") %>
|
22
|
+
<%% end %>
|
20
23
|
<%%= f.submit :class => "btn btn-primary", :data => { :disable_with => t(:saving, :default => "Saving...") } %>
|
21
24
|
</div>
|
22
25
|
<%% end %>
|
@@ -1,5 +1,3 @@
|
|
1
1
|
<h2><%%= t(:editing, :default => 'Editing') %> <%%= <%= i18n_t_m(singular_table_name) %> %></h2>
|
2
2
|
|
3
|
-
<%%= render 'form' %>
|
4
|
-
|
5
|
-
<%%= link_to t(:back, :default => "Back"), <%= namespace_for_route %><%= plural_table_name %>_path, :class => "btn btn-default" %>
|
3
|
+
<%%= render 'form' %>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'thor'
|
3
|
+
require 'rails'
|
4
|
+
require 'rails/generators'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
|
7
|
+
require_relative File.expand_path("../../lib/generators/beautiful_scaffold_generator", __FILE__)
|
8
|
+
|
9
|
+
ENV["RAILS_ENV"] = 'test'
|
10
|
+
|
11
|
+
class ScaffoldGeneratorTest < ::Rails::Generators::TestCase
|
12
|
+
|
13
|
+
tests BeautifulScaffoldGenerator
|
14
|
+
destination File.expand_path("../tmp/dummyapp", File.dirname(__FILE__))
|
15
|
+
|
16
|
+
def create_generator_sample_app
|
17
|
+
if !File.exist?(destination_root)
|
18
|
+
puts "---> Create Dummy App #{destination_root}"
|
19
|
+
FileUtils.cd(File.dirname(destination_root)) do
|
20
|
+
system "rails new dummyapp --quiet --skip-bundle"
|
21
|
+
end
|
22
|
+
|
23
|
+
test_params = "User email:string birthday:datetime children:integer biography:text"
|
24
|
+
|
25
|
+
run_generator test_params.split(' ')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Minitest.after_run do
|
30
|
+
FileUtils.rm_rf(destination_root)
|
31
|
+
end
|
32
|
+
|
33
|
+
setup do
|
34
|
+
create_generator_sample_app
|
35
|
+
end
|
36
|
+
|
37
|
+
test "generates js css" do
|
38
|
+
assert_file "app/assets/javascripts/application-bs.js"
|
39
|
+
assert_file "app/assets/javascripts/beautiful_scaffold.js"
|
40
|
+
assert_file "app/assets/javascripts/bootstrap-colorpicker.js"
|
41
|
+
assert_file "app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js"
|
42
|
+
assert_file "app/assets/javascripts/bootstrap-wysihtml5.js"
|
43
|
+
end
|
44
|
+
|
45
|
+
test "generates model" do
|
46
|
+
assert_file "app/models/user.rb" do |content|
|
47
|
+
assert_match('self.permitted_attributes', content)
|
48
|
+
#assert_match(/return #{test_params.split(' ')[1..-1]keys.map{ |k| ":#{k}"}.join(',')}/, content)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
test "generates controller" do
|
53
|
+
assert_file "app/controllers/users_controller.rb" do |content|
|
54
|
+
assert_match("session['fields']['user'] ||= (User.columns.map(&:name) - [\"id\"])[0..4]", content)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
test "generates initializer" do
|
59
|
+
assert_file "config/initializers/ransack.rb" do |content|
|
60
|
+
assert_match('Ransack.configure do |config|', content)
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_file "config/initializers/link_renderer.rb" do |content|
|
64
|
+
assert_match('class LinkRenderer < LinkRendererBase', content)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beautiful_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Claudel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Beautiful Scaffold generate a complete scaffold (sort, export, paginate
|
14
14
|
and filter data) http://www.beautiful-scaffold.com
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- Gemfile
|
23
23
|
- MIT-LICENSE
|
24
24
|
- README.rdoc
|
25
|
+
- Rakefile
|
25
26
|
- beautiful_scaffold.gemspec
|
26
27
|
- lib/generators/USAGE
|
27
28
|
- lib/generators/beautiful_devisecancan_generator.rb
|
@@ -49,7 +50,6 @@ files:
|
|
49
50
|
- lib/generators/templates/app/assets/stylesheets/application-bs.css
|
50
51
|
- lib/generators/templates/app/assets/stylesheets/beautiful-scaffold.css.scss
|
51
52
|
- lib/generators/templates/app/assets/stylesheets/bootstrap-wysihtml5.css
|
52
|
-
- lib/generators/templates/app/assets/stylesheets/bootstrap_and_overrides.css.less
|
53
53
|
- lib/generators/templates/app/assets/stylesheets/colorpicker.css
|
54
54
|
- lib/generators/templates/app/assets/stylesheets/datepicker.css
|
55
55
|
- lib/generators/templates/app/assets/stylesheets/reset.css
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/generators/templates/app/views/show.html.erb
|
98
98
|
- lib/generators/templates/app/views/treeview.html.erb
|
99
99
|
- lib/generators/templates/lib/custom_failure.rb
|
100
|
+
- test/scaffold_test.rb
|
100
101
|
homepage: http://beautiful-scaffold.com
|
101
102
|
licenses:
|
102
103
|
- MIT
|
@@ -106,6 +107,7 @@ rdoc_options: []
|
|
106
107
|
require_paths:
|
107
108
|
- lib
|
108
109
|
- lib/generators
|
110
|
+
- test/*
|
109
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
112
|
requirements:
|
111
113
|
- - ">="
|
@@ -118,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
120
|
version: '0'
|
119
121
|
requirements: []
|
120
122
|
rubyforge_project: beautiful_scaffold
|
121
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.12
|
122
124
|
signing_key:
|
123
125
|
specification_version: 4
|
124
126
|
summary: Beautiful Scaffold generate fully customizable scaffold
|
@@ -1,40 +0,0 @@
|
|
1
|
-
//= de pend_on_asset "glyphicons-halflings-regular.eot"
|
2
|
-
//= de pend_on_asset "glyphicons-halflings-regular.woff"
|
3
|
-
//= de pend_on_asset "glyphicons-halflings-regular.ttf"
|
4
|
-
//= de pend_on_asset "glyphicons-halflings-regular.svg"
|
5
|
-
//= de pend_on_asset "twitter/bootstrap/glyphicons-halflings.png"
|
6
|
-
//= de pend_on_asset "twitter/bootstrap/glyphicons-halflings-white.png"
|
7
|
-
//= depend_on_asset "fontawesome-webfont.eot"
|
8
|
-
//= depend_on_asset "fontawesome-webfont.woff"
|
9
|
-
//= depend_on_asset "fontawesome-webfont.ttf"
|
10
|
-
//= depend_on_asset "fontawesome-webfont.svg"
|
11
|
-
|
12
|
-
@import "twitter/bootstrap/bootstrap";
|
13
|
-
|
14
|
-
// Set the correct sprite paths
|
15
|
-
@iconSpritePath: image-url("twitter/bootstrap/glyphicons-halflings.png");
|
16
|
-
@iconWhiteSpritePath: image-url("twitter/bootstrap/glyphicons-halflings-white.png");
|
17
|
-
|
18
|
-
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
|
19
|
-
@fontAwesomeEotPath: asset-url("fontawesome-webfont.eot");
|
20
|
-
@fontAwesomeEotPath_iefix: asset-url("fontawesome-webfont.eot?#iefix");
|
21
|
-
@fontAwesomeWoffPath: asset-url("fontawesome-webfont.woff");
|
22
|
-
@fontAwesomeTtfPath: asset-url("fontawesome-webfont.ttf");
|
23
|
-
@fontAwesomeSvgPath: asset-url("fontawesome-webfont.svg#fontawesomeregular");
|
24
|
-
|
25
|
-
// Font Awesome
|
26
|
-
@import "fontawesome/font-awesome";
|
27
|
-
|
28
|
-
// Glyphicons
|
29
|
-
//@import "twitter/bootstrap/sprites.less";
|
30
|
-
|
31
|
-
// Your custom LESS stylesheets goes here
|
32
|
-
//
|
33
|
-
// Since bootstrap was imported above you have access to its mixins which
|
34
|
-
// you may use and inherit here
|
35
|
-
//
|
36
|
-
// If you'd like to override bootstrap's own variables, you can do so here as well
|
37
|
-
// See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation
|
38
|
-
//
|
39
|
-
// Example:
|
40
|
-
// @linkColor: #ff0000;
|