fesplugas-typus 0.9.9 → 0.9.10

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.
Files changed (33) hide show
  1. data/README.rdoc +3 -0
  2. data/VERSION +1 -1
  3. data/app/controllers/admin/master_controller.rb +18 -8
  4. data/app/helpers/admin/form_helper.rb +15 -6
  5. data/app/helpers/admin/master_helper.rb +1 -1
  6. data/app/helpers/admin/sidebar_helper.rb +1 -1
  7. data/app/helpers/admin/table_helper.rb +3 -3
  8. data/app/helpers/typus_helper.rb +15 -10
  9. data/app/views/admin/resources/edit.html.erb +1 -1
  10. data/app/views/admin/resources/index.html.erb +3 -3
  11. data/app/views/admin/resources/new.html.erb +1 -1
  12. data/app/views/admin/resources/show.html.erb +1 -1
  13. data/app/views/layouts/admin.html.erb +1 -0
  14. data/config/locales/{es.yml → typus/es.yml} +9 -3
  15. data/config/locales/typus/language.yml.template +113 -0
  16. data/config/locales/{pt-BR.yml → typus/pt-BR.yml} +7 -1
  17. data/config/locales/{ru.yml → typus/ru.yml} +7 -1
  18. data/generators/typus/templates/config/initializers/typus.rb +4 -0
  19. data/generators/typus/templates/config/typus/application.yml +9 -0
  20. data/generators/typus/templates/public/stylesheets/admin/screen.css +14 -14
  21. data/generators/typus/typus_generator.rb +30 -22
  22. data/lib/typus/active_record.rb +46 -10
  23. data/lib/typus/configuration.rb +4 -0
  24. data/lib/typus.rb +4 -0
  25. data/tasks/typus_tasks.rake +13 -7
  26. data/test/config/working/application.yml +1 -0
  27. data/test/helpers/typus_helper_test.rb +7 -5
  28. data/test/lib/active_record_test.rb +17 -12
  29. data/test/lib/configuration_test.rb +3 -2
  30. data/test/lib/typus_test.rb +5 -0
  31. data/typus.gemspec +6 -6
  32. metadata +6 -6
  33. data/config/locales/typus_hacks.yml +0 -19
data/README.rdoc CHANGED
@@ -10,6 +10,7 @@ extensible enough to match lots of use cases.
10
10
  - Project site and documentation http://intraducibles.com/projects/typus
11
11
  - Plugin source http://github.com/fesplugas/typus/tree
12
12
  - Google Group http://groups.google.es/group/typus
13
+ - Bugs http://typus.lighthouseapp.com/dashboard
13
14
 
14
15
  == Impatients to see it working?
15
16
 
@@ -69,6 +70,8 @@ Typus and blog about Typus.
69
70
  - José Valim (Code) http://github.com/josevalim
70
71
  - Luqman Amjad (Code) http://github.com/snake
71
72
  - Alexey Noskov (Russian translation and code) http://github.com/alno
73
+ - Andres Gutierres (Bugfixes & feedback) http://github.com/andresgutgon
74
+ - Komzák Nándor (Code, bugfixes & feedback) http://github.com/rubymood
72
75
 
73
76
  == Acknowledgments
74
77
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.9
1
+ 0.9.10
@@ -36,6 +36,9 @@ class Admin::MasterController < ApplicationController
36
36
  before_filter :set_fields,
37
37
  :only => [ :index, :new, :edit, :create, :update, :show ]
38
38
 
39
+ before_filter :set_tiny_mce,
40
+ :only => [ :new, :edit, :create, :update ]
41
+
39
42
  ##
40
43
  # This is the main index of the model. With filters, conditions
41
44
  # and more.
@@ -89,7 +92,7 @@ class Admin::MasterController < ApplicationController
89
92
  if @item.valid?
90
93
  create_with_back_to and return if params[:back_to]
91
94
  @item.save
92
- flash[:success] = _("{{model}} successfully created.", :model => @resource[:class].human_name)
95
+ flash[:success] = _("{{model}} successfully created.", :model => @resource[:class].typus_human_name)
93
96
  if @resource[:class].typus_options_for(:index_after_save)
94
97
  redirect_to :action => 'index'
95
98
  else
@@ -126,7 +129,7 @@ class Admin::MasterController < ApplicationController
126
129
 
127
130
  def update
128
131
  if @item.update_attributes(params[:item])
129
- flash[:success] = _("{{model}} successfully updated.", :model => @resource[:class].human_name)
132
+ flash[:success] = _("{{model}} successfully updated.", :model => @resource[:class].typus_human_name)
130
133
  path = if @resource[:class].typus_options_for(:index_after_save)
131
134
  params[:back_to] ? "#{params[:back_to]}##{@resource[:self]}" : { :action => 'index' }
132
135
  else
@@ -141,7 +144,7 @@ class Admin::MasterController < ApplicationController
141
144
 
142
145
  def destroy
143
146
  @item.destroy
144
- flash[:success] = _("{{model}} successfully removed.", :model => @resource[:class].human_name)
147
+ flash[:success] = _("{{model}} successfully removed.", :model => @resource[:class].typus_human_name)
145
148
  redirect_to :back
146
149
  rescue Exception => error
147
150
  error_handler(error, params.merge(:action => 'index', :id => nil))
@@ -151,7 +154,7 @@ class Admin::MasterController < ApplicationController
151
154
  if @resource[:class].typus_options_for(:toggle)
152
155
  @item.toggle!(params[:field])
153
156
  flash[:success] = _("{{model}} {{attribute}} changed.",
154
- :model => @resource[:class].human_name,
157
+ :model => @resource[:class].typus_human_name,
155
158
  :attribute => params[:field].humanize.downcase)
156
159
  else
157
160
  flash[:notice] = _("Toggle is disabled.")
@@ -186,8 +189,8 @@ class Admin::MasterController < ApplicationController
186
189
  @item.send(resource_tableized) << resource_class.find(params[:related][:id])
187
190
 
188
191
  flash[:success] = _("{{model_a}} related to {{model_b}}.",
189
- :model_a => resource_class.human_name,
190
- :model_b => @resource[:class].human_name)
192
+ :model_a => resource_class.typus_human_name,
193
+ :model_b => @resource[:class].typus_human_name)
191
194
 
192
195
  redirect_to :action => @resource[:class].typus_options_for(:default_action_on_item),
193
196
  :id => @item.id,
@@ -212,7 +215,7 @@ class Admin::MasterController < ApplicationController
212
215
  message = "{{model_a}} removed from {{model_b}}."
213
216
  end
214
217
 
215
- flash[:success] = _(message, :model_a => resource_class.human_name, :model_b => @resource[:class].human_name)
218
+ flash[:success] = _(message, :model_a => resource_class.typus_human_name, :model_b => @resource[:class].typus_human_name)
216
219
 
217
220
  redirect_to :controller => @resource[:self],
218
221
  :action => @resource[:class].typus_options_for(:default_action_on_item),
@@ -289,6 +292,13 @@ private
289
292
  @order = params[:order_by] ? "#{@resource[:class].table_name}.#{params[:order_by]} #{params[:sort_order]}" : @resource[:class].typus_order_by
290
293
  end
291
294
 
295
+ def set_tiny_mce
296
+ unless @resource[:class].typus_tiny_mce_fields.empty?
297
+ options = @resource[:class].typus_tiny_mce_options
298
+ self.class.class_eval { uses_tiny_mce :options => options }
299
+ end
300
+ end
301
+
292
302
  def select_template(template, resource = @resource[:self])
293
303
  folder = (File.exist?("app/views/admin/#{resource}/#{template}.html.erb")) ? resource : 'resources'
294
304
  render "admin/#{folder}/#{template}"
@@ -319,7 +329,7 @@ private
319
329
  @item.send(params[:resource]) << resource
320
330
  when :has_many
321
331
  @item.save
322
- message = _("{{model}} successfully created.", :model => @resource[:class].human_name)
332
+ message = _("{{model}} successfully created.", :model => @resource[:class].typus_human_name)
323
333
  path = "#{params[:back_to]}?#{params[:selected]}=#{@item.id}"
324
334
  when :polymorphic
325
335
  resource.send(@item.class.name.tableize).create(params[:item])
@@ -9,6 +9,7 @@ module Admin::FormHelper
9
9
  returning(String.new) do |html|
10
10
  html << (error_messages_for :item, :header_tag => 'h3')
11
11
  html << '<ul>'
12
+
12
13
  fields.each do |key, value|
13
14
  if template = @resource[:class].typus_template(key)
14
15
  html << typus_template_field(key, template, options)
@@ -23,6 +24,7 @@ module Admin::FormHelper
23
24
  when :password: html << typus_password_field(key)
24
25
  when :selector: html << typus_selector_field(key)
25
26
  when :text: html << typus_text_field(key)
27
+ when :tiny_mce: html << typus_tiny_mce_field(key)
26
28
  when :time: html << typus_time_field(key, options)
27
29
  when :tree: html << typus_tree_field(key)
28
30
  else
@@ -137,6 +139,13 @@ module Admin::FormHelper
137
139
  HTML
138
140
  end
139
141
 
142
+ def typus_tiny_mce_field(attribute)
143
+ <<-HTML
144
+ <li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
145
+ #{text_area :item, attribute, :class => 'mceEditor', :disabled => attribute_disabled?(attribute)}</li>
146
+ HTML
147
+ end
148
+
140
149
  def typus_time_field(attribute, options)
141
150
  <<-HTML
142
151
  <li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
@@ -225,7 +234,7 @@ module Admin::FormHelper
225
234
  <a name="#{field}"></a>
226
235
  <div class="box_relationships">
227
236
  <h2>
228
- #{link_to model_to_relate.human_name.pluralize, { :controller => "admin/#{model_to_relate_as_resource}", foreign_key => @item.id }, :title => _("{{model}} filtered by {{filtered_by}}", :model => model_to_relate.human_name.pluralize, :filtered_by => @item.typus_name)}
237
+ #{link_to model_to_relate.typus_human_name.pluralize, { :controller => "admin/#{model_to_relate_as_resource}", foreign_key => @item.id }, :title => _("{{model}} filtered by {{filtered_by}}", :model => model_to_relate.typus_human_name.pluralize, :filtered_by => @item.typus_name)}
229
238
  <small>#{link_to _("Add new"), link_options if @current_user.can_perform?(model_to_relate, 'create')}</small>
230
239
  </h2>
231
240
  HTML
@@ -246,7 +255,7 @@ module Admin::FormHelper
246
255
  association)
247
256
  else
248
257
  html << <<-HTML
249
- <div id="flash" class="notice"><p>#{_("There are no {{records}}.", :records => model_to_relate.human_name.pluralize.downcase)}</p></div>
258
+ <div id="flash" class="notice"><p>#{_("There are no {{records}}.", :records => model_to_relate.typus_human_name.pluralize.downcase)}</p></div>
250
259
  HTML
251
260
  end
252
261
  html << <<-HTML
@@ -268,7 +277,7 @@ module Admin::FormHelper
268
277
  <a name="#{field}"></a>
269
278
  <div class="box_relationships">
270
279
  <h2>
271
- #{link_to model_to_relate.human_name.pluralize, :controller => "admin/#{model_to_relate_as_resource}"}
280
+ #{link_to model_to_relate.typus_human_name.pluralize, :controller => "admin/#{model_to_relate_as_resource}"}
272
281
  <small>#{link_to _("Add new"), :controller => field, :action => 'new', :back_to => @back_to, :resource => @resource[:self], :resource_id => @item.id if @current_user.can_perform?(model_to_relate, 'create')}</small>
273
282
  </h2>
274
283
  HTML
@@ -291,7 +300,7 @@ module Admin::FormHelper
291
300
  association)
292
301
  else
293
302
  html << <<-HTML
294
- <div id="flash" class="notice"><p>#{_("There are no {{records}}.", :records => model_to_relate.human_name.pluralize.downcase)}</p></div>
303
+ <div id="flash" class="notice"><p>#{_("There are no {{records}}.", :records => model_to_relate.typus_human_name.pluralize.downcase)}</p></div>
295
304
  HTML
296
305
  end
297
306
  html << <<-HTML
@@ -313,7 +322,7 @@ module Admin::FormHelper
313
322
  <a name="#{field}"></a>
314
323
  <div class="box_relationships">
315
324
  <h2>
316
- #{link_to model_to_relate.human_name, :controller => "admin/#{model_to_relate_as_resource}"}
325
+ #{link_to model_to_relate.typus_human_name, :controller => "admin/#{model_to_relate_as_resource}"}
317
326
  </h2>
318
327
  HTML
319
328
  items = Array.new
@@ -328,7 +337,7 @@ module Admin::FormHelper
328
337
  association)
329
338
  else
330
339
  html << <<-HTML
331
- <div id="flash" class="notice"><p>#{_("There is no {{records}}.", :records => model_to_relate.human_name.downcase)}</p></div>
340
+ <div id="flash" class="notice"><p>#{_("There is no {{records}}.", :records => model_to_relate.typus_human_name.downcase)}</p></div>
332
341
  HTML
333
342
  end
334
343
  html << <<-HTML
@@ -9,7 +9,7 @@ module Admin::MasterHelper
9
9
  def display_link_to_previous # (_params = params)
10
10
 
11
11
  options = {}
12
- options[:resource_from] = @resource[:class].human_name
12
+ options[:resource_from] = @resource[:class].typus_human_name
13
13
  options[:resource_to] = params[:resource].classify.humanize if params[:resource]
14
14
 
15
15
  editing = %w( edit update ).include?(params[:action])
@@ -171,7 +171,7 @@ function surfto_#{model_pluralized}(form) {
171
171
  <!-- /Embedded JS -->
172
172
  <p><form class="form" action="#">
173
173
  <select name="#{model_pluralized}" onChange="surfto_#{model_pluralized}(this.form)">
174
- <option value="#{url_for params_without_filter}">#{_("filter by")} #{_(model.human_name)}</option>
174
+ <option value="#{url_for params_without_filter}">#{_("filter by")} #{_(model.typus_human_name)}</option>
175
175
  #{items.join("\n")}
176
176
  </select>
177
177
  </form></p>
@@ -5,7 +5,7 @@ module Admin::TableHelper
5
5
  returning(String.new) do |html|
6
6
 
7
7
  html << <<-HTML
8
- <table>
8
+ <table class="typus">
9
9
  HTML
10
10
 
11
11
  html << typus_table_header(model, fields)
@@ -55,8 +55,8 @@ module Admin::TableHelper
55
55
  :resource => model,
56
56
  :resource_id => item.id },
57
57
  :confirm => _("Unrelate {{unrelate_model}} from {{unrelate_model_from}}?",
58
- :unrelate_model => model.human_name,
59
- :unrelate_model_from => @resource[:class].human_name)
58
+ :unrelate_model => model.typus_human_name,
59
+ :unrelate_model_from => @resource[:class].typus_human_name)
60
60
  end
61
61
 
62
62
  html << <<-HTML
@@ -15,7 +15,7 @@ module TypusHelper
15
15
  next if available.compact.empty?
16
16
 
17
17
  html << <<-HTML
18
- <table>
18
+ <table class="typus">
19
19
  <tr>
20
20
  <th colspan="2">#{app}</th>
21
21
  </tr>
@@ -27,7 +27,7 @@ module TypusHelper
27
27
  new_admin_item_path = { :controller => "admin/#{model.tableize}", :action => 'new'}
28
28
  html << <<-HTML
29
29
  <tr class="#{cycle('even', 'odd')}">
30
- <td>#{link_to _(model.constantize.human_name.pluralize), admin_items_path}<br /><small>#{description}</small></td>
30
+ <td>#{link_to model.constantize.typus_human_name.pluralize, admin_items_path}<br /><small>#{description}</small></td>
31
31
  <td class="right"><small>
32
32
  #{link_to _("Add"), new_admin_item_path if @current_user.can_perform?(model, 'create')}
33
33
  </small></td>
@@ -58,7 +58,7 @@ module TypusHelper
58
58
  returning(String.new) do |html|
59
59
 
60
60
  html << <<-HTML
61
- <table>
61
+ <table class="typus">
62
62
  <tr>
63
63
  <th colspan="2">#{_("Resources")}</th>
64
64
  </tr>
@@ -93,7 +93,8 @@ module TypusHelper
93
93
  resources_partials_path = 'admin/resources'
94
94
 
95
95
  partials = ActionController::Base.view_paths.map do |view_path|
96
- Dir["#{Rails.root}/#{view_path}/#{partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
96
+ path = Rails.vendor_rails? ? view_path.path : "#{Rails.root}/#{view_path}"
97
+ Dir["#{path}/#{partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
97
98
  end.flatten
98
99
  resources_partials = Dir["#{Rails.root}/app/views/#{resources_partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
99
100
 
@@ -109,24 +110,28 @@ module TypusHelper
109
110
 
110
111
  def page_title(action = params[:action])
111
112
  crumbs = [ ]
112
- crumbs << @resource[:class].human_name.pluralize if @resource
113
+ crumbs << @resource[:class].typus_human_name.pluralize if @resource
113
114
  crumbs << _(action.humanize) unless %w( index ).include?(action)
114
115
  return "#{Typus::Configuration.options[:app_name]} - " + crumbs.compact.map { |x| x }.join(' &rsaquo; ')
115
116
  end
116
117
 
117
118
  def header
118
119
 
119
- if ActionController::Routing::Routes.named_routes.routes.keys.include?(:root)
120
- link_to_site = "<li>#{link_to _("View site"), root_path, :target => 'blank'}</li>"
120
+ links = []
121
+ links << "<li>#{link_to_unless_current _("Dashboard"), admin_dashboard_path}</li>"
122
+
123
+ Typus.models_on_header.each do |model|
124
+ links << "<li>#{link_to_unless_current model.constantize.typus_human_name.pluralize, :controller => "/admin/#{model.tableize}"}</li>"
121
125
  end
122
126
 
123
- link_to_dashboard = "<li>#{link_to _("Dashboard"), admin_dashboard_path}</li>"
127
+ if ActionController::Routing::Routes.named_routes.routes.keys.include?(:root)
128
+ links << "<li>#{link_to _("View site"), root_path, :target => 'blank'}</li>"
129
+ end
124
130
 
125
131
  <<-HTML
126
132
  <h1>#{Typus::Configuration.options[:app_name]}</h1>
127
133
  <ul>
128
- #{link_to_dashboard}
129
- #{link_to_site}
134
+ #{links.join("\n")}
130
135
  </ul>
131
136
  HTML
132
137
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  <%= display_link_to_previous if params[:back_to] %>
7
7
 
8
- <h2><%= link_to _(@resource[:class].human_name.pluralize), :action => 'index' %> &rsaquo;
8
+ <h2><%= link_to @resource[:class].typus_human_name.pluralize, :action => 'index' %> &rsaquo;
9
9
  <%= _("Edit") %></h2>
10
10
 
11
11
  <%= typus_block :location => @resource[:self], :partial => 'edit' %>
@@ -5,7 +5,7 @@
5
5
  <%= filters %>
6
6
  <% end %>
7
7
 
8
- <h2><%= _(@resource[:class].human_name.pluralize) %> <%= remove_filter_link %></h2>
8
+ <h2><%= @resource[:class].typus_human_name.pluralize %> <%= remove_filter_link %></h2>
9
9
 
10
10
  <%= typus_block :location => @resource[:self], :partial => 'index' %>
11
11
 
@@ -15,9 +15,9 @@
15
15
  <% else %>
16
16
  <div id="flash" class="notice">
17
17
  <% if @resource[:class].count.zero? %>
18
- <p><%= _("There are no {{records}}.", :records => @resource[:class].human_name.pluralize.downcase) %></p>
18
+ <p><%= _("There are no {{records}}.", :records => @resource[:class].typus_human_name.pluralize.downcase) %></p>
19
19
  <% else %>
20
- <p><%= _("There are no {{records}} under this filter.", :records => @resource[:class].human_name.pluralize.downcase) %></p>
20
+ <p><%= _("There are no {{records}} under this filter.", :records => @resource[:class].typus_human_name.pluralize.downcase) %></p>
21
21
  <% end %>
22
22
  </div>
23
23
  <% end %>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <%= display_link_to_previous if params[:back_to] %>
7
7
 
8
- <h2><%= link_to _(@resource[:class].human_name.pluralize), :action => 'index' %> &rsaquo;
8
+ <h2><%= link_to @resource[:class].typus_human_name.pluralize, :action => 'index' %> &rsaquo;
9
9
  <%= _("New") %></h2>
10
10
 
11
11
  <%= typus_block :location => @resource[:self], :partial => 'new' %>
@@ -3,7 +3,7 @@
3
3
  <%= actions %>
4
4
  <% end %>
5
5
 
6
- <h2><%= link_to _(@resource[:class].human_name.pluralize), :action => 'index' %> &rsaquo;
6
+ <h2><%= link_to @resource[:class].typus_human_name.pluralize, :action => 'index' %> &rsaquo;
7
7
  <%= _("Show") %></h2>
8
8
 
9
9
  <%= typus_block :location => @resource[:self], :partial => 'show' %>
@@ -14,6 +14,7 @@
14
14
  <%= yield :stylesheets -%>
15
15
 
16
16
  <%= javascript_include_tag 'admin/application' %>
17
+ <%= include_tiny_mce_if_needed %>
17
18
  <%= yield :javascripts -%>
18
19
 
19
20
  </head>
@@ -1,3 +1,6 @@
1
+ # Spanish translations for Typus
2
+ # by Felipe Talavera <http://github.com/flype>
3
+
1
4
  es:
2
5
  "Email": "Correo"
3
6
  "Password": "Contraseña"
@@ -87,10 +90,10 @@ es:
87
90
  "Have a nice day": "Que tengas un buen dia."
88
91
  "Reset password": "Cambiar contraseña"
89
92
  "Add new": "Añadir nuevo"
90
- "Do you want to cancel it?": " ¿Quieres cancelarlo? "
93
+ "Do you want to cancel it?": "¿Quieres cancelarlo?"
91
94
  "Click here": "Pulsa aquí"
92
95
  "Are you sure you want to leave this page?": "¿Estas seguro que quieres abandonar esta página?"
93
- "If you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost": "Si has relizado algún cambio en los campos sin pulsar en el botón de Guardar/Actualizar, tus cambios se perderán."
96
+ "If you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost": "Si has relizado algún cambio en los campos sin pulsar en el botón de Guardar/Actualizar, tus cambios se perderán."
94
97
  "Click OK to continue, or click Cancel to stay on this page": "Pulse OK para continuar, o pulse Cancelar para permanecer en esta página."
95
98
  "Remove entry?": "¿Borrar entrada?"
96
99
  "Unrelate {{unrelate_model}} from {{unrelate_model_from}}?": "Unrelate {{unrelate_model}} from {{unrelate_model_from}}?"
@@ -100,4 +103,7 @@ es:
100
103
  "Past 7 days": "Últimos 7 dias"
101
104
  "This month": "Este mes"
102
105
  "This year": "Este año"
103
- "{{model}} filtered by {{filtered_by}}": "{{model}} filtrados por {{filtered_by}}"
106
+ "{{model}} filtered by {{filtered_by}}": "{{model}} filtrados por {{filtered_by}}"
107
+ "True": "Verdadero"
108
+ "False": "Falso"
109
+ "Set language to": "Idioma"
@@ -0,0 +1,113 @@
1
+ ##
2
+ # This is the complete translating yaml reference for Typus.
3
+ ##
4
+
5
+ # <language> translations for Typus
6
+ # by <your_name> <contact_form>
7
+
8
+ <language>:
9
+ "Email":
10
+ "Password":
11
+ "Password confirmation":
12
+ "Sign in":
13
+ "Recover password":
14
+ "Sign up":
15
+ "Enter your email below to create the first user":
16
+ "That doesn't seem like a valid email address":
17
+ "I remember my password":
18
+ "Password recovery link sent to your email":
19
+ "Passwords don't match":
20
+ "A valid token is required":
21
+ "The email and/or password you entered is invalid":
22
+ "There are not defined applications in config/typus/*.yml":
23
+ "Overview":
24
+ "Options":
25
+ "Password confirm":
26
+ "Change password":
27
+ "There are no {{records}}":
28
+ "There are no {{records}} under this filter":
29
+ "Dashboard":
30
+ "Create entry":
31
+ "Update entry":
32
+ "New":
33
+ "Show":
34
+ "Edit":
35
+ "Login":
36
+ "Setup":
37
+ "Create":
38
+ "Sign out":
39
+ "Update":
40
+ "View site":
41
+ "Logged as":
42
+ "Remove filter":
43
+ "Back to list":
44
+ "Actions":
45
+ "Add":
46
+ "&larr; Previous":
47
+ "Next &rarr;":
48
+ "Previous":
49
+ "Next":
50
+ "Search":
51
+ "Search by":
52
+ "{{model}} successfully updated":
53
+ "{{model}} successfully created":
54
+ "{{model}} successfully removed":
55
+ "{{model}} {{attribute}} changed":
56
+ "You're adding a new {{resource_from}} to {{resource_to}}":
57
+ "You're adding a new {{resource_from}}":
58
+ "You're updating a {{resource_from}} for {{resource_to}}":
59
+ "You're updating a {{resource_from}}":
60
+ "Toggle is disabled":
61
+ "Record moved {{to}}":
62
+ "{{model_a}} related to {{model_b}}":
63
+ "{{model_a}} successfully assigned to {{model_b}}":
64
+ "{{model_a}} unrelated from {{model_b}}":
65
+ "{{model_a}} removed from {{model_b}}":
66
+ "Your new password is {{password}}":
67
+ "Add entry":
68
+ "Go to":
69
+ "First name":
70
+ "Last name":
71
+ "Roles":
72
+ "Status":
73
+ "Typus User":
74
+ "System Users Administration":
75
+ "Resources":
76
+ "Up":
77
+ "Down":
78
+ "filter by":
79
+ "Checked if active":
80
+ "As you're not the admin or the owner of this record you cannot edit it":
81
+ "You can't change your role":
82
+ "Error! Typus User or role doesn't exist":
83
+ "You can't toggle your status":
84
+ "You're not allowed to toggle status":
85
+ "You can't remove yourself":
86
+ "You're not allowed to remove Typus Users":
87
+ "{{current_user_role}} can't perform action. ({{action}})":
88
+ "{{current_user_role}} can't go to {{action}} on {{controller}}":
89
+ "{{current_user_role}} can't delete this item":
90
+ "{{current_user_role}} can't perform action ({{action}})":
91
+ "{{current_user_role}} can't display items":
92
+ "You can update your password at":
93
+ "If you didn't request a password update, you can ignore this message":
94
+ "Have a nice day":
95
+ "Reset password":
96
+ "Add new":
97
+ "Do you want to cancel it?":
98
+ "Click here":
99
+ "Are you sure you want to leave this page?":
100
+ "If you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost":
101
+ "Click OK to continue, or click Cancel to stay on this page":
102
+ "Remove entry?":
103
+ "Unrelate {{unrelate_model}} from {{unrelate_model_from}}?":
104
+ "Change {{attribute}}?":
105
+ "Set language":
106
+ "Today":
107
+ "Past 7 days":
108
+ "This month":
109
+ "This year":
110
+ "{{model}} filtered by {{filtered_by}}":
111
+ "True":
112
+ "False":
113
+ "Set language to":
@@ -1,3 +1,6 @@
1
+ # Portuguese (pt-br) translations for Typus
2
+ # by George Guimarães <http://github.com/georgeguimaraes>
3
+
1
4
  pt-BR:
2
5
  "Email": "Email"
3
6
  "Password": "Senha"
@@ -102,4 +105,7 @@ pt-BR:
102
105
  "This year": "Este ano"
103
106
  "Created at": "Criado em"
104
107
  "Updated at": "Atualizado em"
105
- "{{model}} filtered by {{filtered_by}}":
108
+ "{{model}} filtered by {{filtered_by}}":
109
+ "True":
110
+ "False":
111
+ "Set language to":
@@ -1,3 +1,6 @@
1
+ # Russian (ru) translations for Typus
2
+ # by Alexey Noskov <http://github.com/alno>
3
+
1
4
  ru:
2
5
  "Email": "E-Mail"
3
6
  "Password": "Пароль"
@@ -102,4 +105,7 @@ ru:
102
105
  "This year": "Этот год"
103
106
  "Created at": "Создано"
104
107
  "Updated at": "Обновлено"
105
- "{{model}} filtered by {{filtered_by}}":
108
+ "{{model}} filtered by {{filtered_by}}":
109
+ "True":
110
+ "False":
111
+ "Set language to":
@@ -22,8 +22,12 @@ Typus::Configuration.options[:app_name] = '<%= application %>'
22
22
  # Typus::Configuration.options[:index_after_save] = true
23
23
  # Typus::Configuration.options[:minute_step] = 5
24
24
  # Typus::Configuration.options[:nil] = 'nil'
25
+ # Typus::Configuration.options[:on_header] = false
25
26
  # Typus::Configuration.options[:only_user_items] = false
26
27
  # Typus::Configuration.options[:per_page] = 15
27
28
  # Typus::Configuration.options[:sidebar_selector] = 5
28
29
  # Typus::Configuration.options[:start_year] = Time.now.year - 10
30
+ # Typus::Configuration.options[:tiny_mce] = { :theme => 'advanced',
31
+ # :theme_advanced_toolbar_location => 'top',
32
+ # :theme_advanced_toolbar_align => 'left' }
29
33
  # Typus::Configuration.options[:toggle] = true
@@ -9,6 +9,14 @@
9
9
  # show: title, category, is_published?
10
10
  # relationship: title, status
11
11
  # options:
12
+ # tiny_mce:
13
+ # fields: body
14
+ # options:
15
+ # theme: simple
16
+ # theme_advanced_buttons3_add:
17
+ # - fulscreen
18
+ # plugins:
19
+ # - fulscreen
12
20
  # auto_generated:
13
21
  # booleans:
14
22
  # is_published: ["Yes, it is", "No, it isn't"]
@@ -35,6 +43,7 @@
35
43
  # index_after_save: false
36
44
  # minute_step: 15
37
45
  # nil: 'nil'
46
+ # on_header: true
38
47
  # only_user_items: true
39
48
  # per_page: 5
40
49
  # sidebar_selector: 5
@@ -205,12 +205,12 @@ a.on {
205
205
  padding: 0em 1em;
206
206
  }
207
207
 
208
- #content table {
208
+ #content table.typus {
209
209
  margin: 1em 0em;
210
210
  background: #000;
211
211
  }
212
212
 
213
- #content h2+table {
213
+ #content h2+table.typus {
214
214
  margin: 0em; /* Here we overwrite a preference */
215
215
  }
216
216
 
@@ -364,21 +364,21 @@ a.on {
364
364
 
365
365
  /* @group Content Tables */
366
366
 
367
- #content table {
367
+ #content table.typus {
368
368
  width: 100%;
369
369
  }
370
370
 
371
- #content table small {
371
+ #content table.typus small {
372
372
  font-size: 0.8em;
373
373
  }
374
374
 
375
- #content table th {
375
+ #content table.typus th {
376
376
  color: #FFF;
377
377
  font-weight: normal;
378
378
  padding: 4px;
379
379
  }
380
380
 
381
- #content table th a {
381
+ #content table.typus th a {
382
382
  color: #FFF!important;
383
383
  }
384
384
 
@@ -386,30 +386,30 @@ a.on {
386
386
 
387
387
  #content .desc { background: transparent url(/images/admin/arrow_down.gif) no-repeat right center; }
388
388
 
389
- #content table td.right {
389
+ #content table.typus td.right {
390
390
  text-align: right;
391
391
  }
392
392
 
393
- #content table tr.even {
393
+ #content table.typus tr.even {
394
394
  background: #FFF!important;
395
395
  }
396
396
 
397
- #content table tr.even:hover,
398
- #content table tr.odd:hover {
397
+ #content table.typus tr.even:hover,
398
+ #content table.typus tr.odd:hover {
399
399
  background: #000!important;
400
400
  color: #FFF;
401
401
  }
402
402
 
403
- #content table tr.even:hover a,
404
- #content table tr.odd:hover a {
403
+ #content table.typus tr.even:hover a,
404
+ #content table.typus tr.odd:hover a {
405
405
  color: #FFF!important;
406
406
  }
407
407
 
408
- #content table tr.odd {
408
+ #content table.typus tr.odd {
409
409
  background: #F5F5F5;
410
410
  }
411
411
 
412
- #content table td {
412
+ #content table.typus td {
413
413
  border: none;
414
414
  font-weight: normal;
415
415
  padding: 3px 4px;
@@ -22,7 +22,7 @@ class TypusGenerator < Rails::Generator::Base
22
22
  class_name = model.sub(/\.rb$/,'').classify
23
23
  begin
24
24
  klass = class_name.constantize
25
- active_record_model = klass.superclass.equal?(ActiveRecord::Base)
25
+ active_record_model = klass.superclass.equal?(ActiveRecord::Base) && !klass.abstract_class?
26
26
  active_record_model_with_sti = klass.superclass.superclass.equal?(ActiveRecord::Base)
27
27
  ar_models << klass if active_record_model || active_record_model_with_sti
28
28
  rescue Exception => error
@@ -40,32 +40,37 @@ class TypusGenerator < Rails::Generator::Base
40
40
 
41
41
  configuration = { :base => '', :roles => '' }
42
42
 
43
- ar_models.each do |model|
43
+ ar_models.sort{ |x,y| x.class_name <=> y.class_name }.each do |model|
44
44
 
45
- # By default we don't want to show in our lists text fields and created_at
46
- # and updated_at attributes.
47
- list = model.columns.reject { |c| c.sql_type == 'text' || %w( created_at updated_at ).include?(c.name) }.map(&:name)
45
+ # Detect all relationships except polymorphic belongs_to using reflection.
46
+ relationships = [ :belongs_to, :has_and_belongs_to_many, :has_many, :has_one ].map do |relationship|
47
+ model.reflect_on_all_associations(relationship).reject { |i| i.options[:polymorphic] }.map { |i| i.name.to_s }
48
+ end.flatten.sort
48
49
 
49
- # By default we don't want to show in our forms created_at and updated_at
50
- # attributes.
51
- form = model.columns.reject { |c| %w( id created_at updated_at ).include?(c.name) }.map(&:name)
50
+ # Remove foreign key and polymorphic type attributes
51
+ reject_columns = []
52
+ model.reflect_on_all_associations(:belongs_to).each do |i|
53
+ reject_columns << model.columns_hash[i.name.to_s + '_id']
54
+ reject_columns << model.columns_hash[i.name.to_s + '_type'] if i.options[:polymorphic]
55
+ end
52
56
 
53
- # By default we want to show all model columns in the show action.
54
- show = model.columns.map(&:name)
57
+ model_columns = model.columns - reject_columns
55
58
 
56
- # Detect relationships using reflection and remove the _id part from
57
- # attributes when relationships is defined in ActiveRecord.
58
- list.each do |i|
59
- if i.include?('_id')
60
- assoc_name = model.reflect_on_association(i.gsub(/_id/, '').to_sym).macro rescue nil
61
- i.gsub!(/_id/, '') if assoc_name == :belongs_to
62
- end
63
- end
59
+ # Don't show `text` fields and timestamps in lists.
60
+ list = model_columns.reject { |c| c.sql_type == 'text' || %w( created_at updated_at ).include?(c.name) }.map(&:name)
64
61
 
65
- # Detect relationships using reflection.
66
- relationships = [ :belongs_to, :has_and_belongs_to_many, :has_many, :has_one ].map do |relationship|
67
- model.reflect_on_all_associations(relationship).map { |i| i.name.to_s }
68
- end.flatten.sort
62
+ # Don't show timestamps in forms.
63
+ form = model_columns.reject { |c| %w( id created_at updated_at ).include?(c.name) }.map(&:name)
64
+
65
+ # Show all model columns in the show action.
66
+ show = model_columns.map(&:name)
67
+
68
+ # We want attributes of belongs_to relationships to be shown in our
69
+ # field collections if those are not polymorphic.
70
+ [ list, form, show ].each do |fields|
71
+ fields << model.reflect_on_all_associations(:belongs_to).reject { |i| i.options[:polymorphic] }.map { |i| i.name.to_s }
72
+ fields.flatten!
73
+ end
69
74
 
70
75
  configuration[:base] << <<-RAW
71
76
  #{model}:
@@ -75,6 +80,9 @@ class TypusGenerator < Rails::Generator::Base
75
80
  show: #{show.join(', ')}
76
81
  relationship:
77
82
  options:
83
+ tiny_mce:
84
+ fields:
85
+ options:
78
86
  auto_generated:
79
87
  read_only:
80
88
  selectors:
@@ -21,6 +21,20 @@ module Typus
21
21
  return hash
22
22
  end
23
23
 
24
+ ##
25
+ # This method is used to change a Rails behavior.
26
+ #
27
+ # typus $ script/console
28
+ # Loading development environment (Rails 2.3.2)
29
+ # >> TypusUser.human_name
30
+ # => "Typususer"
31
+ # >> TypusUser.typus_human_name
32
+ # => "Typus user"
33
+ #
34
+ def typus_human_name
35
+ human_name(:default => self.name.underscore.humanize)
36
+ end
37
+
24
38
  ##
25
39
  # Form and list fields
26
40
  #
@@ -59,6 +73,10 @@ module Typus
59
73
  attribute_type = :selector
60
74
  end
61
75
 
76
+ if typus_tiny_mce_fields.include?(field.to_s)
77
+ attribute_type = :tiny_mce
78
+ end
79
+
62
80
  # And finally insert the field and the attribute_type
63
81
  # into the fields_with_type ordered hash.
64
82
  fields_with_type[field.to_s] = attribute_type
@@ -74,6 +92,24 @@ module Typus
74
92
 
75
93
  end
76
94
 
95
+ ##
96
+ # Return tiny_mce options of the model merged into the default options
97
+ #
98
+ def typus_tiny_mce_options
99
+ typus_options_for(:tiny_mce).merge(Typus::Configuration.config[name]['fields']['options']['tiny_mce']['options'].symbolize_keys.delete_if { |key,value| value == nil})
100
+ rescue
101
+ typus_options_for(:tiny_mce)
102
+ end
103
+
104
+ ##
105
+ # Tiny_mce fields of the model
106
+ #
107
+ def typus_tiny_mce_fields
108
+ Typus::Configuration.config[name]['fields']['options']['tiny_mce']['fields'].split(', ')
109
+ rescue
110
+ []
111
+ end
112
+
77
113
  ##
78
114
  # Typus sidebar filters.
79
115
  #
@@ -234,10 +270,10 @@ module Typus
234
270
  conditions = merge_conditions(conditions, condition)
235
271
  when :datetime
236
272
  interval = case value
237
- when 'today': Time.today..Time.today.tomorrow
238
- when 'past_7_days': 6.days.ago.midnight..Time.today.tomorrow
239
- when 'this_month': Time.today.last_month..Time.today.tomorrow
240
- when 'this_year': Time.today.last_year..Time.today.tomorrow
273
+ when 'today': Time.new.midnight..Time.new.midnight.tomorrow
274
+ when 'past_7_days': 6.days.ago.midnight..Time.new.midnight.tomorrow
275
+ when 'this_month': Time.new.midnight.last_month..Time.new.midnight.tomorrow
276
+ when 'this_year': Time.new.midnight.last_year..Time.new.midnight.tomorrow
241
277
  end
242
278
  condition = ["#{key} BETWEEN ? AND ?", interval.first.to_s(:db), interval.last.to_s(:db)]
243
279
  conditions = merge_conditions(conditions, condition)
@@ -262,8 +298,8 @@ module Typus
262
298
 
263
299
  def previous_and_next(condition = {}, klass = self.class)
264
300
 
265
- previous_conditions = "id < #{id}"
266
- next_conditions = "id > #{id}"
301
+ previous_conditions = "#{klass.primary_key} < #{id}"
302
+ next_conditions = "#{klass.primary_key} > #{id}"
267
303
 
268
304
  if !condition.empty?
269
305
  conditions, joins = klass.build_conditions(condition)
@@ -272,13 +308,13 @@ module Typus
272
308
  end
273
309
 
274
310
  previous_ = klass.find :first,
275
- :select => [:id],
276
- :order => "id DESC",
311
+ :select => [klass.primary_key],
312
+ :order => "#{klass.primary_key} DESC",
277
313
  :conditions => previous_conditions
278
314
 
279
315
  next_ = klass.find :first,
280
- :select => [:id],
281
- :order => "id ASC",
316
+ :select => [klass.primary_key],
317
+ :order => "#{klass.primary_key} ASC",
282
318
  :conditions => next_conditions
283
319
 
284
320
  return previous_, next_
@@ -40,10 +40,14 @@ module Typus
40
40
  :index_after_save => false,
41
41
  :minute_step => 5,
42
42
  :nil => 'nil',
43
+ :on_header => false,
43
44
  :only_user_items => false,
44
45
  :per_page => 15,
45
46
  :sidebar_selector => 5,
46
47
  :start_year => nil,
48
+ :tiny_mce => { :theme => 'advanced',
49
+ :theme_advanced_toolbar_location => 'top',
50
+ :theme_advanced_toolbar_align => 'left' },
47
51
  :toggle => true }
48
52
 
49
53
  @@options = typus_options.merge(model_options)
data/lib/typus.rb CHANGED
@@ -33,6 +33,10 @@ module Typus
33
33
  Typus::Configuration.config.map { |i| i.first }.sort
34
34
  end
35
35
 
36
+ def models_on_header
37
+ models.collect { |m| m if m.constantize.typus_options_for(:on_header) }.compact
38
+ end
39
+
36
40
  ##
37
41
  # Return a list of resources, which are models tableless.
38
42
  #
@@ -8,6 +8,18 @@ namespace :typus do
8
8
  system "script/plugin install #{plugins.join(' ')} --force"
9
9
  end
10
10
 
11
+ desc 'Install ssl_requirement.'
12
+ task :ssl do
13
+ system "script/plugin install git://github.com/rails/ssl_requirement.git --force"
14
+ end
15
+
16
+ desc 'Install tiny_mce.'
17
+ task :tiny_mce do
18
+ system "script/plugin install git://github.com/kete/tiny_mce.git --force"
19
+ load File.join Rails.root, 'vendor', 'plugins', 'tiny_mce', 'tasks', 'tiny_mce.rake'
20
+ Rake::Task["tiny_mce:install"].invoke
21
+ end
22
+
11
23
  desc 'List current roles.'
12
24
  task :roles => :environment do
13
25
  Typus::Configuration.roles.each do |role|
@@ -17,10 +29,4 @@ namespace :typus do
17
29
  puts "\n"
18
30
  end
19
31
 
20
- desc 'Install ssl_requirement.'
21
- task :ssl do
22
- plugins = [ 'git://github.com/rails/ssl_requirement.git' ]
23
- system "script/plugin install #{plugins.join(' ')} --force"
24
- end
25
-
26
- end
32
+ end
@@ -37,6 +37,7 @@ Page:
37
37
  filters: is_published?
38
38
  options:
39
39
  form_rows: 25
40
+ on_header: true
40
41
 
41
42
  Post:
42
43
  fields:
@@ -36,13 +36,15 @@ class TypusHelperTest < ActiveSupport::TestCase
36
36
  # ActionView::Helpers::UrlHelper does not support strings, which are returned by named routes
37
37
  # link root_path
38
38
  self.stubs(:link_to).returns(%(<a href="/">View site</a>))
39
+ self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
39
40
 
40
41
  output = header
41
42
  expected = <<-HTML
42
43
  <h1>#{Typus::Configuration.options[:app_name]}</h1>
43
44
  <ul>
44
- <li><a href="/">View site</a></li>
45
- <li><a href="/">View site</a></li>
45
+ <li><a href="/admin/dashboard">Dashboard</a></li>
46
+ <li><a href="/admin/dashboard">Dashboard</a></li>
47
+ <li><a href="/">View site</a></li>
46
48
  </ul>
47
49
  HTML
48
50
 
@@ -55,14 +57,14 @@ class TypusHelperTest < ActiveSupport::TestCase
55
57
  # Remove root route from list
56
58
  ActionController::Routing::Routes.named_routes.routes.reject! {|key, route| key == :root }
57
59
 
58
- self.stubs(:link_to).returns(%(<a href="/admin/dashboard">Dashboard</a>))
60
+ self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
59
61
 
60
62
  output = header
61
63
  expected = <<-HTML
62
64
  <h1>#{Typus::Configuration.options[:app_name]}</h1>
63
65
  <ul>
64
- <li><a href="/admin/dashboard">Dashboard</a></li>
65
-
66
+ <li><a href="/admin/dashboard">Dashboard</a></li>
67
+ <li><a href="/admin/dashboard">Dashboard</a></li>
66
68
  </ul>
67
69
  HTML
68
70
 
@@ -166,6 +166,11 @@ class ActiveRecordTest < ActiveSupport::TestCase
166
166
  assert_equal 10, TypusUser.typus_options_for(:form_rows)
167
167
  assert_equal 10, TypusUser.typus_options_for('form_rows')
168
168
 
169
+ assert Page.typus_options_for(:on_header)
170
+ assert !TypusUser.typus_options_for(:on_header)
171
+
172
+ assert_nil TypusUser.typus_options_for(:unexisting)
173
+
169
174
  end
170
175
 
171
176
  def test_should_verify_typus_boolean_is_an_instance_of_active_support_ordered_hash
@@ -268,9 +273,9 @@ class ActiveRecordTest < ActiveSupport::TestCase
268
273
 
269
274
  expected = case ENV['DB']
270
275
  when /postgresql/
271
- "(created_at BETWEEN E'#{Time.today.to_s(:db)}' AND E'#{Time.today.tomorrow.to_s(:db)}')"
276
+ "(created_at BETWEEN E'#{Time.new.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
272
277
  else
273
- "(created_at BETWEEN '#{Time.today.to_s(:db)}' AND '#{Time.today.tomorrow.to_s(:db)}')"
278
+ "(created_at BETWEEN '#{Time.new.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
274
279
  end
275
280
  params = { :created_at => 'today' }
276
281
  assert_equal expected, TypusUser.build_conditions(params).first
@@ -278,9 +283,9 @@ class ActiveRecordTest < ActiveSupport::TestCase
278
283
 
279
284
  expected = case ENV['DB']
280
285
  when /postgresql/
281
- "(created_at BETWEEN E'#{6.days.ago.midnight.to_s(:db)}' AND E'#{Time.today.tomorrow.to_s(:db)}')"
286
+ "(created_at BETWEEN E'#{6.days.ago.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
282
287
  else
283
- "(created_at BETWEEN '#{6.days.ago.midnight.to_s(:db)}' AND '#{Time.today.tomorrow.to_s(:db)}')"
288
+ "(created_at BETWEEN '#{6.days.ago.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
284
289
  end
285
290
  params = { :created_at => 'past_7_days' }
286
291
  assert_equal expected, TypusUser.build_conditions(params).first
@@ -288,18 +293,18 @@ class ActiveRecordTest < ActiveSupport::TestCase
288
293
 
289
294
  expected = case ENV['DB']
290
295
  when /postgresql/
291
- "(created_at BETWEEN E'#{Time.today.last_month.to_s(:db)}' AND E'#{Time.today.tomorrow.to_s(:db)}')"
296
+ "(created_at BETWEEN E'#{Time.new.midnight.last_month.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
292
297
  else
293
- "(created_at BETWEEN '#{Time.today.last_month.to_s(:db)}' AND '#{Time.today.tomorrow.to_s(:db)}')"
298
+ "(created_at BETWEEN '#{Time.new.midnight.last_month.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
294
299
  end
295
300
  params = { :created_at => 'this_month' }
296
301
  assert_equal expected, TypusUser.build_conditions(params).first
297
302
 
298
303
  expected = case ENV['DB']
299
304
  when /postgresql/
300
- "(created_at BETWEEN E'#{Time.today.last_year.to_s(:db)}' AND E'#{Time.today.tomorrow.to_s(:db)}')"
305
+ "(created_at BETWEEN E'#{Time.new.midnight.last_year.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
301
306
  else
302
- "(created_at BETWEEN '#{Time.today.last_year.to_s(:db)}' AND '#{Time.today.tomorrow.to_s(:db)}')"
307
+ "(created_at BETWEEN '#{Time.new.midnight.last_year.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
303
308
  end
304
309
  params = { :created_at => 'this_year' }
305
310
  assert_equal expected, TypusUser.build_conditions(params).first
@@ -309,9 +314,9 @@ class ActiveRecordTest < ActiveSupport::TestCase
309
314
  def test_should_return_sql_conditions_on_filtering_posts_by_published_at
310
315
  expected = case ENV['DB']
311
316
  when /postgresql/
312
- "(published_at BETWEEN E'#{Time.today.to_s(:db)}' AND E'#{Time.today.tomorrow.to_s(:db)}')"
317
+ "(published_at BETWEEN E'#{Time.new.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
313
318
  else
314
- "(published_at BETWEEN '#{Time.today.to_s(:db)}' AND '#{Time.today.tomorrow.to_s(:db)}')"
319
+ "(published_at BETWEEN '#{Time.new.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
315
320
  end
316
321
  params = { :published_at => 'today' }
317
322
  assert_equal expected, Post.build_conditions(params).first
@@ -364,8 +369,8 @@ class ActiveRecordTest < ActiveSupport::TestCase
364
369
  assert_equal 'datepicker', Post.typus_template('published_at')
365
370
  assert_equal 'datepicker', Post.typus_template(:published_at)
366
371
 
367
- assert_equal nil, Post.typus_template('created_at')
368
- assert_equal nil, Post.typus_template('unknown')
372
+ assert_nil Post.typus_template('created_at')
373
+ assert_nil Post.typus_template('unknown')
369
374
 
370
375
  end
371
376
 
@@ -25,16 +25,17 @@ class ConfigurationTest < ActiveSupport::TestCase
25
25
  initializer = "#{Rails.root}/config/initializers/typus.rb"
26
26
  return if File.exist?(initializer)
27
27
  assert_equal 'edit', Typus::Configuration.options[:default_action_on_item]
28
- assert_equal nil, Typus::Configuration.options[:end_year]
28
+ assert_nil Typus::Configuration.options[:end_year]
29
29
  assert_equal 10, Typus::Configuration.options[:form_rows]
30
30
  assert_equal true, Typus::Configuration.options[:icon_on_boolean]
31
31
  assert_equal false, Typus::Configuration.options[:index_after_save]
32
32
  assert_equal 5, Typus::Configuration.options[:minute_step]
33
33
  assert_equal 'nil', Typus::Configuration.options[:nil]
34
+ assert_equal false, Typus::Configuration.options[:on_header]
34
35
  assert_equal false, Typus::Configuration.options[:only_user_items]
35
36
  assert_equal 15, Typus::Configuration.options[:per_page]
36
37
  assert_equal 5, Typus::Configuration.options[:sidebar_selector]
37
- assert_equal nil, Typus::Configuration.options[:start_year]
38
+ assert_nil Typus::Configuration.options[:start_year]
38
39
  assert_equal true, Typus::Configuration.options[:toggle]
39
40
  end
40
41
 
@@ -43,6 +43,11 @@ class TypusTest < ActiveSupport::TestCase
43
43
  assert_equal %w( Asset Category Comment CustomUser Page Post TypusUser ), Typus.models
44
44
  end
45
45
 
46
+ def test_should_return_an_array_of_models_on_header
47
+ assert Typus.models_on_header.kind_of?(Array)
48
+ assert_equal ["Page"], Typus.models_on_header
49
+ end
50
+
46
51
  def test_should_verify_resources_class_method
47
52
  assert Typus.respond_to?(:resources)
48
53
  models = Typus.models
data/typus.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{typus}
5
- s.version = "0.9.9"
5
+ s.version = "0.9.10"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Francesc Esplugas"]
9
- s.date = %q{2009-06-13}
9
+ s.date = %q{2009-06-30}
10
10
  s.description = %q{Effortless backend interface for Ruby on Rails applications. (Admin scaffold generator.)}
11
11
  s.email = %q{francesc@intraducibles.com}
12
12
  s.extra_rdoc_files = [
@@ -43,10 +43,10 @@ Gem::Specification.new do |s|
43
43
  "app/views/typus/sign_in.html.erb",
44
44
  "app/views/typus/sign_up.html.erb",
45
45
  "app/views/typus_mailer/reset_password_link.erb",
46
- "config/locales/es.yml",
47
- "config/locales/pt-BR.yml",
48
- "config/locales/ru.yml",
49
- "config/locales/typus_hacks.yml",
46
+ "config/locales/typus/es.yml",
47
+ "config/locales/typus/language.yml.template",
48
+ "config/locales/typus/pt-BR.yml",
49
+ "config/locales/typus/ru.yml",
50
50
  "config/routes.rb",
51
51
  "generators/typus/templates/config/initializers/typus.rb",
52
52
  "generators/typus/templates/config/typus/application.yml",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fesplugas-typus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesc Esplugas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-13 00:00:00 -07:00
12
+ date: 2009-06-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -52,10 +52,10 @@ files:
52
52
  - app/views/typus/sign_in.html.erb
53
53
  - app/views/typus/sign_up.html.erb
54
54
  - app/views/typus_mailer/reset_password_link.erb
55
- - config/locales/es.yml
56
- - config/locales/pt-BR.yml
57
- - config/locales/ru.yml
58
- - config/locales/typus_hacks.yml
55
+ - config/locales/typus/es.yml
56
+ - config/locales/typus/language.yml.template
57
+ - config/locales/typus/pt-BR.yml
58
+ - config/locales/typus/ru.yml
59
59
  - config/routes.rb
60
60
  - generators/typus/templates/config/initializers/typus.rb
61
61
  - generators/typus/templates/config/typus/application.yml
@@ -1,19 +0,0 @@
1
- en:
2
- activerecord:
3
- models:
4
- typus_user: "Typus user"
5
-
6
- es:
7
- activerecord:
8
- models:
9
- typus_user: "Typus user"
10
-
11
- pt-BR:
12
- activerecord:
13
- models:
14
- typus_user: "Typus user"
15
-
16
- ru:
17
- activerecord:
18
- models:
19
- typus_user: "Typus user"