leonardo 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +13 -0
- data/lib/generators/erb/leosca/templates/_list.erb +2 -1
- data/lib/generators/leolay/leolay_generator.rb +16 -1
- data/lib/generators/leolay/templates/config/locales/en.yml +1 -0
- data/lib/generators/leolay/templates/config/locales/it.yml +1 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/style/arrow_down.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/images/style/arrow_up.png +0 -0
- data/lib/generators/leolay/templates/styles/cloudy/stylesheets/app/stylesheet.sass +14 -1
- data/lib/generators/leonardo.rb +8 -5
- data/lib/generators/rails/leosca_controller/templates/controller.rb +10 -1
- data/template.rb +0 -1
- metadata +7 -5
data/CHANGELOG
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
1.8.0 (October 7th, 2011) Marco Mastrodonato
|
2
|
+
* Added sortable columns
|
3
|
+
|
4
|
+
TODO:
|
5
|
+
* Pass spec index view with new sortable helpers
|
6
|
+
* Lists: Multiple selection and multiple operation
|
7
|
+
* Lists: Add id as first column
|
8
|
+
* Model: Create name attribute for every one that does not have
|
9
|
+
* Handle eager loading including child resources
|
10
|
+
* Add user management
|
11
|
+
|
12
|
+
|
13
|
+
|
1
14
|
1.7.2 (October 5th, 2011) Marco Mastrodonato
|
2
15
|
* Updated formtastic support to version 2.0
|
3
16
|
* Updated template.rb
|
@@ -7,7 +7,8 @@
|
|
7
7
|
<thead>
|
8
8
|
<tr>
|
9
9
|
<%- attributes.each do |attribute| -%>
|
10
|
-
|
10
|
+
<%- attr_name = case attribute.type when :references, :belongs_to then "#{attribute.name}_id" else attribute.name end -%>
|
11
|
+
<th><%%= sortable :<%= attr_name %>, t('attributes.<%= singular_table_name %>.<%= attribute.name %>'), remote %></th>
|
11
12
|
<%- end -%>
|
12
13
|
<th></th>
|
13
14
|
<th></th>
|
@@ -87,7 +87,6 @@ class LeolayGenerator < Rails::Generators::Base
|
|
87
87
|
FILE
|
88
88
|
end if options.authorization?
|
89
89
|
|
90
|
-
#{options.authentication? ? ", :authenticate_user!" : ""}
|
91
90
|
inject_into_class file, ApplicationController do
|
92
91
|
<<-FILE.gsub(/^ /, '')
|
93
92
|
before_filter :localizate
|
@@ -103,6 +102,22 @@ class LeolayGenerator < Rails::Generators::Base
|
|
103
102
|
FILE
|
104
103
|
end
|
105
104
|
end
|
105
|
+
|
106
|
+
file = "app/helpers/application_helper.rb"
|
107
|
+
if File.exists?(file)
|
108
|
+
inject_into_file file, :after => "module ApplicationHelper" do
|
109
|
+
<<-FILE.gsub(/^ /, '')
|
110
|
+
|
111
|
+
def sortable(column, title = nil, remote = nil)
|
112
|
+
column = column.to_s
|
113
|
+
title ||= column.titleize
|
114
|
+
css_class = (column == sort_column) ? "sorted \#{sort_direction}" : nil
|
115
|
+
direction = (column == sort_column && sort_direction == "asc") ? "desc" : "asc"
|
116
|
+
link_to(title, {:sort => column, :direction => direction}, :remote => true, :disable_with => t(:loading), :class => css_class)
|
117
|
+
end
|
118
|
+
FILE
|
119
|
+
end
|
120
|
+
end
|
106
121
|
end
|
107
122
|
|
108
123
|
def setup_authentication
|
@@ -251,9 +251,13 @@ table.user
|
|
251
251
|
width: 100%
|
252
252
|
thead
|
253
253
|
tr
|
254
|
-
|
254
|
+
& :hover
|
255
255
|
background-color: inherit
|
256
256
|
th
|
257
|
+
& :link, & :visited
|
258
|
+
color: $title_color
|
259
|
+
& :hover, & :active
|
260
|
+
color: $text_color
|
257
261
|
//background-color: $main_bg
|
258
262
|
color: $title_color
|
259
263
|
padding: 0.2em 0.4em
|
@@ -261,6 +265,15 @@ table.user
|
|
261
265
|
&.main
|
262
266
|
font-weight: bold
|
263
267
|
text-align: center
|
268
|
+
& .sorted
|
269
|
+
color: $text_color
|
270
|
+
padding-right: 10px
|
271
|
+
background-repeat: no-repeat
|
272
|
+
background-position: right center
|
273
|
+
& .asc
|
274
|
+
background-image: url($style_path + '/arrow_up.png')
|
275
|
+
& .desc
|
276
|
+
background-image: url($style_path + '/arrow_down.png')
|
264
277
|
tbody
|
265
278
|
tr
|
266
279
|
line-height: 1.2em
|
data/lib/generators/leonardo.rb
CHANGED
@@ -37,12 +37,15 @@ module Leonardo
|
|
37
37
|
" #{name} => #{value}"
|
38
38
|
end
|
39
39
|
def attribute_to_factories(attribute)
|
40
|
-
|
40
|
+
spaces = 34
|
41
|
+
space_association = " " * (spaces-11).abs
|
42
|
+
space_sequence = " " * (spaces-attribute.name.size-11).abs
|
43
|
+
space_other = " " * (spaces-attribute.name.size).abs
|
41
44
|
name = case attribute.type
|
42
|
-
when :references, :belongs_to then "#{singular_table_name[0..0]}.association
|
45
|
+
when :references, :belongs_to then "#{singular_table_name[0..0]}.association#{space_association}"
|
43
46
|
when :boolean, :datetime, :time, :timestamp
|
44
|
-
then "#{singular_table_name[0..0]}.#{attribute.name}
|
45
|
-
else "#{singular_table_name[0..0]}.sequence(:#{attribute.name})#{
|
47
|
+
then "#{singular_table_name[0..0]}.#{attribute.name}#{space_other}"
|
48
|
+
else "#{singular_table_name[0..0]}.sequence(:#{attribute.name})#{space_sequence}"
|
46
49
|
end
|
47
50
|
value = case attribute.type
|
48
51
|
when :boolean then "true"
|
@@ -54,7 +57,7 @@ module Leonardo
|
|
54
57
|
when :time, :timestamp then "#{Time.now.strftime("%H:%M:%S.000")}".inspect
|
55
58
|
else "{|n| \"#{attribute.name.titleize}\#{n}\" }"
|
56
59
|
end
|
57
|
-
" #{name}
|
60
|
+
" #{name}#{value}"
|
58
61
|
end
|
59
62
|
def attribute_to_requests(attribute)
|
60
63
|
case attribute.type
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
2
|
class <%= leospaced? ? (base_namespaces << controller_class_name).join('/').camelize : controller_class_name %>Controller < ApplicationController
|
3
|
+
helper_method :sort_column, :sort_direction
|
3
4
|
<%= "before_filter :authenticate_user!#{CRLF}" if authentication? -%>
|
4
5
|
<%= "load_and_authorize_resource#{CRLF}" if authorization? -%>
|
5
6
|
<%#= "before_filter :load_parents#{CRLF}" if nested? -%>
|
@@ -58,7 +59,7 @@ end
|
|
58
59
|
|
59
60
|
@<%= plural_table_name %> = case request.format
|
60
61
|
when 'text/html', 'text/javascript'
|
61
|
-
<%= class_name %>.where(conditions).order(
|
62
|
+
<%= class_name %>.where(conditions).order("#{sort_column} #{sort_direction}")<%= ".page(params[:page])" if pagination? %>
|
62
63
|
else
|
63
64
|
<%= class_name %>.where(conditions)
|
64
65
|
end
|
@@ -156,5 +157,13 @@ end
|
|
156
157
|
format.js
|
157
158
|
end
|
158
159
|
end
|
160
|
+
|
161
|
+
private
|
162
|
+
def sort_direction
|
163
|
+
%w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
|
164
|
+
end
|
165
|
+
def sort_column
|
166
|
+
<%= class_name %>.column_names.include?(params[:sort]) ? params[:sort] : "id"
|
167
|
+
end
|
159
168
|
end
|
160
169
|
<% end -%>
|
data/template.rb
CHANGED
@@ -100,7 +100,6 @@ generate "autocomplete:install" if ajax
|
|
100
100
|
####################################################################
|
101
101
|
# F I X
|
102
102
|
####################################################################
|
103
|
-
p "Update source path #{File.join(File.dirname(__FILE__), app_name)}"
|
104
103
|
source_paths << File.join(File.dirname(__FILE__), app_name)
|
105
104
|
|
106
105
|
if formtastic
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leonardo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 8
|
9
|
+
- 0
|
10
|
+
version: 1.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marco Mastrodonato
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-07 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: 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
|
@@ -81,6 +81,8 @@ files:
|
|
81
81
|
- lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-icons_ffd27a_256x240.png
|
82
82
|
- lib/generators/leolay/templates/styles/cloudy/images/jquery-ui/ui-icons_ffffff_256x240.png
|
83
83
|
- lib/generators/leolay/templates/styles/cloudy/images/kaminari/nav.png
|
84
|
+
- lib/generators/leolay/templates/styles/cloudy/images/style/arrow_down.png
|
85
|
+
- lib/generators/leolay/templates/styles/cloudy/images/style/arrow_up.png
|
84
86
|
- lib/generators/leolay/templates/styles/cloudy/images/style/bg_but_gray.png
|
85
87
|
- lib/generators/leolay/templates/styles/cloudy/images/style/bg_top.png
|
86
88
|
- lib/generators/leolay/templates/styles/cloudy/images/style/button_170_126.png
|