typus 0.9.27 → 0.9.28

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 (42) hide show
  1. data/README.rdoc +1 -1
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/app/controllers/admin/master_controller.rb +31 -9
  5. data/app/controllers/typus_controller.rb +6 -2
  6. data/app/helpers/admin/form_helper.rb +10 -3
  7. data/app/helpers/admin/sidebar_helper.rb +30 -14
  8. data/app/helpers/admin/table_helper.rb +38 -27
  9. data/app/views/admin/dashboard/_sidebar.html.erb +1 -1
  10. data/app/views/admin/resources/show.html.erb +18 -3
  11. data/app/views/admin/shared/_pagination.html.erb +4 -4
  12. data/config/locales/de.yml +1 -4
  13. data/config/locales/es.yml +1 -4
  14. data/config/locales/fr.yml +99 -0
  15. data/config/locales/language.yml.template +81 -88
  16. data/config/locales/pt-BR.yml +17 -23
  17. data/config/locales/ru.yml +1 -6
  18. data/generators/typus/templates/config/initializers/typus.rb +2 -1
  19. data/generators/typus/templates/public/stylesheets/admin/screen.css +6 -3
  20. data/lib/typus/active_record.rb +6 -8
  21. data/lib/typus/authentication.rb +5 -8
  22. data/lib/typus/configuration.rb +2 -1
  23. data/lib/typus/user.rb +22 -22
  24. data/lib/typus.rb +13 -1
  25. data/lib/vendor/rss_parser.rb +20 -0
  26. data/test/functional/admin/assets_controller_test.rb +3 -4
  27. data/test/functional/admin/categories_controller_test.rb +1 -2
  28. data/test/functional/admin/comments_controller_test.rb +3 -2
  29. data/test/functional/admin/master_controller_test.rb +46 -0
  30. data/test/functional/admin/posts_controller_test.rb +41 -2
  31. data/test/functional/admin/status_controller_test.rb +1 -2
  32. data/test/functional/admin/typus_users_controller_test.rb +1 -2
  33. data/test/functional/typus_controller_test.rb +12 -9
  34. data/test/helpers/admin/sidebar_helper_test.rb +25 -1
  35. data/test/helpers/admin/table_helper_test.rb +30 -1
  36. data/test/lib/active_record_test.rb +5 -0
  37. data/test/lib/configuration_test.rb +2 -1
  38. data/test/lib/typus_test.rb +10 -0
  39. data/test/unit/typus_user_test.rb +2 -2
  40. data/test/vendor/paginator_test.rb +2 -0
  41. data/typus.gemspec +4 -2
  42. metadata +4 -2
@@ -1,110 +1,103 @@
1
- ##
2
- # This is the complete translating yaml reference for Typus.
3
- ##
4
-
5
- # <language> translations for Typus
1
+ # <language> translations for Typus (template)
6
2
  # by <your_name> <contact_form>
7
3
 
8
4
  <language>:
5
+ "A valid token is required":
6
+ "Actions":
7
+ "Add":
8
+ "Add entry":
9
+ "Add new":
10
+ "Are you sure you want to leave this page?":
11
+ "Are you sure you want to sign out and end your session?":
12
+ "As you're not the admin or the owner of this record you cannot edit it":
13
+ "Back to list":
14
+ "Change {{attribute}}?":
15
+ "Change password":
16
+ "Checked if active":
17
+ "Click here":
18
+ "Click OK to continue, or click Cancel to stay on this page":
19
+ "Create":
20
+ "Create entry":
21
+ "Dashboard":
22
+ "Do you want to cancel it?":
23
+ "Down":
24
+ "Edit":
9
25
  "Email":
26
+ "Enter your email below to create the first user":
27
+ "Error! Typus User or role doesn't exist":
28
+ "False":
29
+ "Filter by":
30
+ "First name":
31
+ "Go to":
32
+ "I remember my password":
33
+ "If you didn't request a password update, you can ignore this message":
34
+ "If you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost":
35
+ "Last 7 days":
36
+ "Last 30 days":
37
+ "Last name":
38
+ "Last few days":
39
+ "Logged as":
40
+ "Login":
41
+ "New":
42
+ "Next":
43
+ "Options":
44
+ "Overview":
10
45
  "Password":
46
+ "Password confirm":
11
47
  "Password confirmation":
12
- "Sign in":
48
+ "Password recovery link sent to your email":
49
+ "Previous":
50
+ "Record moved {{to}}":
13
51
  "Recover password":
52
+ "Remove entry?":
53
+ "Remove filter":
54
+ "Reset password":
55
+ "Resources":
56
+ "Roles":
57
+ "Search":
58
+ "Search by":
59
+ "Setup":
60
+ "Show":
61
+ "Sign in":
62
+ "Sign out":
14
63
  "Sign up":
15
- "Enter your email below to create the first user":
64
+ "Status":
65
+ "System Users Administration":
16
66
  "That doesn't seem like a valid email address":
17
- "I remember my password":
18
- "Password recovery link sent to your email":
19
- "A valid token is required":
20
67
  "The email and/or password you entered is invalid":
21
- "There are not defined applications in config/typus/*.yml":
22
- "Overview":
23
- "Options":
24
- "Password confirm":
25
- "Change password":
26
68
  "There are no {{records}}":
27
69
  "There are no {{records}} under this filter":
28
- "Dashboard":
29
- "Create entry":
30
- "Update entry":
31
- "New":
32
- "Show":
33
- "Edit":
34
- "Login":
35
- "Setup":
36
- "Create":
37
- "Sign out":
70
+ "There are not defined applications in config/typus/*.yml":
71
+ "Today":
72
+ "Toggle is disabled":
73
+ "True":
74
+ "Typus User":
75
+ "Unrelate {{unrelate_model}} from {{unrelate_model_from}}?":
76
+ "Up":
38
77
  "Update":
78
+ "Update entry":
39
79
  "View site":
40
- "Logged as":
41
- "Remove filter":
42
- "Back to list":
43
- "Actions":
44
- "Add":
45
- "&larr; Previous":
46
- "Next &rarr;":
47
- "Previous":
48
- "Next":
49
- "Search":
50
- "Search by":
51
- "{{model}} successfully updated":
52
- "{{model}} successfully created":
53
- "{{model}} successfully removed":
54
- "{{model}} {{attribute}} changed":
55
80
  "You're adding a new {{resource_from}} to {{resource_to}}":
56
81
  "You're adding a new {{resource_from}}":
82
+ "You're not allowed to toggle status":
83
+ "You're not allowed to remove Typus Users":
84
+ "You can update your password at":
85
+ "You can't change your role":
86
+ "You can't remove yourself":
87
+ "You can't toggle your status":
57
88
  "You're updating a {{resource_from}} for {{resource_to}}":
58
89
  "You're updating a {{resource_from}}":
59
- "Toggle is disabled":
60
- "Record moved {{to}}":
61
- "{{model_a}} related to {{model_b}}":
62
- "{{model_a}} successfully assigned to {{model_b}}":
63
- "{{model_a}} unrelated from {{model_b}}":
64
- "{{model_a}} removed from {{model_b}}":
65
90
  "Your new password is {{password}}":
66
- "Add entry":
67
- "Go to":
68
- "First name":
69
- "Last name":
70
- "Roles":
71
- "Status":
72
- "Typus User":
73
- "System Users Administration":
74
- "Resources":
75
- "Up":
76
- "Down":
77
- "filter by":
78
- "Checked if active":
79
- "As you're not the admin or the owner of this record you cannot edit it":
80
- "You can't change your role":
81
- "Error! Typus User or role doesn't exist":
82
- "You can't toggle your status":
83
- "You're not allowed to toggle status":
84
- "You can't remove yourself":
85
- "You're not allowed to remove Typus Users":
86
- "{{current_user_role}} can't perform action. ({{action}})":
87
- "{{current_user_role}} can't go to {{action}} on {{controller}}":
88
91
  "{{current_user_role}} can't delete this item":
89
- "{{current_user_role}} can't perform action ({{action}})":
90
92
  "{{current_user_role}} can't display items":
91
- "You can update your password at":
92
- "If you didn't request a password update, you can ignore this message":
93
- "Reset password":
94
- "Add new":
95
- "Do you want to cancel it?":
96
- "Click here":
97
- "Are you sure you want to leave this page?":
98
- "If you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost":
99
- "Click OK to continue, or click Cancel to stay on this page":
100
- "Remove entry?":
101
- "Unrelate {{unrelate_model}} from {{unrelate_model_from}}?":
102
- "Change {{attribute}}?":
103
- "Today":
104
- "Last few days":
105
- "Last 7 days":
106
- "Last 30 days":
93
+ "{{current_user_role}} can't go to {{action}} on {{controller}}":
94
+ "{{current_user_role}} can't perform action. ({{action}})":
107
95
  "{{model}} filtered by {{filtered_by}}":
108
- "True":
109
- "False":
110
- "Are you sure you want to sign out and end your session?":
96
+ "{{model}} successfully created":
97
+ "{{model}} successfully removed":
98
+ "{{model}} successfully updated":
99
+ "{{model}} {{attribute}} changed":
100
+ "{{model_a}} related to {{model_b}}":
101
+ "{{model_a}} removed from {{model_b}}":
102
+ "{{model_a}} successfully assigned to {{model_b}}":
103
+ "{{model_a}} unrelated from {{model_b}}":
@@ -2,32 +2,31 @@
2
2
  # by George Guimarães <http://github.com/georgeguimaraes>
3
3
 
4
4
  pt-BR:
5
+ "A valid token is required": "É necessário um token válido."
6
+ "Create entry": "Criar entrada"
7
+ "Change password": "Trocar senha"
8
+ "Dashboard": "Painel"
9
+ "Edit": "Editar"
5
10
  "Email": "Email"
11
+ "Enter your email below to create the first user": "Escreva seu email para criar o primeiro usuário"
12
+ "I remember my password": "Lembro minha senha"
13
+ "Login": "Login"
14
+ "New": "Novo"
15
+ "Options": "Opções"
16
+ "Overview": "Visão geral"
6
17
  "Password": "Senha"
7
18
  "Password confirmation": "Senha confirmação"
8
- "Sign in": "Entrar"
19
+ "Password recovery link sent to your email": "Link para recuperar senha enviado para seu email."
9
20
  "Recover password": "Recuperar senha"
21
+ "Show": "Mostrar"
22
+ "Sign in": "Entrar"
10
23
  "Sign up": "Criar conta"
11
- "Enter your email below to create the first user": "Escreva seu email para criar o primeiro usuário"
12
24
  "That doesn't seem like a valid email address": "Este não parece um email válido"
13
- "I remember my password": "Lembro minha senha"
14
- "Password recovery link sent to your email": "Link para recuperar senha enviado para seu email."
15
- "A valid token is required": "É necessário um token válido."
16
25
  "The email and/or password you entered is invalid": "O email e/ou a senha que você colocou são inválidos."
17
- "There are not defined applications in config/typus/*.yml": "Não há aplicativos definidos em config/typus/*.yml"
18
- "Overview": "Visão geral"
19
- "Options": "Opções"
20
- "Password confirmation": "Confirmação de senha"
21
- "Change password": "Trocar senha"
22
26
  "There are no {{records}}": "Não há {{records}}."
23
27
  "There are no {{records}} under this filter": "Não há {{records}} com este filtro."
24
- "Dashboard": "Painel"
25
- "Create entry": "Criar entrada"
28
+ "There are not defined applications in config/typus/*.yml": "Não há aplicativos definidos em config/typus/*.yml"
26
29
  "Update entry": "Atualizar entrada"
27
- "New": "Novo"
28
- "Show": "Mostrar"
29
- "Edit": "Editar"
30
- "Login": "Login"
31
30
  "Setup": "Configurar"
32
31
  "Create": "Criar"
33
32
  "Sign out": "Sair"
@@ -38,8 +37,6 @@ pt-BR:
38
37
  "Back to list": "Voltar à lista"
39
38
  "Actions": "Ações"
40
39
  "Add": "Adicionar"
41
- "&larr; Previous": "&larr; Anterior"
42
- "Next &rarr;": "Próximo &rarr;"
43
40
  "Previous": "Anterior"
44
41
  "Next": "Próximo"
45
42
  "Search": "Busca"
@@ -70,7 +67,7 @@ pt-BR:
70
67
  "Resources": "Recursos"
71
68
  "Up": "Subir"
72
69
  "Down": "Descer"
73
- "filter by": "filtrar por"
70
+ "Filter by": "filtrar por"
74
71
  "Checked if active": "Marcar para ativar"
75
72
  "As you're not the admin or the owner of this record you cannot edit it": "Como você não é o dono desse registro ou o admin, você não pode editá-lo."
76
73
  "You can't change your role": "Você não pode mudar sua própria função no sistema."
@@ -82,7 +79,6 @@ pt-BR:
82
79
  "{{current_user_role}} can't perform action. ({{action}})": "{{current_user_role}} não pode realizar a ação. ({{action}})"
83
80
  "{{current_user_role}} can't go to {{action}} on {{controller}}": "{{current_user_role}} não pode ir a {{action}} no {{controller}}."
84
81
  "{{current_user_role}} can't delete this item": "{{current_user_role}} não pode apagar este item."
85
- "{{current_user_role}} can't perform action ({{action}})": "{{current_user_role}} não pode realizar a ação ({{action}})"
86
82
  "{{current_user_role}} can't display items": "{{current_user_role}} não pode mostrar os items."
87
83
  "You can update your password at": "Você pode atualizar sua senha em"
88
84
  "If you didn't request a password update, you can ignore this message": "Se você não pediu uma renovação de senha, por favor ignore esta mensagem."
@@ -100,9 +96,7 @@ pt-BR:
100
96
  "Last few days": "Últimos dias"
101
97
  "Last 7 days": "Últimos 7 dias"
102
98
  "Last 30 days": "Últimos 30 dias"
103
- "Created at": "Criado em"
104
- "Updated at": "Atualizado em"
105
99
  "{{model}} filtered by {{filtered_by}}": "{{model}} filtrados por {{filtered_by}}"
106
100
  "True": "Verdadeiro"
107
101
  "False": "Falso"
108
- "Are you sure you want to sign out and end your session?": "Tem certeza que quer sair e encerrar sua sessão?"
102
+ "Are you sure you want to sign out and end your session?": "Tem certeza que quer sair e encerrar sua sessão?"
@@ -38,8 +38,6 @@ ru:
38
38
  "Back to list": "Назад к списку"
39
39
  "Actions": "Действия"
40
40
  "Add": "Добавить"
41
- "&larr; Previous": "&larr; Предыдущая"
42
- "Next &rarr;": "Следующая &rarr;"
43
41
  "Previous": "Предыдующий"
44
42
  "Next": "Следующий"
45
43
  "Search": "Поиск"
@@ -70,7 +68,7 @@ ru:
70
68
  "Resources": "Ресурсы"
71
69
  "Up": "Вверх"
72
70
  "Down": "Вниз"
73
- "filter by": "фильтр по"
71
+ "Filter by": "фильтр по"
74
72
  "Checked if active": "Отмечено, если активно"
75
73
  "As you're not the admin or the owner of this record you cannot edit it": "Вы не администратор и не владелец записи и не можете ее редактировать"
76
74
  "You can't change your role": "Вы не можете менять свою собственную роль"
@@ -82,7 +80,6 @@ ru:
82
80
  "{{current_user_role}} can't perform action. ({{action}})": "{{current_user_role}} не может выполнить действие. ({{action}})"
83
81
  "{{current_user_role}} can't go to {{action}} on {{controller}}": "{{current_user_role}} не может перейти к {{action}} в {{controller}}."
84
82
  "{{current_user_role}} can't delete this item": "{{current_user_role}} не может удалить эту запись"
85
- "{{current_user_role}} can't perform action ({{action}})": "{{current_user_role}} не может выполнить действие ({{action}})"
86
83
  "{{current_user_role}} can't display items": "{{current_user_role}} не может отобразить записи"
87
84
  "You can update your password at": "Вы можете установить свой пароль на"
88
85
  "If you didn't request a password update, you can ignore this message": "Если Вы не запрашивали обновление пароля, Вы можете проигнорировать это сообщение."
@@ -100,8 +97,6 @@ ru:
100
97
  "Last few days": "Последние дней"
101
98
  "Last 7 days": "Последние 7 дней"
102
99
  "Last 30 days": "Последние 30 дней"
103
- "Created at": "Создано"
104
- "Updated at": "Обновлено"
105
100
  "{{model}} filtered by {{filtered_by}}":
106
101
  "True":
107
102
  "False":
@@ -7,6 +7,7 @@ Typus::Configuration.options[:app_name] = '<%= application %>'
7
7
  # Typus::Configuration.options[:default_locale] = :en
8
8
  # Typus::Configuration.options[:email] = 'admin@example.com'
9
9
  # Typus::Configuration.options[:recover_password] = true
10
+ # Typus::Configuration.options[:relationship] = 'typus_users'
10
11
  # Typus::Configuration.options[:root] = 'admin'
11
12
  # Typus::Configuration.options[:ssl] = false
12
13
  # Typus::Configuration.options[:templates_folder] = 'admin/templates'
@@ -17,7 +18,7 @@ Typus::Configuration.options[:app_name] = '<%= application %>'
17
18
 
18
19
  # Typus::Configuration.options[:default_action_on_item] = 'edit'
19
20
  # Typus::Configuration.options[:end_year] = Time.now.year + 1
20
- # Typus::Configuration.options[:form_rows] = 10
21
+ # Typus::Configuration.options[:form_rows] = 15
21
22
  # Typus::Configuration.options[:index_after_save] = true
22
23
  # Typus::Configuration.options[:minute_step] = 5
23
24
  # Typus::Configuration.options[:nil] = 'nil'
@@ -4,8 +4,10 @@ html { background: #000; height: 100%; margin-bottom: 1px; }
4
4
  body { color: #000; font-family: "Lucida Grande", Helvetica, Arial, sans-serif; font-size: 75%; }
5
5
  label { display: block; font-weight: bold; margin-bottom: 5px; }
6
6
  strong { font-weight: bold; }
7
- dt { float: left; font-weight: bold; width: 200px; }
8
- dd { margin: 0 0 0 220px; }
7
+ em { font-style: italic; }
8
+ dl { margin: 14px 0 20px 0; }
9
+ dt { font-weight: bold; margin: 0 0 5px 0; }
10
+ dd { font-size: 18px; margin: 0 0 15px 0; }
9
11
 
10
12
  /* @end */
11
13
 
@@ -78,7 +80,7 @@ a.on { color: #333; font-weight: bold; text-decoration: underline; }
78
80
  #content ul { margin: 0 1.5em; }
79
81
  #content li { list-style: square; line-height: 20px; }
80
82
  #content ul li { list-style: square; }
81
- #content p { margin: 1em 0; }
83
+ #content p { margin: 0 0 1em 0; }
82
84
  #content p a { text-decoration: underline; }
83
85
  #content p a:hover { color: #408BB6; }
84
86
 
@@ -368,5 +370,6 @@ input#search { border: 1px solid #999; font-size: 1.2em; padding: 3px; }
368
370
 
369
371
  .sprite { background: url(/images/admin/ui-icons.png) no-repeat; text-indent: -1000px; }
370
372
  .trash { background-position: -177px -97px; height: 15px; width: 15px; }
373
+ .unrelate { background-position: -145px -129px; height: 15px; width: 15px; }
371
374
 
372
375
  /* @end */
@@ -278,8 +278,8 @@ module Typus
278
278
 
279
279
  def previous_and_next(condition = {}, klass = self.class)
280
280
 
281
- previous_conditions = "#{klass.primary_key} < #{id}"
282
- next_conditions = "#{klass.primary_key} > #{id}"
281
+ previous_conditions = "#{klass.primary_key} < #{quote_value(id)}"
282
+ next_conditions = "#{klass.primary_key} > #{quote_value(id)}"
283
283
 
284
284
  if !condition.empty?
285
285
  conditions, joins = klass.build_conditions(condition)
@@ -287,13 +287,15 @@ module Typus
287
287
  next_conditions += " AND #{conditions}"
288
288
  end
289
289
 
290
+ select = !klass.typus_user_id? ? klass.primary_key : "#{klass.primary_key}, #{Typus.user_fk}"
291
+
290
292
  previous_ = klass.find :first,
291
- :select => [klass.primary_key],
293
+ :select => select,
292
294
  :order => "#{klass.primary_key} DESC",
293
295
  :conditions => previous_conditions
294
296
 
295
297
  next_ = klass.find :first,
296
- :select => [klass.primary_key],
298
+ :select => select,
297
299
  :order => "#{klass.primary_key} ASC",
298
300
  :conditions => next_conditions
299
301
 
@@ -305,10 +307,6 @@ module Typus
305
307
  respond_to?(:name) ? name : "#{self.class}##{id}"
306
308
  end
307
309
 
308
- def typus_user_id?
309
- self.class.typus_user_id?
310
- end
311
-
312
310
  def owned_by?(user)
313
311
  send(Typus.user_fk) == user.id
314
312
  end
@@ -86,7 +86,7 @@ module Typus
86
86
 
87
87
  if message
88
88
  flash[:notice] = message
89
- redirect_to :back rescue redirect_to admin_dashboard_path
89
+ redirect_to request.referer || admin_dashboard_path
90
90
  end
91
91
 
92
92
  end
@@ -99,21 +99,18 @@ module Typus
99
99
  when 'index', 'show'
100
100
  _("{{current_user_role}} can't display items.",
101
101
  :current_user_role => @current_user.role.capitalize)
102
- when 'edit', 'update', 'position', 'toggle', 'relate', 'unrelate'
103
102
  when 'destroy'
104
103
  _("{{current_user_role}} can't delete this item.",
105
104
  :current_user_role => @current_user.role.capitalize)
106
105
  else
107
- _("{{current_user_role}} can't perform action ({{action}}).",
106
+ _("{{current_user_role}} can't perform action. ({{action}})",
108
107
  :current_user_role => @current_user.role.capitalize,
109
108
  :action => params[:action])
110
109
  end
111
110
 
112
111
  unless @current_user.can_perform?(@resource[:class], params[:action])
113
- flash[:notice] = message || _("{{current_user_role}} can't perform action. ({{action}}).",
114
- :current_user_role => @current_user.role.capitalize,
115
- :action => params[:action])
116
- redirect_to :back rescue redirect_to admin_dashboard_path
112
+ flash[:notice] = message
113
+ redirect_to request.referer || admin_dashboard_path
117
114
  end
118
115
 
119
116
  end
@@ -129,7 +126,7 @@ module Typus
129
126
  :current_user_role => @current_user.role.capitalize,
130
127
  :action => action,
131
128
  :controller => controller.humanize.downcase)
132
- redirect_to :back rescue redirect_to admin_dashboard_path
129
+ redirect_to request.referer || admin_dashboard_path
133
130
  end
134
131
  end
135
132
 
@@ -9,6 +9,7 @@ module Typus
9
9
  :email => 'admin@example.com',
10
10
  :image_preview_size => 'typus',
11
11
  :recover_password => false,
12
+ :relationship => 'typus_users',
12
13
  :root => 'admin',
13
14
  :ssl => false,
14
15
  :templates_folder => 'admin/templates',
@@ -18,7 +19,7 @@ module Typus
18
19
  # Default options which can be overwritten from the initializer.
19
20
  model_options = { :default_action_on_item => 'edit',
20
21
  :end_year => nil,
21
- :form_rows => 10,
22
+ :form_rows => 15,
22
23
  :index_after_save => false,
23
24
  :minute_step => 5,
24
25
  :nil => 'nil',
data/lib/typus/user.rb CHANGED
@@ -13,6 +13,7 @@ module Typus
13
13
  extend ClassMethodsMixin
14
14
 
15
15
  attr_accessor :password
16
+ attr_protected :status
16
17
 
17
18
  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/
18
19
  validates_presence_of :email
@@ -50,12 +51,12 @@ module Typus
50
51
  user && user.authenticated?(password) ? user : nil
51
52
  end
52
53
 
53
- def generate(email, password, role = Typus::Configuration.options[:root], status = true)
54
- new :email => email,
55
- :password => password,
56
- :password_confirmation => password,
57
- :role => role,
58
- :status => status
54
+ def generate(*args)
55
+ options = args.extract_options!
56
+ new :email => options[:email],
57
+ :password => options[:password],
58
+ :password_confirmation => options[:password],
59
+ :role => options[:role]
59
60
  end
60
61
 
61
62
  end
@@ -76,24 +77,23 @@ module Typus
76
77
 
77
78
  def can_perform?(resource, action, options = {})
78
79
 
79
- if options[:special]
80
- _action = action
81
- else
82
- _action = case action
83
- when 'new', 'create' then 'create'
84
- when 'index', 'show' then 'read'
85
- when 'edit', 'update' then 'update'
86
- when 'position' then 'update'
87
- when 'toggle' then 'update'
88
- when 'relate', 'unrelate' then 'update'
89
- when 'destroy' then 'delete'
90
- else
91
- action
80
+ return false if !resources.include?(resource.to_s)
81
+
82
+ _action = if options[:special]
83
+ action
84
+ else
85
+ case action
86
+ when 'new', 'create' then 'create'
87
+ when 'index', 'show' then 'read'
88
+ when 'edit', 'update' then 'update'
89
+ when 'position', 'toggle' then 'update'
90
+ when 'relate', 'unrelate' then 'update'
91
+ when 'destroy' then 'delete'
92
+ else action
92
93
  end
93
- end
94
+ end
94
95
 
95
- # OPTIMIZE: We should not use a rescue.
96
- resources[resource.to_s].split(', ').include?(_action) rescue false
96
+ resources[resource.to_s].split(', ').include?(_action)
97
97
 
98
98
  end
99
99
 
data/lib/typus.rb CHANGED
@@ -13,7 +13,8 @@ module Typus
13
13
  def locales
14
14
  [ [ "German", 'de' ],
15
15
  [ "English", 'en' ],
16
- [ "Español", 'es' ],
16
+ [ "Español", 'es' ],
17
+ [ "Français", 'fr' ],
17
18
  [ "Portuguese", 'pt-BR' ],
18
19
  [ "Russian", 'ru' ] ]
19
20
  end
@@ -59,6 +60,10 @@ module Typus
59
60
  Typus::Configuration.options[:user_fk]
60
61
  end
61
62
 
63
+ def relationship
64
+ Typus::Configuration.options[:relationship]
65
+ end
66
+
62
67
  def testing?
63
68
  Rails.env.test? && Dir.pwd == "#{Rails.root}/vendor/plugins/typus"
64
69
  end
@@ -110,6 +115,13 @@ module Typus
110
115
  # Vendor.
111
116
  require 'vendor/active_record'
112
117
  require 'vendor/paginator'
118
+ require 'vendor/rss_parser'
119
+
120
+ # Gems.
121
+ begin
122
+ require 'Rdiscount'
123
+ rescue LoadError
124
+ end
113
125
 
114
126
  # Run controllers generator ...
115
127
  generator unless testing? || Rails.env.production?
@@ -0,0 +1,20 @@
1
+ class RssParser
2
+
3
+ require 'rexml/document'
4
+
5
+ def self.run(url)
6
+ xml = REXML::Document.new Net::HTTP.get(URI.parse(url))
7
+ data = { :title => xml.root.elements['channel/title'].text,
8
+ :home_url => xml.root.elements['channel/link'].text,
9
+ :rss_url => url,
10
+ :items => [] }
11
+ xml.elements.each '//item' do |item|
12
+ new_items = {} and item.elements.each do |e|
13
+ new_items[e.name.gsub(/^dc:(\w)/,"\1").to_sym] = e.text
14
+ end
15
+ data[:items] << new_items
16
+ end
17
+ data
18
+ end
19
+
20
+ end
@@ -1,8 +1,7 @@
1
1
  require 'test/helper'
2
2
 
3
- ##
4
3
  # Test polimorphic relationships using the relate & unrelate actions.
5
- #
4
+
6
5
  class Admin::AssetsControllerTest < ActionController::TestCase
7
6
 
8
7
  def setup
@@ -27,7 +26,7 @@ class Admin::AssetsControllerTest < ActionController::TestCase
27
26
  assert_response :redirect
28
27
  assert_redirected_to '/admin/posts/edit/1#assets'
29
28
  assert flash[:success]
30
- assert_equal 'Asset successfully assigned to Post.', flash[:success]
29
+ assert_equal "Asset successfully assigned to Post.", flash[:success]
31
30
 
32
31
  end
33
32
 
@@ -50,7 +49,7 @@ class Admin::AssetsControllerTest < ActionController::TestCase
50
49
  assert_response :redirect
51
50
  assert_redirected_to '/admin/posts/1/edit#assets'
52
51
  assert flash[:success]
53
- assert_equal 'Asset successfully updated.', flash[:success]
52
+ assert_equal "Asset successfully updated.", flash[:success]
54
53
 
55
54
  end
56
55
 
@@ -1,8 +1,7 @@
1
1
  require 'test/helper'
2
2
 
3
- ##
4
3
  # Test position action if acts as list is installed.
5
- #
4
+
6
5
  class Admin::CategoriesControllerTest < ActionController::TestCase
7
6
 
8
7
  def setup
@@ -1,8 +1,7 @@
1
1
  require 'test/helper'
2
2
 
3
- ##
4
3
  # Test template extensions rendering and things related to views.
5
- #
4
+
6
5
  class Admin::CommentsControllerTest < ActionController::TestCase
7
6
 
8
7
  def setup
@@ -104,6 +103,8 @@ class Admin::CommentsControllerTest < ActionController::TestCase
104
103
 
105
104
  def test_should_generate_csv
106
105
 
106
+ return if !defined?(FasterCSV)
107
+
107
108
  expected = <<-RAW
108
109
  Email,Post
109
110
  john@example.com,1