card 1.16.15 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/initializers/recaptcha.rb +21 -4
  4. data/db/migrate_core_cards/20130823192433_add_style_cards.rb +1 -1
  5. data/db/migrate_core_cards/20140512155840_add_script_cards.rb +1 -1
  6. data/db/migrate_core_cards/20140629222005_add_email_cards.rb +2 -2
  7. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +1 -1
  8. data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +1 -1
  9. data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +63 -0
  10. data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
  11. data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +1 -1
  12. data/db/schema.rb +1 -1
  13. data/db/seed/new/card_actions.yml +602 -394
  14. data/db/seed/new/card_acts.yml +595 -1
  15. data/db/seed/new/card_changes.yml +26282 -10262
  16. data/db/seed/new/card_references.yml +1252 -1084
  17. data/db/seed/new/cards.yml +1899 -1423
  18. data/db/seed/test/fixtures/card_actions.yml +1653 -1413
  19. data/db/seed/test/fixtures/card_acts.yml +1063 -445
  20. data/db/seed/test/fixtures/card_changes.yml +29674 -13637
  21. data/db/seed/test/fixtures/card_references.yml +1976 -1815
  22. data/db/seed/test/fixtures/cards.yml +3194 -2719
  23. data/lib/card.rb +14 -13
  24. data/lib/card/auth.rb +10 -6
  25. data/lib/card/cache.rb +58 -120
  26. data/lib/card/cache/persistent.rb +50 -0
  27. data/lib/card/cache/temporary.rb +38 -0
  28. data/lib/card/chunk.rb +34 -25
  29. data/lib/card/content.rb +3 -3
  30. data/lib/card/env.rb +3 -0
  31. data/lib/card/format.rb +56 -53
  32. data/lib/card/migration.rb +6 -2
  33. data/lib/card/name.rb +9 -1
  34. data/lib/card/query.rb +1 -1
  35. data/lib/card/reference.rb +17 -11
  36. data/lib/card/set.rb +1 -1
  37. data/lib/card/subcards.rb +6 -6
  38. data/lib/card/view_cache.rb +45 -28
  39. data/lib/generators/card/migration/templates/card_migration.erb +1 -2
  40. data/mod/01_core/chunk/include.rb +71 -48
  41. data/mod/01_core/chunk/link.rb +6 -3
  42. data/mod/01_core/chunk/query_reference.rb +38 -29
  43. data/mod/01_core/chunk/reference.rb +23 -24
  44. data/mod/01_core/set/all/collection.rb +1 -1
  45. data/mod/01_core/set/all/fetch.rb +39 -12
  46. data/mod/01_core/set/all/permissions.rb +2 -4
  47. data/mod/01_core/set/all/references.rb +50 -75
  48. data/mod/01_core/set/all/rules.rb +19 -18
  49. data/mod/01_core/set/all/subcards.rb +1 -1
  50. data/mod/01_core/set/all/templating.rb +31 -88
  51. data/mod/01_core/set/all/tracked_attributes.rb +7 -14
  52. data/mod/01_core/set/all/utils.rb +77 -66
  53. data/mod/01_core/set_pattern/07_type_plus_right.rb +6 -3
  54. data/mod/01_core/spec/set/all/fetch_spec.rb +148 -96
  55. data/mod/01_core/spec/set/all/templating_spec.rb +49 -40
  56. data/mod/01_core/spec/set/all/trash_spec.rb +1 -1
  57. data/mod/01_history/set/all/actions.rb +1 -1
  58. data/mod/02_basic_types/set/all/base.rb +13 -7
  59. data/mod/02_basic_types/set/all/rss.rb +17 -22
  60. data/mod/02_basic_types/set/type/plain_text.rb +5 -2
  61. data/mod/02_basic_types/spec/set/all/base_spec.rb +1 -0
  62. data/mod/02_basic_types/spec/set/all/rss_spec.rb +7 -6
  63. data/mod/03_machines/lib/javascript/wagn.js.coffee +22 -9
  64. data/mod/03_machines/set/right/machine_output.rb +1 -1
  65. data/mod/04_settings/lib/card/setting.rb +45 -31
  66. data/mod/04_settings/set/right/structure.rb +47 -1
  67. data/mod/04_settings/set/self/default_html_view.rb +2 -0
  68. data/mod/04_settings/set/self/follow_fields.rb +2 -0
  69. data/mod/04_settings/set/self/recent_settings.rb +1 -1
  70. data/mod/05_standard/file/favicon/image-icon.png +0 -0
  71. data/mod/05_standard/file/favicon/image-large.png +0 -0
  72. data/mod/05_standard/file/favicon/image-medium.png +0 -0
  73. data/mod/05_standard/file/favicon/image-original.png +0 -0
  74. data/mod/05_standard/file/favicon/image-small.png +0 -0
  75. data/mod/05_standard/set/all/links.rb +27 -26
  76. data/mod/05_standard/set/all/rich_html/editing.rb +1 -1
  77. data/mod/05_standard/set/all/rich_html/toolbar.rb +1 -1
  78. data/mod/05_standard/set/rstar/rules.rb +20 -325
  79. data/mod/05_standard/set/rstar/rules_editor.rb +362 -0
  80. data/mod/05_standard/set/self/admin_info.rb +82 -0
  81. data/mod/05_standard/set/self/all.rb +16 -10
  82. data/mod/05_standard/set/self/head.rb +20 -19
  83. data/mod/05_standard/set/type/signup.rb +0 -1
  84. data/mod/05_standard/spec/set/all/account_spec.rb +44 -43
  85. data/mod/05_standard/spec/set/right/account_spec.rb +4 -2
  86. data/mod/05_standard/spec/set/type/search_type_spec.rb +8 -0
  87. data/mod/05_standard/spec/set/type/signup_spec.rb +24 -17
  88. data/mod/06_bootstrap/set/all/bootstrap/helper.rb +1 -1
  89. data/spec/lib/card/cache_spec.rb +64 -70
  90. data/spec/lib/card/content_spec.rb +236 -150
  91. data/spec/lib/card/reference_spec.rb +22 -38
  92. data/spec/lib/card/subcards_spec.rb +38 -0
  93. data/spec/lib/card/view_cache_spec.rb +8 -0
  94. data/spec/spec_helper.rb +1 -1
  95. data/tmpsets/set/mod001-01_core/all/collection.rb +77 -74
  96. data/tmpsets/set/mod001-01_core/all/content.rb +14 -16
  97. data/tmpsets/set/mod001-01_core/all/fetch.rb +137 -110
  98. data/tmpsets/set/mod001-01_core/all/name.rb +58 -40
  99. data/tmpsets/set/mod001-01_core/all/pattern.rb +12 -11
  100. data/tmpsets/set/mod001-01_core/all/permissions.rb +125 -117
  101. data/tmpsets/set/mod001-01_core/all/phases.rb +2 -1
  102. data/tmpsets/set/mod001-01_core/all/references.rb +52 -77
  103. data/tmpsets/set/mod001-01_core/all/rules.rb +47 -53
  104. data/tmpsets/set/mod001-01_core/all/templating.rb +31 -87
  105. data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +12 -21
  106. data/tmpsets/set/mod001-01_core/all/trash.rb +4 -1
  107. data/tmpsets/set/mod001-01_core/all/type.rb +23 -21
  108. data/tmpsets/set/mod001-01_core/all/utils.rb +80 -64
  109. data/tmpsets/set/mod002-01_history/all/actions.rb +20 -16
  110. data/tmpsets/set/mod002-01_history/all/history.rb +18 -13
  111. data/tmpsets/set/mod003-02_basic_types/all/base.rb +37 -10
  112. data/tmpsets/set/mod003-02_basic_types/all/rss.rb +17 -22
  113. data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +5 -2
  114. data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +51 -39
  115. data/tmpsets/set/mod004-03_machines/right/machine_output.rb +10 -6
  116. data/tmpsets/set/mod005-04_settings/abstract/permission.rb +10 -5
  117. data/tmpsets/set/mod005-04_settings/right/structure.rb +47 -1
  118. data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +1 -0
  119. data/tmpsets/set/mod005-04_settings/type/setting.rb +4 -1
  120. data/tmpsets/set/mod006-05_email/all/follow.rb +45 -54
  121. data/tmpsets/set/mod006-05_email/all/notify.rb +88 -73
  122. data/tmpsets/set/mod006-05_email/right/followers.rb +17 -14
  123. data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +22 -18
  124. data/tmpsets/set/mod006-05_email/type/email_template.rb +1 -1
  125. data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +94 -67
  126. data/tmpsets/set/mod007-05_standard/all/account.rb +18 -20
  127. data/tmpsets/set/mod007-05_standard/all/comment.rb +51 -29
  128. data/tmpsets/set/mod007-05_standard/all/error.rb +129 -99
  129. data/tmpsets/set/mod007-05_standard/all/links.rb +27 -26
  130. data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +115 -103
  131. data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +112 -78
  132. data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +123 -81
  133. data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +15 -58
  134. data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -2
  135. data/tmpsets/set/mod007-05_standard/right/account.rb +71 -75
  136. data/tmpsets/set/mod007-05_standard/right/email.rb +16 -13
  137. data/tmpsets/set/mod007-05_standard/right/password.rb +20 -12
  138. data/tmpsets/set/mod007-05_standard/right/status.rb +2 -2
  139. data/tmpsets/set/mod007-05_standard/right/token.rb +49 -2
  140. data/tmpsets/set/mod007-05_standard/rstar/rules.rb +20 -325
  141. data/tmpsets/set/mod007-05_standard/self/all.rb +16 -10
  142. data/tmpsets/set/mod007-05_standard/self/head.rb +76 -62
  143. data/tmpsets/set/mod007-05_standard/self/search.rb +45 -22
  144. data/tmpsets/set/mod007-05_standard/self/signin.rb +14 -12
  145. data/tmpsets/set/mod007-05_standard/type/cardtype.rb +13 -11
  146. data/tmpsets/set/mod007-05_standard/type/file.rb +1 -1
  147. data/tmpsets/set/mod007-05_standard/type/search_type.rb +3 -2
  148. data/tmpsets/set/mod007-05_standard/type/set.rb +20 -16
  149. data/tmpsets/set/mod007-05_standard/type/signup.rb +19 -25
  150. data/tmpsets/set/mod007-05_standard/type/user.rb +1 -1
  151. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +1 -1
  152. data/tmpsets/set_pattern/106-type_plus_right.rb +6 -3
  153. metadata +11 -2
@@ -12,11 +12,11 @@ def account
12
12
  end
13
13
 
14
14
  def accountable?
15
- Card.toggle( rule :accountable )
15
+ Card.toggle(rule :accountable)
16
16
  end
17
17
 
18
18
  def parties
19
- @parties ||= (all_roles << self.id).flatten.reject(&:blank?)
19
+ @parties ||= (all_roles << id).flatten.reject(&:blank?)
20
20
  end
21
21
 
22
22
  def among? ok_ids
@@ -26,18 +26,18 @@ def among? ok_ids
26
26
  ok_ids.member? Card::AnyoneID
27
27
  end
28
28
 
29
- def is_own_account?
29
+ def own_account?
30
30
  # card is +*account card of signed_in user.
31
- cardname.part_names[0].key == Auth.as_card.key and
32
- cardname.part_names[1].key == Card[:account].key
31
+ cardname.part_names[0].key == Auth.as_card.key &&
32
+ cardname.part_names[1].key == Card[:account].key
33
33
  end
34
34
 
35
35
  def read_rules
36
36
  @read_rules ||= begin
37
37
  rule_ids = []
38
- unless id==Card::WagnBotID # always_ok, so not needed
39
- ( [ Card::AnyoneID ] + parties ).each do |party_id|
40
- if rule_ids_for_party = self.class.read_rule_cache[ party_id ]
38
+ unless id == Card::WagnBotID # always_ok, so not needed
39
+ ([Card::AnyoneID] + parties).each do |party_id|
40
+ if rule_ids_for_party = self.class.read_rule_cache[party_id]
41
41
  rule_ids += rule_ids_for_party
42
42
  end
43
43
  end
@@ -47,28 +47,26 @@ def read_rules
47
47
  end
48
48
 
49
49
  def all_roles
50
- @all_roles ||=
51
- if id == Card::AnonymousID
52
- []
53
- else
54
- Auth.as_bot do
55
- role_trait = fetch trait: :roles
56
- [ Card::AnyoneSignedInID ] + ( role_trait ? role_trait.item_ids : [] )
57
- end
58
- end
50
+ @all_roles ||= (id == Card::AnonymousID ? [] : fetch_roles)
59
51
  end
60
52
 
53
+ def fetch_roles
54
+ Auth.as_bot do
55
+ role_trait = fetch trait: :roles
56
+ next [Card::AnyoneSignedInID] unless role_trait
57
+ [Card::AnyoneSignedInID] + (role_trait.item_ids)
58
+ end
59
+ end
61
60
 
62
61
  event :generate_token do
63
- Digest::SHA1.hexdigest "--#{Time.now.to_f}--#{rand 10}--"
62
+ Digest::SHA1.hexdigest "--#{Time.zone.now.to_f}--#{rand 10}--"
64
63
  end
65
64
 
66
65
  event :set_stamper, before: :approve do
67
66
  self.updater_id = Auth.current_id
68
- self.creator_id = self.updater_id if new_card?
67
+ self.creator_id = updater_id if new_card?
69
68
  end
70
69
 
71
70
 
72
-
73
71
  # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/all/account.rb ~~~~~~~~~~~
74
72
  end;end;end;end;
@@ -1,44 +1,66 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class Card; module Set; module All; module Comment; extend Card::Set
3
3
  # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/all/comment.rb ~~~~~~~~~~~
4
- event :add_comment, after: :approve, on: :save, when: proc {|c| c.comment } do
4
+ event :add_comment, after: :approve, on: :save, when: proc { |c| c.comment } do
5
+ cleaned_comment =
6
+ comment.split(/\n/).map do |line|
7
+ "<p>#{line.strip.empty? ? '&nbsp;' : line}</p>"
8
+ end * "\n"
9
+
10
+ signature =
11
+ if Auth.signed_in?
12
+ "[[#{Auth.current.name}]]"
13
+ else
14
+ Env.session[:comment_author] = comment_author if Env.session
15
+ "#{comment_author} (Not signed in)"
16
+ end
17
+
5
18
  self.content = %{
6
- #{ content }
7
- #{ '<hr>' unless content.blank? }
8
- #{ comment.split(/\n/).map {|line| "<p>#{line.strip.empty? ? '&nbsp;' : line}</p>"} * "\n" }
9
- <div class="w-comment-author">--#{
10
- if Auth.signed_in?
11
- "[[#{Auth.current.name}]]"
12
- else
13
- Env.session[:comment_author] = comment_author if Env.session
14
- "#{ comment_author } (Not signed in)"
15
- end
16
- }.....#{Time.now}</div>
19
+ #{content}
20
+ #{'<hr>' unless content.blank?}
21
+ #{cleaned_comment}
22
+ <div class="w-comment-author">--#{signature}.....#{Time.zone.now}</div>
17
23
  }
18
24
  end
19
25
 
20
- view( :comment_box, denial: :blank, tags: :unknown_ok, perms: lambda { |r| r.card.ok? :comment } ) do |args|
21
-
26
+ format do
27
+ view :comment_box,
28
+ denial: :blank, tags: :unknown_ok,
29
+ perms: lambda { |r| r.card.ok? :comment } do |_args|
30
+ <<-HTML
31
+ <div class="comment-box nodblclick">#{comment_form}</div>
32
+ HTML
33
+ end
22
34
 
23
- %{<div class="comment-box nodblclick"> #{
35
+ def comment_form
24
36
  card_form :update do
25
37
  %{
26
- #{ hidden_field_tag( 'card[name]', card.name ) if card.new_card?
27
- # FIXME wish we had more generalized solution for names. without this, nonexistent cards will often take left's linkname. (needs test)
38
+ #{hidden_field_tag('card[name]', card.name) if card.new_card?
39
+ # FIXME: wish we had more generalized solution for names.
40
+ # without this, nonexistent cards will often take left's linkname.
41
+ # (needs test)
28
42
  }
29
- #{ text_area :comment, rows: 3 }
30
- <div class="comment-buttons">
31
- #{
32
- unless Auth.signed_in?
33
- card.comment_author= (session[:comment_author] || params[:comment_author] || "Anonymous") #ENGLISH
34
- %{<label>My Name is:</label> #{ text_field :comment_author }}
35
- end
36
- }
37
- #{ button_tag 'Comment', type: :submit, disable_with: "Commenting" }
38
- </div>
43
+ #{text_area :comment, rows: 3}
44
+ #{comment_buttons}
39
45
  }
40
- end}
41
- </div>}
46
+ end
47
+ end
48
+
49
+ def comment_buttons
50
+ <<-HTML
51
+ <div class="comment-buttons">
52
+ #{
53
+ unless Auth.signed_in?
54
+ card.comment_author = session[:comment_author] ||
55
+ params[:comment_author] || 'Anonymous' # ENGLISH
56
+ %{<label>My Name is:</label> #{text_field :comment_author}}
57
+ end
58
+ }
59
+ #{submit_button text: 'Comment', type: :submit,
60
+ disable_with: 'Commenting'}
61
+ </div>
62
+ HTML
63
+ end
42
64
  end
43
65
 
44
66
 
@@ -1,84 +1,100 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class Card; module Set; module All; module Error; extend Card::Set
3
3
  # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/all/error.rb ~~~~~~~~~~~
4
-
4
+ def copy_errors card
5
+ card.errors.each do |att, msg|
6
+ errors.add att, msg
7
+ end
8
+ end
5
9
 
6
10
  format do
7
- view :closed_missing, perms: :none, closed: true do |args|
11
+ view :closed_missing, perms: :none, closed: true do
8
12
  ''
9
13
  end
10
14
 
11
- view :missing, perms: :none do |args|
15
+ view :unsupported_view, perms: :none, tags: :unknown_ok do |args|
16
+ "view (#{args[:unsupported_view]}) not supported for #{error_cardname}"
17
+ end
18
+
19
+ view :missing, perms: :none do
12
20
  ''
13
21
  end
14
22
 
15
- view :not_found, perms: :none, error_code: 404 do |args|
16
- %{ Could not find #{card.name.present? ? %{"#{card.name}"} : 'the card requested'}. }
23
+ view :not_found, perms: :none, error_code: 404 do |_args|
24
+ error_name = card.name.present? ? card.name : 'the card requested'
25
+ %{ Could not find #{error_name}. }
17
26
  end
18
27
 
19
- view :server_error, perms: :none, error_code: 500 do |args|
20
- %{ Wagn Hitch! Server Error. Yuck, sorry about that.\n}+
21
- %{ To tell us more and follow the fix, add a support ticket at http://wagn.org/new/Support_Ticket }
28
+ view :server_error, perms: :none, error_code: 500 do
29
+ %{
30
+ Wagn Hitch! Server Error. Yuck, sorry about that.
31
+ To tell us more and follow the fix,
32
+ add a support ticket at http://wagn.org/new/Support_Ticket
33
+ }
22
34
  end
23
35
 
24
- view :denial, perms: :none, error_code: 403 do |args|
36
+ view :denial, perms: :none, error_code: 403 do
25
37
  focal? ? 'Permission Denied' : ''
26
38
  end
27
39
 
28
- view :bad_address, perms: :none, error_code: 404 do |args|
40
+ view :bad_address, perms: :none, error_code: 404 do
29
41
  %{ 404: Bad Address }
30
42
  end
31
43
 
32
- view :too_deep, perms: :none, closed: true do |args|
44
+ view :too_deep, perms: :none, closed: true do
33
45
  %{ Man, you're too deep. (Too many levels of inclusions at a time) }
34
46
  end
35
47
 
36
- view :too_slow, perms: :none, closed: true do |args|
37
- %{ Timed out! #{ showname } took too long to load. }
48
+ view :too_slow, perms: :none, closed: true do
49
+ %{ Timed out! #{showname} took too long to load. }
38
50
  end
39
51
  end
40
52
 
41
-
42
53
  format :html do
43
54
  def view_for_unknown view, args
44
55
  case
45
- when focal? && ok?( :create ) ; :new
46
- when commentable?( view, args ) ; view
47
- else super
56
+ when focal? && ok?(:create) then :new
57
+ when commentable?(view, args) then view
58
+ else super
48
59
  end
49
60
  end
50
61
 
51
62
  def commentable? view, args
52
- self.class.tagged view, :comment and
53
- show_view? :comment_box, args.merge( default_visibility: :hide ) and #developer or wagneer has overridden default
63
+ return false unless self.class.tagged view, :comment
64
+ visibility_args = args.merge default_visibility: :hide
65
+ return false unless show_view? :comment_box, visibility_args
54
66
  ok? :comment
55
67
  end
56
68
 
57
69
  def rendering_error exception, view
58
- details = if Auth.always_ok?
59
- card_link(error_cardname, class: 'render-error-link') +
60
- alert('warning', dismissible: true, alert_class: "render-error-message errors-view admin-error-message") do
61
- %{
62
- <h3>Error message (visible to admin only)</h3>
63
- <p><strong>#{ exception.message }</strong></p>
64
- <div>#{exception.backtrace * "<br>\n"}</div>
65
- }
66
- end
67
- else
68
- error_cardname
69
- end
70
-
70
+ details = Auth.always_ok? ? backtrace_link(exception) : error_cardname
71
71
  content_tag :span, class: 'render-error alert alert-danger' do
72
- [
73
- 'error rendering',
74
- details,
75
- "(#{view} view)"
76
- ].join "\n"
72
+ ['error rendering', details, "(#{view} view)"].join "\n"
77
73
  end
78
74
  end
79
75
 
80
- def unsupported_view view
81
- "<strong>view <em>#{view}</em> not supported for <em>#{error_cardname}</em></strong>"
76
+ def backtrace_link exception
77
+ warning_options = {
78
+ dismissible: true,
79
+ alert_class: 'render-error-message errors-view admin-error-message'
80
+ }
81
+ warning = alert('warning', warning_options) do
82
+ %{
83
+ <h3>Error message (visible to admin only)</h3>
84
+ <p><strong>#{exception.message}</strong></p>
85
+ <div>#{exception.backtrace * "<br>\n"}</div>
86
+ }
87
+ end
88
+ card_link(error_cardname, class: 'render-error-link') + warning
89
+ end
90
+
91
+ view :unsupported_view, perms: :none, tags: :unknown_ok do |args|
92
+ %{
93
+ <strong>
94
+ view <em>#{args[:unsupported_view]}</em>
95
+ not supported for <em>#{error_cardname}</em>
96
+ </strong>
97
+ }
82
98
  end
83
99
 
84
100
  view :message, perms: :none, tags: :unknown_ok do |args|
@@ -87,46 +103,53 @@ format :html do
87
103
  end
88
104
  end
89
105
 
90
-
91
106
  view :missing do |args|
92
107
  return '' unless card.ok? :create # should this be moved into ok_view?
93
108
 
94
- opts = { remote: true, class: "slotter missing-#{ args[:denied_view] || args[:home_view]}" }
95
- opts[:path_opts] = { type: args[:type] } if args[:type]
109
+ link_opts = {
110
+ remote: true,
111
+ class: "slotter missing-#{args[:denied_view] || args[:home_view]}"
112
+ }
113
+ link_opts[:path_opts] = { type: args[:type] } if args[:type]
96
114
 
97
115
  wrap args do
98
- view_link "Add #{ fancy_title args[:title] }", :new, opts
116
+ view_link "Add #{fancy_title args[:title]}", :new, link_opts
99
117
  end
100
118
  end
101
119
 
102
- view :closed_missing, perms: :none do |args|
103
- %{<span class="faint"> #{ showname } </span>}
120
+ view :closed_missing, perms: :none do
121
+ %{<span class="faint"> #{showname} </span>}
104
122
  end
105
123
 
106
-
107
-
108
124
  view :conflict, error_code: 409 do |args|
109
- wrap args.merge( slot_class: 'error-view' ) do #ENGLISH below
125
+ actor_link = card_link card.last_action.act.actor.cardname
126
+ expanded_act = wrap(args) do
127
+ _render_act_expanded act: card.last_action.act, current_rev_nr: 0
128
+ end
129
+ wrap args.merge(slot_class: 'error-view') do # ENGLISH below
110
130
  alert 'warning' do
111
- %{<strong>Conflict!</strong><span class="new-current-revision-id">#{card.last_action_id}</span>
112
- <div>#{ card_link card.last_action.act.actor.cardname } has also been making changes.</div>
131
+ %{
132
+ <strong>Conflict!</strong>
133
+ <span class="new-current-revision-id">#{card.last_action_id}</span>
134
+ <div>#{actor_link} has also been making changes.</div>
113
135
  <div>Please examine below, resolve above, and re-submit.</div>
114
- #{ wrap do |args|
115
- _render_act_expanded act: card.last_action.act, current_rev_nr: 0
116
- end
117
- }
136
+ #{expanded_act}
118
137
  }
119
138
  end
120
139
  end
121
140
  end
122
141
 
123
142
  view :errors, perms: :none do |args|
124
-
125
143
  if card.errors.any?
126
- title = %{ Problems #{%{ with #{card.name} } unless card.name.blank?} }
127
- frame args.merge(panel_class: "panel panel-warning", title: title, hide: 'menu' ) do
144
+ title = 'Problems'
145
+ title += " with #{card.name}" unless card.name.blank?
146
+ frame_opts = { panel_class: 'panel panel-warning',
147
+ title: title, hide: 'menu' }
148
+ frame args.merge(frame_opts) do
128
149
  card.errors.map do |attrib, msg|
129
- msg = "<strong>#{attrib.to_s.upcase}:</strong> #{msg}" unless attrib == :abort
150
+ unless attrib == :abort
151
+ msg = "<strong>#{attrib.to_s.upcase}:</strong> #{msg}"
152
+ end
130
153
  alert 'warning', dismissible: true, alert_class: 'card-error-msg' do
131
154
  msg
132
155
  end
@@ -135,63 +158,70 @@ format :html do
135
158
  end
136
159
  end
137
160
 
138
- view :not_found do |args| #ug. bad name.
139
- sign_in_or_up_links = if !Auth.signed_in?
140
- %{<div>
141
- #{ card_link :signin, text: 'Sign in' } or
142
- #{ link_to 'Sign up', card_path('new/:signup') } to create it.
143
- </div>}
144
- end
161
+ view :not_found do |args| # ug. bad name.
162
+ sign_in_or_up_links =
163
+ if !Auth.signed_in?
164
+ signin_link = card_link :signin, text: 'Sign in'
165
+ signup_link = link_to 'Sign up', card_path('new/:signup')
166
+ %{<div>#{signin_link} or #{signup_link} to create it.</div>}
167
+ end
145
168
  frame args.merge(title: 'Not Found', optional_menu: :never) do
146
- %{
147
- <h2>Could not find #{card.name.present? ? "<em>#{card.name}</em>" : 'that'}.</h2>
148
- #{sign_in_or_up_links}
149
- }
169
+ card_label = card.name.present? ? "<em>#{card.name}</em>" : 'that'
170
+ %{<h2>Could not find #{card_label}.</h2> #{sign_in_or_up_links}}
150
171
  end
151
172
  end
152
173
 
153
174
  view :denial do |args|
154
- to_task = if task = args[:denied_task]
155
- %{to #{task} this.}
156
- else
157
- 'to do that.'
158
- end
175
+ task = args[:denied_task]
176
+ to_task = task ? "to #{task} this." : 'to do that.'
159
177
  if !focal?
160
- %{<span class="denied"><!-- Sorry, you don't have permission #{to_task} --></span>}
178
+ %{
179
+ <span class="denied">
180
+ <!-- Sorry, you don't have permission #{to_task} -->
181
+ </span>
182
+ }
161
183
  else
162
- frame args do #ENGLISH below
163
- message = case
164
- when task != :read && Card.config.read_only
165
- "We are currently in read-only mode. Please try again later."
166
- when Auth.signed_in?
167
- "You need permission #{to_task}"
168
- else
169
- or_signup = if Card.new(type_id: Card::SignupID).ok? :create
170
- "or #{ link_to 'sign up', card_url('new/:signup') }"
184
+ frame args do # ENGLISH below
185
+ message =
186
+ case
187
+ when task != :read && Card.config.read_only
188
+ 'We are currently in read-only mode. Please try again later.'
189
+ when Auth.signed_in?
190
+ "You need permission #{to_task}"
191
+ else
192
+ signin_link = link_to 'sign in', card_url(':signin')
193
+ or_signup_link =
194
+ if Card.new(type_id: Card::SignupID).ok? :create
195
+ 'or ' + link_to('sign up', card_url('new/:signup'))
196
+ end
197
+ Env.save_interrupted_action(request.env['REQUEST_URI'])
198
+ "Please #{signin_link} #{or_signup_link} #{to_task}"
171
199
  end
172
- Env.save_interrupted_action(request.env['REQUEST_URI'])
173
- "Please #{ link_to 'sign in', card_url(':signin') } #{or_signup} #{to_task}"
174
- end
175
200
 
176
- %{<h1>Sorry!</h1>\n<div>#{ message }</div>}
201
+ %{
202
+ <h1>Sorry!</h1>
203
+ <div>#{message}</div>
204
+ }
177
205
  end
178
206
  end
179
207
  end
180
208
 
181
-
182
- view :server_error do |args|
209
+ view :server_error do
183
210
  %{
184
- <body>
185
- <div class="dialog">
186
- <h1>Wagn Hitch :(</h1>
187
- <p>Server Error. Yuck, sorry about that.</p>
188
- <p><a href="http://www.wagn.org/new/Support_Ticket">Add a support ticket</a>
189
- to tell us more and follow the fix.</p>
190
- </div>
191
- </body>
211
+ <body>
212
+ <div class="dialog">
213
+ <h1>Wagn Hitch :(</h1>
214
+ <p>Server Error. Yuck, sorry about that.</p>
215
+ <p>
216
+ <a href="http://www.wagn.org/new/Support_Ticket">
217
+ Add a support ticket
218
+ </a>
219
+ to tell us more and follow the fix.
220
+ </p>
221
+ </div>
222
+ </body>
192
223
  }
193
224
  end
194
-
195
225
  end
196
226
 
197
227