card 1.16.9 → 1.16.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/db/migrate_core_cards/20120611203506_rails_inflection_updates.rb +3 -1
  4. data/db/seed/new/card_actions.yml +389 -557
  5. data/db/seed/new/card_acts.yml +595 -1
  6. data/db/seed/new/card_changes.yml +22595 -7526
  7. data/db/seed/new/card_references.yml +379 -407
  8. data/db/seed/new/cards.yml +1694 -2072
  9. data/db/seed/test/fixtures/card_actions.yml +966 -1102
  10. data/db/seed/test/fixtures/card_acts.yml +1017 -399
  11. data/db/seed/test/fixtures/card_changes.yml +24750 -9681
  12. data/db/seed/test/fixtures/card_references.yml +603 -631
  13. data/db/seed/test/fixtures/cards.yml +2293 -2671
  14. data/lib/card/set.rb +1 -1
  15. data/mod/01_core/set/all/content.rb +14 -12
  16. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +1 -1
  17. data/mod/05_standard/set/abstract/attachment.rb +9 -9
  18. data/mod/05_standard/set/all/rich_html/content.rb +115 -103
  19. data/mod/05_standard/set/type/file.rb +1 -1
  20. data/tmpsets/set/mod001-01_core/all/active_card.rb +2 -1
  21. data/tmpsets/set/mod001-01_core/all/collection.rb +3 -3
  22. data/tmpsets/set/mod001-01_core/all/content.rb +2 -1
  23. data/tmpsets/set/mod001-01_core/all/erb.rb +2 -1
  24. data/tmpsets/set/mod001-01_core/all/fetch.rb +169 -93
  25. data/tmpsets/set/mod001-01_core/all/haml.rb +2 -1
  26. data/tmpsets/set/mod001-01_core/all/initialize.rb +11 -23
  27. data/tmpsets/set/mod001-01_core/all/name.rb +130 -80
  28. data/tmpsets/set/mod001-01_core/all/pattern.rb +2 -1
  29. data/tmpsets/set/mod001-01_core/all/permissions.rb +2 -1
  30. data/tmpsets/set/mod001-01_core/all/phases.rb +95 -96
  31. data/tmpsets/set/mod001-01_core/all/references.rb +2 -1
  32. data/tmpsets/set/mod001-01_core/all/rules.rb +2 -1
  33. data/tmpsets/set/mod001-01_core/all/states.rb +2 -1
  34. data/tmpsets/set/mod001-01_core/all/templating.rb +2 -1
  35. data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +85 -60
  36. data/tmpsets/set/mod001-01_core/all/trash.rb +16 -13
  37. data/tmpsets/set/mod001-01_core/all/type.rb +5 -25
  38. data/tmpsets/set/mod001-01_core/all/utils.rb +2 -1
  39. data/tmpsets/set/mod001-01_core/all/view_cache.rb +2 -1
  40. data/tmpsets/set/mod002-01_history/all/actions.rb +2 -1
  41. data/tmpsets/set/mod002-01_history/all/content_history.rb +7 -4
  42. data/tmpsets/set/mod002-01_history/all/history.rb +119 -83
  43. data/tmpsets/set/mod003-02_basic_types/all/all_css.rb +2 -1
  44. data/tmpsets/set/mod003-02_basic_types/all/all_csv.rb +2 -1
  45. data/tmpsets/set/mod003-02_basic_types/all/all_js.rb +2 -1
  46. data/tmpsets/set/mod003-02_basic_types/all/base.rb +52 -50
  47. data/tmpsets/set/mod003-02_basic_types/all/file.rb +2 -1
  48. data/tmpsets/set/mod003-02_basic_types/all/json.rb +2 -1
  49. data/tmpsets/set/mod003-02_basic_types/all/rss.rb +2 -1
  50. data/tmpsets/set/mod003-02_basic_types/all/text.rb +2 -1
  51. data/tmpsets/set/mod003-02_basic_types/type/html.rb +2 -1
  52. data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +2 -1
  53. data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +10 -1
  54. data/tmpsets/set/mod004-03_machines/right/machine_input.rb +2 -1
  55. data/tmpsets/set/mod004-03_machines/right/machine_output.rb +2 -1
  56. data/tmpsets/set/mod004-03_machines/self/script_ace.rb +2 -1
  57. data/tmpsets/set/mod004-03_machines/self/script_card_menu.rb +2 -1
  58. data/tmpsets/set/mod004-03_machines/self/script_html5shiv_printshiv.rb +2 -1
  59. data/tmpsets/set/mod004-03_machines/self/script_jquery.rb +2 -1
  60. data/tmpsets/set/mod004-03_machines/self/script_jquery_helper.rb +2 -1
  61. data/tmpsets/set/mod004-03_machines/self/script_slot.rb +2 -1
  62. data/tmpsets/set/mod004-03_machines/self/script_tinymce.rb +2 -1
  63. data/tmpsets/set/mod004-03_machines/self/style_bootstrap_compatible.rb +2 -1
  64. data/tmpsets/set/mod004-03_machines/self/style_cards.rb +2 -1
  65. data/tmpsets/set/mod004-03_machines/self/style_jquery_ui_smoothness.rb +2 -1
  66. data/tmpsets/set/mod004-03_machines/type/coffee_script.rb +2 -1
  67. data/tmpsets/set/mod004-03_machines/type/css.rb +2 -1
  68. data/tmpsets/set/mod004-03_machines/type/java_script.rb +2 -1
  69. data/tmpsets/set/mod004-03_machines/type/scss.rb +2 -1
  70. data/tmpsets/set/mod004-03_machines/type/skin.rb +2 -1
  71. data/tmpsets/set/mod005-04_settings/abstract/permission.rb +2 -1
  72. data/tmpsets/set/mod005-04_settings/right/add_help.rb +2 -1
  73. data/tmpsets/set/mod005-04_settings/right/comment.rb +2 -1
  74. data/tmpsets/set/mod005-04_settings/right/create.rb +2 -1
  75. data/tmpsets/set/mod005-04_settings/right/default.rb +2 -1
  76. data/tmpsets/set/mod005-04_settings/right/delete.rb +2 -1
  77. data/tmpsets/set/mod005-04_settings/right/help.rb +2 -1
  78. data/tmpsets/set/mod005-04_settings/right/read.rb +2 -1
  79. data/tmpsets/set/mod005-04_settings/right/script.rb +2 -1
  80. data/tmpsets/set/mod005-04_settings/right/structure.rb +2 -1
  81. data/tmpsets/set/mod005-04_settings/right/style.rb +2 -1
  82. data/tmpsets/set/mod005-04_settings/right/update.rb +2 -1
  83. data/tmpsets/set/mod005-04_settings/self/accountable.rb +2 -1
  84. data/tmpsets/set/mod005-04_settings/self/add_help.rb +2 -1
  85. data/tmpsets/set/mod005-04_settings/self/autoname.rb +2 -1
  86. data/tmpsets/set/mod005-04_settings/self/captcha.rb +2 -1
  87. data/tmpsets/set/mod005-04_settings/self/create.rb +2 -1
  88. data/tmpsets/set/mod005-04_settings/self/default.rb +2 -1
  89. data/tmpsets/set/mod005-04_settings/self/delete.rb +2 -1
  90. data/tmpsets/set/mod005-04_settings/self/help.rb +2 -1
  91. data/tmpsets/set/mod005-04_settings/self/input.rb +2 -1
  92. data/tmpsets/set/mod005-04_settings/self/layout.rb +2 -1
  93. data/tmpsets/set/mod005-04_settings/self/on_create.rb +2 -1
  94. data/tmpsets/set/mod005-04_settings/self/on_delete.rb +2 -1
  95. data/tmpsets/set/mod005-04_settings/self/on_update.rb +2 -1
  96. data/tmpsets/set/mod005-04_settings/self/options.rb +2 -1
  97. data/tmpsets/set/mod005-04_settings/self/options_label.rb +2 -1
  98. data/tmpsets/set/mod005-04_settings/self/read.rb +2 -1
  99. data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +2 -1
  100. data/tmpsets/set/mod005-04_settings/self/script.rb +2 -1
  101. data/tmpsets/set/mod005-04_settings/self/structure.rb +2 -1
  102. data/tmpsets/set/mod005-04_settings/self/style.rb +2 -1
  103. data/tmpsets/set/mod005-04_settings/self/table_of_contents.rb +2 -1
  104. data/tmpsets/set/mod005-04_settings/self/thanks.rb +2 -1
  105. data/tmpsets/set/mod005-04_settings/self/update.rb +2 -1
  106. data/tmpsets/set/mod005-04_settings/type/setting.rb +2 -1
  107. data/tmpsets/set/mod006-05_email/all/email_html.rb +2 -1
  108. data/tmpsets/set/mod006-05_email/all/email_text.rb +2 -1
  109. data/tmpsets/set/mod006-05_email/all/follow.rb +2 -1
  110. data/tmpsets/set/mod006-05_email/all/notify.rb +2 -1
  111. data/tmpsets/set/mod006-05_email/all/observer.rb +2 -1
  112. data/tmpsets/set/mod006-05_email/right/bcc.rb +2 -1
  113. data/tmpsets/set/mod006-05_email/right/cc.rb +2 -1
  114. data/tmpsets/set/mod006-05_email/right/follow.rb +2 -1
  115. data/tmpsets/set/mod006-05_email/right/follow_fields.rb +2 -1
  116. data/tmpsets/set/mod006-05_email/right/followers.rb +7 -6
  117. data/tmpsets/set/mod006-05_email/right/following.rb +3 -2
  118. data/tmpsets/set/mod006-05_email/right/from.rb +2 -1
  119. data/tmpsets/set/mod006-05_email/right/html_message.rb +2 -1
  120. data/tmpsets/set/mod006-05_email/right/to.rb +2 -1
  121. data/tmpsets/set/mod006-05_email/self/always.rb +2 -1
  122. data/tmpsets/set/mod006-05_email/self/created.rb +2 -1
  123. data/tmpsets/set/mod006-05_email/self/edited.rb +2 -1
  124. data/tmpsets/set/mod006-05_email/self/follow.rb +2 -1
  125. data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +2 -1
  126. data/tmpsets/set/mod006-05_email/self/never.rb +2 -1
  127. data/tmpsets/set/mod006-05_email/type/email_template.rb +2 -1
  128. data/tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb +3 -2
  129. data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +22 -9
  130. data/tmpsets/set/mod007-05_standard/all/account.rb +2 -1
  131. data/tmpsets/set/mod007-05_standard/all/comment.rb +2 -1
  132. data/tmpsets/set/mod007-05_standard/all/error.rb +2 -1
  133. data/tmpsets/set/mod007-05_standard/all/event_viz.rb +2 -1
  134. data/tmpsets/set/mod007-05_standard/all/links.rb +2 -1
  135. data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +3 -2
  136. data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +2 -1
  137. data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +23 -12
  138. data/tmpsets/set/mod007-05_standard/all/rich_html/header.rb +2 -1
  139. data/tmpsets/set/mod007-05_standard/all/rich_html/menu.rb +3 -2
  140. data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +2 -1
  141. data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -1
  142. data/tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb +2 -1
  143. data/tmpsets/set/mod007-05_standard/right/account.rb +7 -6
  144. data/tmpsets/set/mod007-05_standard/right/discussion.rb +2 -1
  145. data/tmpsets/set/mod007-05_standard/right/email.rb +2 -1
  146. data/tmpsets/set/mod007-05_standard/right/password.rb +2 -1
  147. data/tmpsets/set/mod007-05_standard/right/salt.rb +2 -1
  148. data/tmpsets/set/mod007-05_standard/right/stats.rb +2 -1
  149. data/tmpsets/set/mod007-05_standard/right/status.rb +2 -1
  150. data/tmpsets/set/mod007-05_standard/right/token.rb +2 -1
  151. data/tmpsets/set/mod007-05_standard/right/when_created.rb +2 -1
  152. data/tmpsets/set/mod007-05_standard/right/when_last_edited.rb +2 -1
  153. data/tmpsets/set/mod007-05_standard/rstar/rules.rb +2 -1
  154. data/tmpsets/set/mod007-05_standard/self/account_links.rb +2 -1
  155. data/tmpsets/set/mod007-05_standard/self/alerts.rb +2 -1
  156. data/tmpsets/set/mod007-05_standard/self/all.rb +2 -1
  157. data/tmpsets/set/mod007-05_standard/self/foot.rb +2 -1
  158. data/tmpsets/set/mod007-05_standard/self/head.rb +2 -2
  159. data/tmpsets/set/mod007-05_standard/self/navbox.rb +2 -1
  160. data/tmpsets/set/mod007-05_standard/self/now.rb +2 -1
  161. data/tmpsets/set/mod007-05_standard/self/recent.rb +2 -1
  162. data/tmpsets/set/mod007-05_standard/self/search.rb +2 -1
  163. data/tmpsets/set/mod007-05_standard/self/signin.rb +45 -36
  164. data/tmpsets/set/mod007-05_standard/self/stats.rb +2 -1
  165. data/tmpsets/set/mod007-05_standard/self/version.rb +2 -1
  166. data/tmpsets/set/mod007-05_standard/type/basic.rb +2 -1
  167. data/tmpsets/set/mod007-05_standard/type/cardtype.rb +2 -1
  168. data/tmpsets/set/mod007-05_standard/type/date.rb +2 -1
  169. data/tmpsets/set/mod007-05_standard/type/file.rb +11 -3
  170. data/tmpsets/set/mod007-05_standard/type/image.rb +2 -1
  171. data/tmpsets/set/mod007-05_standard/type/layout_type.rb +2 -1
  172. data/tmpsets/set/mod007-05_standard/type/number.rb +2 -1
  173. data/tmpsets/set/mod007-05_standard/type/phrase.rb +2 -1
  174. data/tmpsets/set/mod007-05_standard/type/search_type.rb +70 -64
  175. data/tmpsets/set/mod007-05_standard/type/session.rb +2 -1
  176. data/tmpsets/set/mod007-05_standard/type/set.rb +2 -1
  177. data/tmpsets/set/mod007-05_standard/type/signup.rb +96 -64
  178. data/tmpsets/set/mod007-05_standard/type/toggle.rb +2 -1
  179. data/tmpsets/set/mod007-05_standard/type/uri.rb +2 -1
  180. data/tmpsets/set/mod007-05_standard/type/user.rb +50 -40
  181. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/form.rb +2 -1
  182. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +2 -1
  183. data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb +2 -1
  184. data/tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb +2 -1
  185. data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_cards.rb +2 -1
  186. data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_js.rb +2 -1
  187. data/tmpsets/set/mod008-06_bootstrap/self/bootswatch_shared.rb +2 -1
  188. data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_css.rb +2 -1
  189. data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_js.rb +2 -1
  190. metadata +2 -2
@@ -481,7 +481,7 @@ EOF
481
481
 
482
482
  def attachment name, args
483
483
  include Abstract::Attachment
484
- set_specific_attributes name, :load_from_mod, :cached_upload,
484
+ set_specific_attributes name, :load_from_mod, :action_id_of_cached_upload,
485
485
  "remote_#{name}_url".to_sym
486
486
  uploader_class = args[:uploader] || FileUploader
487
487
  mount_uploader name, uploader_class
@@ -1,10 +1,10 @@
1
1
  ::Card.error_codes[:conflict] = [:conflict, 409]
2
2
 
3
3
  def content
4
- db_content or (new_card? && template.db_content)
4
+ db_content || (new_card? && template.db_content)
5
5
  end
6
6
 
7
- def content=(value)
7
+ def content= value
8
8
  self.db_content = value
9
9
  end
10
10
 
@@ -13,7 +13,7 @@ def raw_content
13
13
  end
14
14
 
15
15
  format do
16
- def chunk_list #override to customize by set
16
+ def chunk_list # override to customize by set
17
17
  :default
18
18
  end
19
19
  end
@@ -23,11 +23,11 @@ def label
23
23
  end
24
24
 
25
25
  def creator
26
- Card[ creator_id ]
26
+ Card[creator_id]
27
27
  end
28
28
 
29
29
  def updater
30
- Card[ updater_id ]
30
+ Card[updater_id]
31
31
  end
32
32
 
33
33
  def clean_html?
@@ -38,25 +38,27 @@ def history?
38
38
  false
39
39
  end
40
40
 
41
- def save_content_draft content
41
+ def save_content_draft _content
42
42
  clear_drafts
43
43
  end
44
44
 
45
45
  def clear_drafts
46
- drafts.created_by(Card::Auth.current_id).each do |draft|
47
- draft.delete
48
- end
46
+ drafts.created_by(Card::Auth.current_id).each(&:delete)
47
+ end
48
+
49
+ def last_draft_content
50
+ drafts.last.card_changes.last.value
49
51
  end
50
52
 
51
- event :save_draft, before: :store, on: :update, when: proc{ |c| Env.params['draft'] == 'true' } do
53
+ event :save_draft,
54
+ before: :store, on: :update,
55
+ when: proc { Env.params['draft'] == 'true' } do
52
56
  save_content_draft content
53
57
  abort :success
54
58
  end
55
59
 
56
-
57
60
  event :set_default_content, on: :create, before: :approve do
58
61
  if !db_content_changed? && template && template.db_content.present?
59
62
  self.db_content = template.db_content
60
63
  end
61
64
  end
62
-
@@ -41,7 +41,7 @@ $.extend wagn,
41
41
  # for file as a subcard in a form,
42
42
  # excess parameters are inlcuded in the request which cause errors.
43
43
  # only the file, type_id and attachment_card_name are needed
44
- # attachment_card_name is the original card name,
44
+ # attachment_card_name is the original card name,
45
45
  # ex: card[subcards][+logo][image], card[file]
46
46
  $(fileupload).bind 'fileuploadsubmit', (e,data) ->
47
47
  $_this = $(this)
@@ -24,7 +24,7 @@ event :upload_attachment, before: :validate_name, on: :save, when: proc { |c| c.
24
24
  end
25
25
 
26
26
  event :assign_attachment_on_create, after: :prepare, on: :create, when: proc { |c| c.save_preliminary_upload? } do
27
- if (action = Card::Action.fetch(@cached_upload))
27
+ if (action = Card::Action.fetch(@action_id_of_cached_upload))
28
28
  upload_cache_card.selected_action_id = action.id
29
29
  upload_cache_card.select_file_revision
30
30
  assign_attachment upload_cache_card.attachment.file, action.comment
@@ -33,7 +33,7 @@ end
33
33
 
34
34
  event :assign_attachment_on_update, after: :prepare, on: :update,
35
35
  when: proc { |c| c.save_preliminary_upload? } do
36
- if (action = Card::Action.fetch(@cached_upload))
36
+ if (action = Card::Action.fetch(@action_id_of_cached_upload))
37
37
  uploaded_file =
38
38
  with_selected_action_id(action.id) do
39
39
  attachment.file
@@ -62,7 +62,7 @@ event :save_original_filename, after: :validate_name, when: proc {|c| !c.prelimi
62
62
  end
63
63
 
64
64
  event :delete_cached_upload_file_on_create, after: :extend, on: :create, when: proc { |c| c.save_preliminary_upload? } do
65
- if (action = Card::Action.fetch(@cached_upload))
65
+ if (action = Card::Action.fetch(@action_id_of_cached_upload))
66
66
  upload_cache_card.delete_files_for_action action
67
67
  action.delete
68
68
  end
@@ -70,7 +70,7 @@ event :delete_cached_upload_file_on_create, after: :extend, on: :create, when: p
70
70
  end
71
71
 
72
72
  event :delete_cached_upload_file_on_update, after: :extend, on: :update, when: proc { |c| c.save_preliminary_upload? } do
73
- if (action = Card::Action.fetch(@cached_upload))
73
+ if (action = Card::Action.fetch(@action_id_of_cached_upload))
74
74
  delete_files_for_action action
75
75
  action.delete
76
76
  end
@@ -99,7 +99,7 @@ def preliminary_upload?
99
99
  end
100
100
 
101
101
  def save_preliminary_upload?
102
- @cached_upload.present?
102
+ @action_id_of_cached_upload.present?
103
103
  end
104
104
 
105
105
  def attachment_changed?
@@ -116,12 +116,12 @@ def upload_cache_card
116
116
  end
117
117
 
118
118
  # action id of the cached upload
119
- def cached_upload= value
120
- @cached_upload = value
119
+ def action_id_of_cached_upload= value
120
+ @action_id_of_cached_upload = value
121
121
  end
122
122
 
123
- def cached_upload
124
- @cached_upload
123
+ def action_id_of_cached_upload
124
+ @action_id_of_cached_upload
125
125
  end
126
126
 
127
127
  def load_from_mod= value
@@ -3,15 +3,14 @@ def show_comment_box_in_related?
3
3
  end
4
4
 
5
5
  format :html do
6
-
7
6
  def show view, args
8
7
  if show_layout?
9
8
  args.merge! view: view if view
10
9
  @main_opts = args
11
- self.render :layout
10
+ render :layout
12
11
  else
13
12
  view ||= args[:home_view] || :open
14
- @inclusion_opts = args.delete(:items)
13
+ @inclusion_opts = (args[:items] || {}).clone
15
14
  render view, args
16
15
  end
17
16
  end
@@ -22,17 +21,17 @@ format :html do
22
21
 
23
22
  view :layout, perms: :none do |args|
24
23
  output [
25
- process_content(get_layout_content, content_opts: { chunk_list: :references }),
24
+ process_content(get_layout_content, content_opts:
25
+ { chunk_list: :references }),
26
26
  _render_modal_slot(args)
27
27
  ]
28
28
  end
29
29
 
30
-
31
30
  view :content do |args|
32
31
  wrap args.reverse_merge(slot_class: 'card-content') do
33
32
  [
34
- _optional_render( :menu, args, :hide ),
35
- _render_core( args )
33
+ _optional_render(:menu, args, :hide),
34
+ _render_core(args)
36
35
  ]
37
36
  end
38
37
  end
@@ -41,9 +40,9 @@ format :html do
41
40
  wrap args.reverse_merge(slot_class: 'card-content panel panel-default') do
42
41
  wrap_with :div, class: 'panel-body' do
43
42
  [
44
- _optional_render( :menu, args, :hide ),
45
- _render_core( args )
46
- ]*"\n"
43
+ _optional_render(:menu, args, :hide),
44
+ _render_core(args)
45
+ ] * "\n"
47
46
  end
48
47
  end
49
48
  end
@@ -51,10 +50,10 @@ format :html do
51
50
  view :titled, tags: :comment do |args|
52
51
  wrap args do
53
52
  [
54
- _optional_render( :menu, args ),
55
- _render_header( args ),
56
- wrap_body( content: true ) { _render_core args },
57
- optional_render( :comment_box, args )
53
+ _optional_render(:menu, args),
54
+ _render_header(args),
55
+ wrap_body(content: true) { _render_core args },
56
+ optional_render(:comment_box, args)
58
57
  ]
59
58
  end
60
59
  end
@@ -62,9 +61,9 @@ format :html do
62
61
  view :labeled do |args|
63
62
  wrap args do
64
63
  [
65
- _optional_render( :menu, args ),
66
- "<label>#{ _render_title args }</label>",
67
- wrap_body( body_class: 'closed-content', content: true ) do
64
+ _optional_render(:menu, args),
65
+ "<label>#{_render_title args}</label>",
66
+ wrap_body(body_class: 'closed-content', content: true) do
68
67
  _render_closed_content args
69
68
  end
70
69
  ]
@@ -73,23 +72,23 @@ format :html do
73
72
 
74
73
  view :title do |args|
75
74
  title = fancy_title args[:title], args[:title_class]
76
- title = _optional_render( :title_editable, args, :hide) ||
77
- _optional_render( :title_link, args.merge( title_ready: title ), :hide ) ||
78
- title
75
+ title =
76
+ _optional_render(:title_editable, args, :hide) ||
77
+ _optional_render(:title_link, args.merge(title_ready: title), :hide) ||
78
+ title
79
79
  add_name_context
80
80
  title
81
81
  end
82
82
 
83
83
  view :title_link do |args|
84
- card_link card.cardname, text: ( args[:title_ready] || showname(args[:title]) )
84
+ title_text = args[:title_ready] || showname(args[:title])
85
+ card_link card.cardname, text: title_text
85
86
  end
86
87
 
87
- view :type_info do |args|
88
- %{
89
- <span class="type-info pull-right">
90
- #{card_link(card.type_name, text: "#{card.type_name}", class: 'navbar-link')}
91
- </span>
92
- }.html_safe
88
+ view :type_info do
89
+ link_args = { text: "#{card.type_name}", class: 'navbar-link' }
90
+ link = card_link card.type_name, link_args
91
+ %{<span class="type-info pull-right">#{link}</span>}.html_safe
93
92
  end
94
93
 
95
94
  view :title_editable do |args|
@@ -98,145 +97,158 @@ format :html do
98
97
  end
99
98
  res = links.shift
100
99
  links.each_with_index do |link, index|
101
- res += card_link card.cardname.parts[0..index+1].join('+'), text: glyphicon('plus','header-icon')
100
+ name = card.cardname.parts[0..index + 1].join '+'
101
+ res += card_link name, text: glyphicon('plus', 'header-icon')
102
102
  res += link
103
103
  end
104
104
  res += ' '
105
- res.concat view_link(glyphicon('edit','header-icon'),:edit_name, class: 'slotter', 'data-toggle'=>'tooltip', title: 'edit name')
106
- res.concat _optional_render(:type_link,args,:show)
105
+ res.concat view_link(
106
+ glyphicon('edit', 'header-icon'),
107
+ :edit_name,
108
+ class: 'slotter', 'data-toggle' => 'tooltip', title: 'edit name'
109
+ )
110
+ res.concat _optional_render(:type_link, args, :show)
107
111
  end
108
112
 
109
113
  view :open, tags: :comment do |args|
110
114
  args[:optional_toggle] ||= main? ? :hide : :show
111
115
  frame args.merge(content: true) do
112
116
  [
113
- _render_open_content( args ),
114
- optional_render( :comment_box, args )
117
+ _render_open_content(args),
118
+ optional_render(:comment_box, args)
115
119
  ]
116
120
  end
117
121
  end
118
122
 
119
-
120
-
121
- =begin
122
- view :anchor, perms: :none, tags: :unknown_ok do |args|
123
- %{ <a id="#{card.cardname.url_key}" name="#{card.cardname.url_key}"></a> }
124
- end
125
- =end
123
+ # view :anchor, perms: :none, tags: :unknown_ok do |args|
124
+ # %{ <a id="#{card.cardname.url_key}" name="#{card.cardname.url_key}"></a> }
125
+ # end
126
126
 
127
127
  view :type do |args|
128
128
  klasses = ['cardtype']
129
- klass = args[:type_class] and klasses << klass
129
+ klass = args[:type_class]
130
+ klasses << klass if klass
130
131
  card_link card.type_card.name, class: klasses
131
132
  end
132
133
 
133
134
  view :closed do |args|
134
- frame args.reverse_merge(content: true, body_class: 'closed-content', toggle_mode: :close, optional_toggle: :show, optional_toolbar: :hide ) do
135
+ frame args.reverse_merge(
136
+ content: true,
137
+ body_class: 'closed-content',
138
+ toggle_mode: :close,
139
+ optional_toggle: :show,
140
+ optional_toolbar: :hide
141
+ ) do
135
142
  _optional_render :closed_content, args
136
143
  end
137
144
  end
138
145
 
139
-
140
146
  view :change do |args|
141
147
  args[:optional_title_link] = :show
142
148
  wrap args do
143
149
  [
144
- _optional_render( :title, args ),
145
- _optional_render( :menu, args, :hide ),
146
- _optional_render( :last_action, args )
150
+ _optional_render(:title, args),
151
+ _optional_render(:menu, args, :hide),
152
+ _optional_render(:last_action, args)
147
153
  ]
148
154
  end
149
155
  end
150
156
 
151
157
  def current_set_card
152
158
  set_name = params[:current_set]
153
- set_name ||= "#{card.name}+*type" if card.known? && card.type_id==Card::CardtypeID
159
+ if card.known? && card.type_id == Card::CardtypeID
160
+ set_name ||= "#{card.name}+*type"
161
+ end
154
162
  set_name ||= "#{card.name}+*self"
155
163
  Card.fetch(set_name)
156
164
  end
157
165
 
158
-
159
166
  view :related do |args|
160
167
  if args[:related_card]
161
168
  frame args.merge(optional_toolbar: :show) do
162
- nest( args[:related_card], args[:related_args])
169
+ nest(args[:related_card], args[:related_args])
163
170
  end
164
171
  end
165
172
  end
166
173
 
167
174
  def default_related_args args
168
- if rparams = args[:related] || params[:related]
169
- rcard = rparams[:card] || begin
170
- rcardname = rparams[:name].to_name.to_absolute_name( card.cardname)
171
- Card.fetch rcardname, new: {}
172
- end
173
-
174
- #subheader = with_name_context(card.name) { showname rcard.name }
175
- subheader = with_name_context(card.name) { subformat(rcard)._render_title(args) }
176
- add_name_context card.name
177
- nest_args = ( rparams[:slot] || {} ).deep_symbolize_keys.reverse_merge(
178
- view: ( rparams[:view] || :open ),
179
- optional_header: :hide,
180
- optional_menu: :show,
181
- subheader: subheader,
182
- optional_toggle: :hide,
183
- optional_help: :show,
184
- parent: card,
185
- subframe: true,
186
- subslot: true
187
- )
188
- nest_args[:optional_comment_box] = :show if rcard.show_comment_box_in_related?
175
+ rparams = args[:related] || params[:related]
176
+ return unless rparams
177
+ rcard = rparams[:card] || begin
178
+ rcardname = rparams[:name].to_name.to_absolute_name(card.cardname)
179
+ Card.fetch rcardname, new: {}
180
+ end
189
181
 
190
- args[:related_args] = nest_args
191
- args[:related_card] = rcard
182
+ subheader = with_name_context(card.name) do
183
+ subformat(rcard)._render_title(args)
192
184
  end
185
+ add_name_context card.name
186
+ nest_args = (rparams[:slot] || {}).deep_symbolize_keys.reverse_merge(
187
+ view: (rparams[:view] || :open),
188
+ optional_header: :hide,
189
+ optional_menu: :show,
190
+ subheader: subheader,
191
+ optional_toggle: :hide,
192
+ optional_help: :show,
193
+ parent: card,
194
+ subframe: true,
195
+ subslot: true
196
+ )
197
+ if rcard.show_comment_box_in_related?
198
+ nest_args[:optional_comment_box] = :show
199
+ end
200
+ args[:related_args] = nest_args
201
+ args[:related_card] = rcard
193
202
  end
194
203
 
195
-
196
-
197
204
  view :help, tags: :unknown_ok do |args|
198
- text = if args[:help_text]
199
- args[:help_text]
200
- else
201
- setting = card.new_card? ? [ :add_help, { fallback: :help } ] : :help
202
- if help_card = card.rule_card( *setting ) and help_card.ok? :read
205
+ text = args[:help_text] || begin
206
+ setting = card.new_card? ? [:add_help, { fallback: :help }] : :help
207
+ help_card = card.rule_card(*setting)
208
+ if help_card && help_card.ok?(:read)
203
209
  with_inclusion_mode :normal do
204
- process_content _render_raw( args.merge structure: help_card.name ), content_opts: { chunk_list: :references }
205
- # render help card with current card's format so current card's context is used in help card inclusions
210
+ raw_help_content = _render_raw args.merge(structure: help_card.name)
211
+ process_content raw_help_content, content_opts:
212
+ { chunk_list: :references }
213
+ # render help card with current card's format
214
+ # so current card's context is used in help card inclusions
206
215
  end
207
216
  end
208
217
  end
209
- klass = [args[:help_class], 'help-text'].compact*' '
218
+ klass = [args[:help_class], 'help-text'].compact * ' '
210
219
  %{<div class="#{klass}">#{raw text}</div>} if text
211
220
  end
212
221
 
222
+ view :last_action do
223
+ act = card.last_act
224
+ return unless act
225
+ action = act.action_on card.id
226
+ return unless action
227
+ action_verb =
228
+ case action.action_type
229
+ when :create then 'added'
230
+ when :delete then 'deleted'
231
+ else
232
+ link_to(
233
+ 'edited',
234
+ path(view: :history),
235
+ class: 'last-edited', rel: 'nofollow'
236
+ )
237
+ end
213
238
 
214
- view :last_action do |args|
215
- if act = card.last_act and action = act.action_on(card.id)
216
- action_verb =
217
- case action.action_type
218
- when :create then 'added'
219
- when :delete then 'deleted'
220
- else
221
- link_to('edited', path(view: :history), class: 'last-edited', rel: 'nofollow')
222
- end
223
-
224
- %{
225
- <span class="last-update">
226
- #{ action_verb }
227
- #{ _render_acted_at }
228
- ago by
229
- #{ subformat(card.last_actor)._render_link }
230
- </span>
231
- }
232
- end
239
+ %{
240
+ <span class="last-update">
241
+ #{action_verb} #{_render_acted_at} ago by
242
+ #{subformat(card.last_actor)._render_link}
243
+ </span>
244
+ }
233
245
  end
234
246
 
235
247
  private
236
248
 
237
249
  def fancy_title title=nil, title_class=nil
238
- raw %{<span class="card-title#{" #{title_class}"if title_class}">#{ showname(title).to_name.parts.join %{<span class="joint">+</span>} }</span>}
250
+ klasses = ['card-title', title_class].compact * ' '
251
+ title = showname(title).to_name.parts.join %{<span class="joint">+</span>}
252
+ raw %{<span class="#{klasses}">#{title}</span>}
239
253
  end
240
254
  end
241
-
242
-