card 1.96.0 → 1.96.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/initializers/02_patches/kaminari.rb +2 -2
  4. data/config/locales/de.yml +38 -3
  5. data/config/locales/en.yml +39 -4
  6. data/config/locales/es.yml +606 -0
  7. data/db/migrate_core_cards/data/cards/{*header → Xheader} +0 -0
  8. data/db/migrate_core_cards/data/cards/{*main_menu → Xmain_menu} +0 -0
  9. data/lib/card.rb +2 -2
  10. data/lib/card/act_manager.rb +1 -1
  11. data/lib/card/env/success.rb +26 -13
  12. data/lib/card/format/nest/fetch.rb +6 -1
  13. data/lib/card/migration/import/import_data/card_content.rb +1 -1
  14. data/mod/account/set/right/account.rb +115 -101
  15. data/mod/account/set/self/signin.rb +106 -96
  16. data/mod/account/spec/set/all/account_spec.rb +0 -2
  17. data/mod/account/spec/set/right/account_spec.rb +6 -9
  18. data/mod/account/spec/set/self/signin_spec.rb +2 -5
  19. data/mod/admin/set/self/admin_info.rb +4 -4
  20. data/mod/admin/spec/set/self/admin_info_spec.rb +10 -0
  21. data/mod/admin/spec/set/self/trash_spec.rb +7 -0
  22. data/mod/basic_formats/set/all/json.rb +7 -3
  23. data/mod/basic_formats/spec/set/all/head_spec.rb +33 -0
  24. data/mod/basic_types/set/type/json.rb +1 -1
  25. data/mod/basic_types/spec/set/type/plain_text_spec.rb +6 -0
  26. data/mod/bootstrap/set/type/customized_bootswatch_skin.rb +2 -2
  27. data/mod/bootstrap/spec/set/type/customized_bootswatch_skin/html_views_spec.rb +5 -0
  28. data/mod/bootstrap/spec/set/type_plus_right/customized_bootswatch_skin/colors_spec.rb +8 -0
  29. data/mod/carrierwave/set/abstract/attachment/storage_type.rb +12 -13
  30. data/mod/core/set/all/actify.rb +5 -0
  31. data/mod/core/set/all/codename.rb +2 -2
  32. data/mod/core/set/all/event_conditions.rb +2 -1
  33. data/mod/core/set/all/fetch_helper.rb +2 -2
  34. data/mod/core/set/all/i18n.rb +1 -1
  35. data/mod/core/set/all/item.rb +6 -0
  36. data/mod/core/set/all/location_history.rb +12 -1
  37. data/mod/core/set/all/name_events.rb +8 -9
  38. data/mod/core/set/all/permissions.rb +1 -1
  39. data/mod/core/set/all/rename.rb +3 -5
  40. data/mod/core/set/all/trash.rb +4 -9
  41. data/mod/core/set/all/type.rb +7 -5
  42. data/mod/core/set/all/utils.rb +13 -5
  43. data/mod/core/spec/set/abstract/code_file_spec.rb +8 -0
  44. data/mod/core/spec/set/all/tabs_spec.rb +19 -0
  45. data/mod/developer/spec/set/all/view_viz_spec.rb +9 -0
  46. data/mod/follow/spec/set/all/follow/follow_link_spec.rb +7 -0
  47. data/mod/follow/spec/set/all/notify/html_views_spec.rb +7 -0
  48. data/mod/follow/spec/set/right/follow_spec.rb +0 -0
  49. data/mod/follow/spec/set/right/following_spec.rb +6 -0
  50. data/mod/follow/spec/set/type/notification_template_spec.rb +1 -1
  51. data/mod/history/set/all/content_history.rb +1 -1
  52. data/mod/history/spec/set/all/act_view_spec.rb +16 -0
  53. data/mod/history/spec/set/all/action_view_spec.rb +10 -0
  54. data/mod/history/spec/set/all/history_spec.rb +11 -0
  55. data/mod/item/spec/set/all/bar_spec.rb +41 -0
  56. data/mod/machines/lib/javascript/decko_slot.js.coffee +1 -1
  57. data/mod/pointer/set/abstract/02_pointer/other_views.rb +0 -4
  58. data/mod/recaptcha/set/all/recaptcha.rb +1 -1
  59. data/mod/search/spec/set/abstract/search_spec.rb +8 -0
  60. data/mod/standard/set/all/error.rb +48 -26
  61. data/mod/standard/set/all/rich_html/toolbar.rb +6 -1
  62. data/mod/standard/set/type/list.rb +7 -9
  63. data/mod/standard/set/type/number.rb +1 -1
  64. data/mod/standard/set/type/session.rb +1 -1
  65. data/mod/standard/spec/content/chunk/link_spec.rb +3 -3
  66. data/mod/utility/set/abstract/media.rb +13 -9
  67. data/mod/utility/set/abstract/media/media_snippet.haml +5 -3
  68. metadata +22 -6
@@ -14,11 +14,9 @@ def suspend_name name
14
14
  Card.where(id: id).update_all(name: tmp_name, key: tmp_name)
15
15
  end
16
16
 
17
- event :validate_renaming, :validate, on: :update, changed: :name do
18
- if db_content_is_changing?
19
- errors.add :content, "cannot change content while changing name"
20
- end
21
- errors.add :type, "cannot change type while changing name" if type_id_is_changing?
17
+ event :validate_renaming, :validate, on: :update, changed: :name, skip: :allowed do
18
+ errors.add :content, tr(:cannot_change_content) if db_content_is_changing?
19
+ errors.add :type, tr(:cannot_change_type) if type_id_is_changing?
22
20
  end
23
21
 
24
22
  event :cascade_name_changes, :finalize, on: :update, changed: :name,
@@ -31,9 +31,7 @@ module ClassMethods
31
31
  file_ids = all_file_ids
32
32
  file_ids.each do |file_id|
33
33
  next unless trashed_card_ids.member?(file_id)
34
- if Card.exists?(file_id) # double check!
35
- raise Card::Error, "Narrowly averted deleting current file"
36
- end
34
+ raise Card::Error, tr(:exception_almost_deleted) if Card.exists?(file_id)
37
35
  ::FileUtils.rm_rf "#{dir}/#{file_id}", secure: true
38
36
  end
39
37
  end
@@ -92,7 +90,7 @@ end
92
90
 
93
91
  event :validate_delete, :validate, on: :delete do
94
92
  unless codename.blank?
95
- errors.add :delete, "#{name} is is a system card. (#{codename})"
93
+ errors.add :delete, tr(:error_system_card, name: name, codename: codename)
96
94
  end
97
95
 
98
96
  undeletable_all_rules_tags =
@@ -101,13 +99,10 @@ event :validate_delete, :validate, on: :delete do
101
99
 
102
100
  if junction? && left&.codename == :all &&
103
101
  undeletable_all_rules_tags.member?(right.codename.to_s)
104
- errors.add :delete, "#{name} is an indestructible rule"
102
+ errors.add :delete, tr(:error_indestructible, name: name)
105
103
  end
106
104
 
107
- if account && has_edits?
108
- errors.add :delete, "Edits have been made with #{name}'s user account.\n" \
109
- "Deleting this card would mess up our history."
110
- end
105
+ errors.add :delete, tr(:error_user_edits, name: name) if account && has_edits?
111
106
  end
112
107
 
113
108
  event :validate_delete_children, after: :validate_delete, on: :delete do
@@ -44,16 +44,18 @@ end
44
44
 
45
45
  event :validate_type_change, :validate, on: :update, changed: :type_id do
46
46
  if (c = dup) && c.action == :create && !c.valid?
47
- errors.add :type, "of #{name} can't be changed; errors creating new " \
48
- "#{type_id}: #{c.errors.full_messages * ', '}"
47
+ errors.add :type, tr(
48
+ :error_cant_change_errors,
49
+ name: name, type_id: type_id,
50
+ error_messages: c.errors.full_messages
51
+ )
49
52
  end
50
53
  end
51
54
 
52
55
  event :validate_type, :validate, changed: :type_id do
53
- errors.add :type, "No such type" unless type_name
56
+ errors.add :type, tr(:error_no_such_type) unless type_name
54
57
 
55
58
  if (rt = structure) && rt.assigns_type? && type_id != rt.type_id
56
- errors.add :type, "can't be changed because #{name} is hard templated " \
57
- "to #{rt.type_name}"
59
+ errors.add :type, tr(:error_hard_templated, name: name, type_name: rt.type_name)
58
60
  end
59
61
  end
@@ -31,14 +31,22 @@ module ClassMethods
31
31
  def merge name, attribs={}, opts={}
32
32
  # puts "merging #{name}"
33
33
  card = fetch name, new: {}
34
+ return unless mergeable? card, opts[:pristine]
35
+ resolve_file_attributes! attribs
36
+ card.update_attributes! attribs.reverse_merge(skip: :validate_renaming)
37
+ end
38
+
39
+ private
40
+
41
+ def resolve_file_attributes! attribs
34
42
  %i[image file].each do |attach|
35
43
  next unless attribs[attach] && attribs[attach].is_a?(String)
36
44
  attribs[attach] = ::File.open(attribs[attach])
37
45
  end
38
- if opts[:pristine] && !card.pristine?
39
- false
40
- else
41
- card.update_attributes! attribs
42
- end
46
+ end
47
+
48
+ def mergeable? card, pristine_only
49
+ return true unless pristine_only
50
+ !card.pristine?
43
51
  end
44
52
  end
@@ -0,0 +1,8 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Set::Abstract::CodeFile do
4
+ specify "view bar_middle" do
5
+ expect_view(:bar_middle).to have_tag("i.fa")
6
+ expect_view(:bar_middle).to have_tag("span.text-muted")
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Set::All::Tabs do
4
+ specify "view tabs" do
5
+ expect_view(:tabs).to have_tag("div.tabbable") do
6
+ with_tag "ul.nav"
7
+ with_tag "li.nav-item"
8
+ with_tag "div.tab-content"
9
+ end
10
+ end
11
+
12
+ specify "view pills" do
13
+ expect_view(:pills).to have_tag("div.tabbable") do
14
+ with_tag "ul.nav"
15
+ with_tag "li.nav-item"
16
+ with_tag "div.tab-content"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ describe Card::Set::All::ViewViz do
2
+ specify "view views_by_format" do
3
+ expect_view(:views_by_format).to have_tag("div.card") do
4
+ with_tag "div.card-body"
5
+ with_tag "ul.list-group"
6
+ with_tag "li.list-group-item"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ describe Card::Set::All::Follow::FollowLink do
2
+ specify "view follow_link" do
3
+ expect_view(:follow_link).to have_tag("a") do
4
+ with_tag "span.follow-verb.menu-item-label"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ describe Card::Set::All::Notify::HtmlViews do
2
+ specify "view last_action" do
3
+ expect_view(:last_action).to have_tag("a.known-card") do
4
+ with_tag "span.card-title"
5
+ end
6
+ end
7
+ end
@@ -8,4 +8,10 @@ describe Card::Set::Right::Following do
8
8
 
9
9
  check_views_for_errors :core, :status, :rule_editor
10
10
  end
11
+
12
+ specify "view core" do
13
+ expect_view(:core).to have_tag("div.card-slot") do
14
+ with_tag "div.menu-slot.nodblclick"
15
+ end
16
+ end
11
17
  end
@@ -11,7 +11,7 @@ RSpec.describe Card::Set::Type::NotificationTemplate do
11
11
 
12
12
  def notify
13
13
  Card::Auth.as_bot do
14
- post :update, params: { id: "~#{Card['A'].id}",
14
+ post :update, params: { mark: "A",
15
15
  card: { "content" => "change" } },
16
16
  xhr: true
17
17
  end
@@ -169,7 +169,7 @@ def draft_acts
169
169
  end
170
170
 
171
171
  event :detect_conflict, :validate, on: :update, when: :edit_conflict? do
172
- errors.add :conflict, "changes not based on latest revision"
172
+ errors.add :conflict, tr(:error_not_latest_revision)
173
173
  end
174
174
 
175
175
  def edit_conflict?
@@ -0,0 +1,16 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Set::All::ActView do
4
+ specify "view act" do
5
+ expect_view(:act).to have_tag("div.card") do
6
+ with_tag "div.card-header"
7
+ with_tag "div.card-body"
8
+ end
9
+ end
10
+
11
+ specify "view act_legend" do
12
+ expect_view(:act_legend).to have_tag("div.row") do
13
+ with_tag "div"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Set::All::ActionView do
4
+ # SPECSTUB
5
+ specify "view action_summary" do
6
+ expect_view(:action_summary).to have_tag("div.card-slot") do
7
+ with_tag "ins"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Set::All::History do
4
+ # SPECSTUB
5
+ specify "view history" do
6
+ expect_view(:history).to have_tag("div.card-slot.history-view") do
7
+ with_tag "div.card-body"
8
+ with_tag "div.card-header"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,41 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Set::All::Bar do
4
+ specify "view thin_bar" do
5
+ expect_view(:thin_bar).to have_tag("div.card-slot.bar-view")
6
+ end
7
+
8
+ specify "view bar_left" do
9
+ expect_view(:bar_left).to have_tag("span.card-title")
10
+ end
11
+
12
+ specify "view bar_middle" do
13
+ expect_view(:bar_middle).to have_tag("span.labeled-badge")
14
+ end
15
+
16
+ specify "view bar_bottomm" do
17
+ expect_view(:bar_bottomm).to have_tag("strong")
18
+ end
19
+
20
+ specify "view bar_page_link" do
21
+ expect_view(:bar_page_link).to have_tag("a.text-muted") do
22
+ with_tag "i"
23
+ end
24
+ end
25
+
26
+ specify "view bar_expand_link" do
27
+ expect_view(:bar_expand_link).to have_tag("a.slotter") do
28
+ with_tag "i"
29
+ end
30
+ end
31
+
32
+ specify "view bar_collapse_link" do
33
+ expect_view(:bar_collapse_link).to have_tag("a.slotter") do
34
+ with_tag "i"
35
+ end
36
+ end
37
+
38
+ specify "view edit_button" do
39
+ expect_view(:edit_button).to have_tag("a.btn")
40
+ end
41
+ end
@@ -72,7 +72,7 @@ jQuery.fn.extend {
72
72
  s = @slot()
73
73
  v = $(val)[0] && $(val) || val
74
74
  if typeof(v) == "string"
75
- # Needed to support "TEXT: result" pattern in success (eg deleting nested cards)
75
+ # needed to support unwrapped views
76
76
  s.replaceWith v
77
77
  else
78
78
  s.setSlotContentFromElement v
@@ -11,10 +11,6 @@ format do
11
11
  end
12
12
  end
13
13
 
14
- def wrap_item item, _args={}
15
- item # no wrap in base
16
- end
17
-
18
14
  def nest_item_array
19
15
  card.item_cards.map do |item|
20
16
  nest_item item
@@ -1,5 +1,5 @@
1
1
  format :html do
2
- def decko_variables
2
+ def decko_script_variables
3
3
  super.merge "decko.recaptchaKey": Card.config.recaptcha_public_key
4
4
  end
5
5
 
@@ -0,0 +1,8 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ describe Card::Set::Abstract::Search do
4
+ # SPECSTUB
5
+ specify "view no_search_results" do
6
+ expect_view(:no_search_results).to have_tag("div.search-no-results")
7
+ end
8
+ end
@@ -10,7 +10,7 @@ format do
10
10
  end
11
11
 
12
12
  view :unsupported_view, perms: :none, tags: :unknown_ok, error_code: 404 do
13
- "view (#{voo.unsupported_view}) not supported for #{error_cardname}"
13
+ tr(:unsupported_view, view: voo.unsupported_view, cardname: error_cardname)
14
14
  end
15
15
 
16
16
  view :missing, perms: :none do
@@ -18,28 +18,28 @@ format do
18
18
  end
19
19
 
20
20
  view :not_found, perms: :none, error_code: 404 do
21
- error_name = card.name.present? ? safe_name : "the card requested"
22
- %( Could not find #{error_name}. )
21
+ error_name = card.name.present? ? safe_name : tr(:not_found_no_name)
22
+ tr(:not_found_named, cardname: error_name)
23
23
  end
24
24
 
25
25
  view :server_error, perms: :none, error_code: 500 do
26
- ["Wild Card!", "500 Server Error", "Yuck, sorry about that.", ":("].join "\n\n"
26
+ tr(:server_error)
27
27
  end
28
28
 
29
29
  view :denial, perms: :none, error_code: 403 do
30
- focal? ? "Permission Denied" : ""
30
+ focal? ? tr(:denial) : ""
31
31
  end
32
32
 
33
33
  view :bad_address, perms: :none, error_code: 404 do
34
- %( 404: Bad Address )
34
+ tr(:bad_address)
35
35
  end
36
36
 
37
37
  view :too_deep, perms: :none, closed: true do
38
- %{ Man, you're too deep. (Too many levels of nests at a time) }
38
+ tr(:too_deep)
39
39
  end
40
40
 
41
41
  view :too_slow, perms: :none, closed: true, error_code: 408 do
42
- %( Timed out! #{title_in_context} took too long to load. )
42
+ tr(:too_slow, showname: title_in_context)
43
43
  end
44
44
  end
45
45
 
@@ -62,7 +62,7 @@ format :html do
62
62
  debug_error exception if Auth.always_ok?
63
63
  details = Auth.always_ok? ? backtrace_link(exception) : error_cardname
64
64
  wrap_with :span, class: "render-error alert alert-danger" do
65
- ["error rendering", details, "(#{view} view)"].join "\n"
65
+ [tr(:error_rendering), details, "(#{view} view)"].join "\n"
66
66
  end
67
67
  end
68
68
 
@@ -122,7 +122,7 @@ format :html do
122
122
 
123
123
  view :errors, perms: :none do
124
124
  return if card.errors.empty?
125
- voo.title = card.name.blank? ? "Problems" : "Problems with #{card.name}"
125
+ voo.title = card.name.blank? ? "Problems" : tr(:problems_name, cardname: card.name)
126
126
  voo.hide! :menu
127
127
  class_up "d0-card-frame", "card card-warning card-inverse"
128
128
  class_up "alert", "card-error-msg"
@@ -145,7 +145,7 @@ format :html do
145
145
  voo.hide! :menu
146
146
  voo.title = "Not Found"
147
147
  frame do
148
- [not_found_errors, sign_in_or_up_links]
148
+ [not_found_errors, sign_in_or_up_links("to create it")]
149
149
  end
150
150
  end
151
151
 
@@ -157,11 +157,25 @@ format :html do
157
157
  end
158
158
  end
159
159
 
160
- def sign_in_or_up_links
160
+ def sign_in_or_up_links to_task
161
161
  return if Auth.signed_in?
162
- signin_link = link_to_card :signin, "Sign in"
163
- signup_link = link_to "Sign up", path: { action: :new, mark: :signup }
164
- wrap_with(:div) { "#{signin_link} or #{signup_link} to create it." }
162
+ links = [signin_link, signup_link].compact.join " #{tr :or} "
163
+ wrap_with(:div) do
164
+ [tr(:please), links, to_task].join(" ") + "."
165
+ end
166
+ end
167
+
168
+ def signin_link
169
+ link_to_card :signin, tr(:sign_in_c)
170
+ end
171
+
172
+ def signup_link
173
+ return unless signup_ok?
174
+ link_to tr(:sign_up_c), path: { action: :new, mark: :signup }
175
+ end
176
+
177
+ def signup_ok?
178
+ Card.new(type_id: Card::SignupID).ok? :create
165
179
  end
166
180
 
167
181
  view :denial do
@@ -176,32 +190,40 @@ format :html do
176
190
 
177
191
  def loud_denial
178
192
  frame do
179
- [
180
- wrap_with(:h1, "Sorry!"),
181
- wrap_with(:div, loud_denial_message)
182
- ]
193
+ [wrap_with(:h1, tr(:sorry)),
194
+ wrap_with(:div, loud_denial_message)]
183
195
  end
184
196
  end
185
197
 
186
198
  def loud_denial_message
187
- to_task = @denied_task ? "to #{@denied_task} this." : "to do that."
199
+ to_task = @denied_task ? tr(:denied_task, denied_task: @denied_task) : tr(:to_do_that)
200
+
188
201
  case
189
- when @denied_task != :read && Card.config.read_only
190
- "We are currently in read-only mode. Please try again later."
202
+ when not_denied_task_read?
203
+ tr(:read_only)
191
204
  when Auth.signed_in?
192
- "You need permission #{to_task}"
205
+ tr(:need_permission_task, task: to_task)
193
206
  else
194
- denial_message_with_links to_task
207
+ Env.save_interrupted_action request.env["REQUEST_URI"]
208
+ sign_in_or_up_links to_do_unauthorized_task
195
209
  end
196
210
  end
197
211
 
212
+ def not_denied_task_read?
213
+ @denied_task != :read && Card.config.read_only
214
+ end
215
+
216
+ def to_do_unauthorized_task
217
+ @denied_task ? tr(:denied_task, denied_task: @denied_task) : tr(:to_do_that)
218
+ end
219
+
198
220
  def denial_message_with_links to_task
199
221
  linx = [link_to_card(:signin, "sign in")]
200
222
  if Card.new(type_id: Card::SignupID).ok?(:create)
201
- linx += ["or", link_to("sign up", path: { action: "new", mark: :signup })]
223
+ [tr(:or), link_to(tr(:sign_up), path: { action: "new", mark: :signup })]
202
224
  end
203
225
  Env.save_interrupted_action request.env["REQUEST_URI"]
204
- "Please #{linx.join ' '} #{to_task}"
226
+ "#{tr(:please)} #{linx.join ' '} #{to_task}"
205
227
  end
206
228
 
207
229
  view :server_error, template: :haml