card 1.15.7 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +3 -2
  4. data/config/initializers/inflections.rb +1 -1
  5. data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +0 -1
  6. data/db/migrate_core_cards/20150601133433_add_recent_setting_session_card.rb +12 -0
  7. data/db/migrate_core_cards/20150610171702_add_debugger_session_card.rb +11 -0
  8. data/db/migrate_core_cards/20150611203506_rails_inflection_updates.rb +82 -0
  9. data/db/migrate_core_cards/20150627205133_fix_script_bootstrap_card_type.rb +7 -0
  10. data/db/migrate_core_cards/20150702130543_remove_edit_toolbar_pinned.rb +9 -0
  11. data/db/schema.rb +81 -81
  12. data/db/seed/new/card_actions.yml +12581 -1647
  13. data/db/seed/new/card_acts.yml +1 -1
  14. data/db/seed/new/card_changes.yml +39326 -7569
  15. data/db/seed/new/card_references.yml +518 -455
  16. data/db/seed/new/cards.yml +1547 -1291
  17. data/db/seed/test/fixtures/card_actions.yml +13700 -2717
  18. data/db/seed/test/fixtures/card_acts.yml +314 -272
  19. data/db/seed/test/fixtures/card_changes.yml +45409 -13573
  20. data/db/seed/test/fixtures/card_references.yml +1223 -1125
  21. data/db/seed/test/fixtures/cards.yml +2694 -2433
  22. data/db/seed/test/fixtures/file1.txt +1 -0
  23. data/db/seed/test/fixtures/file2.txt +1 -0
  24. data/db/version_core_cards.txt +1 -1
  25. data/lib/card.rb +23 -13
  26. data/lib/card/auth.rb +6 -6
  27. data/lib/card/cache.rb +24 -5
  28. data/lib/card/env.rb +10 -10
  29. data/lib/card/format.rb +29 -12
  30. data/lib/card/log.rb +5 -3
  31. data/lib/card/migration.rb +17 -41
  32. data/lib/card/name.rb +12 -0
  33. data/lib/card/reference.rb +11 -12
  34. data/lib/card/set.rb +59 -6
  35. data/lib/card/simplecov_helper.rb +6 -1
  36. data/lib/card/spec_helper.rb +3 -2
  37. data/lib/card/view_cache.rb +77 -0
  38. data/lib/cardio.rb +30 -22
  39. data/mod/01_core/format/html_format.rb +17 -9
  40. data/mod/01_core/layout/blank.html +1 -1
  41. data/mod/01_core/layout/default.html +6 -16
  42. data/mod/01_core/layout/modal.html +9 -0
  43. data/mod/01_core/layout/noside.html +5 -12
  44. data/mod/01_core/layout/simple.html +1 -1
  45. data/mod/01_core/set/all/collection.rb +57 -5
  46. data/mod/01_core/set/all/content.rb +5 -7
  47. data/mod/01_core/set/all/name.rb +8 -10
  48. data/mod/01_core/set/all/permissions.rb +1 -2
  49. data/mod/01_core/set/all/phases.rb +5 -13
  50. data/mod/01_core/set/all/references.rb +10 -10
  51. data/mod/01_core/set/all/rules.rb +2 -2
  52. data/mod/01_core/set/all/tracked_attributes.rb +5 -3
  53. data/mod/01_core/set/all/utils.rb +79 -9
  54. data/mod/01_core/set/all/view_cache.rb +9 -0
  55. data/mod/01_core/spec/format/html_format_spec.rb +2 -2
  56. data/mod/01_core/spec/set/all/collection_spec.rb +1 -1
  57. data/mod/01_history/lib/card/act.rb +3 -1
  58. data/mod/01_history/lib/card/action.rb +20 -12
  59. data/mod/01_history/lib/card/change.rb +12 -8
  60. data/mod/01_history/set/all/actions.rb +2 -2
  61. data/mod/01_history/set/all/content_history.rb +3 -2
  62. data/mod/01_history/set/all/history.rb +57 -19
  63. data/mod/02_basic_types/set/all/rss.rb +5 -6
  64. data/mod/{05_standard → 02_basic_types}/set/type/html.rb +4 -3
  65. data/mod/02_basic_types/set/type/plain_text.rb +1 -1
  66. data/mod/02_basic_types/set/type/pointer.rb +7 -4
  67. data/mod/02_basic_types/spec/set/type/pointer_spec.rb +21 -17
  68. data/mod/03_machines/lib/card/machine.rb +33 -31
  69. data/mod/03_machines/lib/javascript/script_card_menu.js.coffee +2 -10
  70. data/mod/03_machines/lib/javascript/wagn.js.coffee +10 -10
  71. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +87 -40
  72. data/mod/03_machines/lib/stylesheets/style_cards.scss +26 -28
  73. data/mod/03_machines/set/right/machine_output.rb +3 -3
  74. data/mod/03_machines/set/type/coffee_script.rb +6 -6
  75. data/mod/03_machines/set/type/css.rb +1 -1
  76. data/mod/03_machines/set/type/java_script.rb +5 -6
  77. data/mod/03_machines/spec/lib/shared_machine_examples.rb +3 -1
  78. data/mod/03_machines/spec/set/type/scss_spec.rb +9 -10
  79. data/mod/04_settings/lib/card/setting.rb +16 -14
  80. data/mod/04_settings/set/right/structure.rb +6 -0
  81. data/mod/04_settings/set/self/add_help.rb +1 -1
  82. data/mod/04_settings/set/self/autoname.rb +1 -1
  83. data/mod/04_settings/set/self/captcha.rb +1 -1
  84. data/mod/04_settings/set/self/default.rb +1 -1
  85. data/mod/04_settings/set/self/help.rb +1 -1
  86. data/mod/04_settings/set/self/input.rb +1 -1
  87. data/mod/04_settings/set/self/layout.rb +1 -1
  88. data/mod/04_settings/set/self/on_create.rb +1 -1
  89. data/mod/04_settings/set/self/on_delete.rb +1 -1
  90. data/mod/04_settings/set/self/on_update.rb +1 -1
  91. data/mod/04_settings/set/self/options.rb +1 -1
  92. data/mod/04_settings/set/self/options_label.rb +1 -1
  93. data/mod/04_settings/set/self/script.rb +1 -1
  94. data/mod/04_settings/set/self/structure.rb +1 -1
  95. data/mod/04_settings/set/self/style.rb +1 -1
  96. data/mod/04_settings/set/self/table_of_contents.rb +1 -1
  97. data/mod/04_settings/set/self/thanks.rb +1 -1
  98. data/mod/05_email/set/all/follow.rb +3 -21
  99. data/mod/05_email/set/all/notify.rb +20 -4
  100. data/mod/05_email/set/right/follow.rb +16 -18
  101. data/mod/05_email/set/self/follow.rb +1 -1
  102. data/mod/05_email/spec/set/all/follow_spec.rb +6 -13
  103. data/mod/05_standard/set/all/attach.rb +23 -9
  104. data/mod/05_standard/set/all/error.rb +5 -7
  105. data/mod/05_standard/set/all/event_viz.rb +10 -6
  106. data/mod/05_standard/set/all/links.rb +37 -13
  107. data/mod/05_standard/set/all/rich_html/content.rb +46 -18
  108. data/mod/05_standard/set/all/rich_html/editing.rb +29 -25
  109. data/mod/05_standard/set/all/rich_html/form.rb +17 -10
  110. data/mod/05_standard/set/all/rich_html/header.rb +26 -4
  111. data/mod/05_standard/set/all/rich_html/menu.rb +17 -34
  112. data/mod/05_standard/set/all/rich_html/modal.rb +50 -12
  113. data/mod/05_standard/set/all/rich_html/toolbar.rb +178 -186
  114. data/mod/05_standard/set/all/rich_html/wrapper.rb +44 -21
  115. data/mod/05_standard/set/rstar/rules.rb +43 -53
  116. data/mod/05_standard/set/self/all.rb +2 -1
  117. data/mod/05_standard/set/self/head.rb +2 -2
  118. data/mod/05_standard/set/self/signin.rb +18 -18
  119. data/mod/05_standard/set/self/stats.rb +14 -2
  120. data/mod/05_standard/set/type/search_type.rb +9 -4
  121. data/mod/05_standard/set/type/session.rb +12 -7
  122. data/mod/05_standard/set/type/set.rb +135 -18
  123. data/mod/05_standard/spec/chunk/include_spec.rb +15 -16
  124. data/mod/05_standard/spec/set/all/account_spec.rb +21 -21
  125. data/mod/05_standard/spec/set/all/event_viz_spec.rb +7 -7
  126. data/mod/05_standard/spec/set/all/history_spec.rb +54 -24
  127. data/mod/05_standard/spec/set/all/rich_html/editing_spec.rb +42 -40
  128. data/mod/05_standard/spec/set/rstar/rules_spec.rb +1 -1
  129. data/mod/05_standard/spec/set/type/search_type_spec.rb +9 -1
  130. data/mod/05_standard/spec/set/type/signup_spec.rb +42 -42
  131. data/mod/06_bootstrap/lib/stylesheets/bootstrap_cards.scss +6 -0
  132. data/mod/06_bootstrap/set/all/bootstrap/form.rb +4 -5
  133. data/mod/06_bootstrap/set/all/bootstrap/helper.rb +145 -0
  134. data/mod/06_bootstrap/set/all/rich_bootstrap.rb +0 -59
  135. data/spec/lib/card/action_spec.rb +1 -1
  136. data/spec/lib/card/log_spec.rb +7 -7
  137. data/spec/models/card/cardtype_spec.rb +1 -1
  138. data/spec/spec_helper.rb +1 -1
  139. metadata +31 -6
  140. data/mod/04_settings/set/self/comment.rb +0 -2
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:communication, :position=>7, :rule_type_editable => false, :user_specific=>true
2
+ setting_opts :group=>:other, :position=>7, :rule_type_editable => false, :user_specific=>true
@@ -4,9 +4,6 @@ describe "Card::Set::All::Follow" do
4
4
  def follow_view card_name
5
5
  render_card :follow_link, :name=>card_name
6
6
  end
7
- def follow_modal_view card_name
8
- render_card :follow_modal_link, :name=>card_name
9
- end
10
7
 
11
8
  describe "follower_ids" do
12
9
 
@@ -19,7 +16,6 @@ describe "Card::Set::All::Follow" do
19
16
  end
20
17
  end
21
18
 
22
-
23
19
  subject { Card[cardname].follower_names.sort }
24
20
  context 'followers of No One Sees Me' do
25
21
  let(:cardname) {'No One Sees Me'}
@@ -61,7 +57,7 @@ describe "Card::Set::All::Follow" do
61
57
  end
62
58
 
63
59
  def assert_following_view name, args
64
- assert_follow_view name, args.reverse_merge(:following => true, :text=>"unfollow #{name}")
60
+ assert_follow_view name, args.reverse_merge(:following => true, :text=>"unfollow" )
65
61
  end
66
62
 
67
63
  # href="/card/update/Home+*self+philipp+*follow?card%5Bcontent%5D=%5B%5Bnever%5D%5D&success%5Bid%5D=Home&success%5Bview%5D=follow"
@@ -78,14 +74,11 @@ describe "Card::Set::All::Follow" do
78
74
  # CGI.escape("[[*always]]")
79
75
  # end
80
76
 
81
- link_class = args[:following] ? "follow-toggle-off" : "follow-toggle-on"
82
- assert_view_select follow_view(name), "a[class~=#{link_class}][href*='']", args[:text] || "follow #{name}"
77
+ link_class = 'follow-link'
78
+ assert_view_select follow_view(name), "a[class~=#{link_class}][href*='']", args[:text] || "follow"
83
79
  end
84
80
 
85
- def assert_follow_modal_view card_name
86
- href_part = args[:following] ? "never" : "always"
87
- assert_view_select follow_view(name), "a[class~=follow-link][href*=#{href_part}]", args[:text] || "follow #{name}"
88
- end
81
+
89
82
 
90
83
 
91
84
  context "when not following" do
@@ -108,13 +101,13 @@ describe "Card::Set::All::Follow" do
108
101
 
109
102
  context "when following cardtype card" do
110
103
  it 'renders following all link' do
111
- assert_following_view 'Optic', :add_set=>'Optic+*type', :text=>'unfollow all "Optics"'
104
+ assert_following_view 'Optic', :add_set=>'Optic+*type', :text=>'unfollow'
112
105
  end
113
106
  end
114
107
 
115
108
  context "when not following cardtype card" do
116
109
  it "renders 'follow all' link" do
117
- assert_follow_view 'Basic', :add_set=>'Basic+*type', :text=>'follow all "Basics"'
110
+ assert_follow_view 'Basic', :add_set=>'Basic+*type', :text=>'follow'
118
111
  end
119
112
  end
120
113
 
@@ -3,7 +3,7 @@ require 'rmagick'
3
3
  require 'paperclip'
4
4
 
5
5
  def attach_array
6
-
6
+
7
7
  c= self.content
8
8
  !c || c =~ /^\s*<img / ? ['','',''] : c.split(/\n/)
9
9
  end
@@ -38,17 +38,17 @@ STYLES = %w{ icon small medium large original }
38
38
 
39
39
 
40
40
  def attachment_format(ext)
41
- if ext.present? and attach and original_ext=attach_extension
41
+ if ext.present? and attach and original_ext=attach_extension
42
42
  if['file', original_ext].member? ext
43
43
  original_ext
44
- elsif exts = MIME::Types[attach.content_type]
44
+ elsif exts = MIME::Types[attach.content_type]
45
45
  if exts.find {|mt| mt.extensions.member? ext }
46
46
  ext
47
47
  else
48
48
  exts[0].extensions[0]
49
49
  end
50
50
  end
51
- end
51
+ end
52
52
  rescue => e
53
53
  Rails.logger.info "attachment_format issue: #{e.message}"
54
54
  nil
@@ -65,7 +65,7 @@ def attachment_symlink_to(prior_action_id) # create filesystem links to files fr
65
65
  if styles and prior_action_id != last_action_id
66
66
  save_action_id = selected_action_id
67
67
  links = {}
68
-
68
+
69
69
  self.selected_action_id = prior_action_id
70
70
  styles.each { |style| links[style] = ::File.basename(attach.path(style)) }
71
71
 
@@ -94,12 +94,14 @@ def self.included(base)
94
94
  # this isn't quite right, but without it, we see logging to STDOUT
95
95
  Paperclip.options[:log] = false
96
96
 
97
+
97
98
  has_attached_file :attach, :preserve_files=>true,
98
99
  :default_url => "missing",
99
100
  :url => ":web_dir/:basename-:size:action_id.:extension",
100
101
  :path => ":system_path.:extension",
101
102
  :styles => { :icon => '16x16#', :small => '75x75',
102
103
  :medium => '200x200>', :large => '500x500>' }
104
+ # :validate_media_type => false
103
105
 
104
106
  before_post_process :before_post_attach
105
107
 
@@ -111,13 +113,25 @@ def self.included(base)
111
113
  end
112
114
  end
113
115
  end
116
+
117
+ do_not_validate_attachment_file_type :attach
114
118
  end
115
119
  end
116
120
 
117
121
 
122
+ # allow empty files
123
+ # without this monkey patch empty files get detected as application/octet-stream
124
+ # and throw a type mismatch exception
125
+ # alternative solution: turn spoof detection always off with option :validate_media_type=>false
126
+ class Paperclip::MediaTypeSpoofDetector
127
+ alias_method 'content_spoofed?', 'spoofed?'
128
+ def spoofed?
129
+ @file.size == 0 ? false : content_spoofed?
130
+ end
131
+ end
118
132
 
119
133
  module Paperclip::Interpolations
120
-
134
+
121
135
  extend Card::Format::Location
122
136
 
123
137
  def system_path at, style
@@ -130,7 +144,7 @@ module Paperclip::Interpolations
130
144
  "#{ Card.paths['files'].existent.first }/#{card.id}/#{size at, style}#{action_id at, style}"
131
145
  end
132
146
  end
133
-
147
+
134
148
  def web_dir at, style_name
135
149
  card_path Card.config.files_web_path
136
150
  end
@@ -143,8 +157,8 @@ module Paperclip::Interpolations
143
157
  at.instance.type_id==Card::FileID || style_name.blank? ? '' : "#{style_name}-"
144
158
  end
145
159
 
146
- def action_id(at, style_name)
147
- at.instance.selected_content_action_id
160
+ def action_id(at, style_name)
161
+ at.instance.selected_content_action_id
148
162
  end
149
163
  end
150
164
 
@@ -104,17 +104,14 @@ format :html do
104
104
 
105
105
  view :conflict, :error_code=>409 do |args|
106
106
  # FIXME: hack to get the conflicted update as a proper act for the diff view
107
- card.current_act.save
108
- action = card.actions.last # the unsaved action with the new changes
109
- action.card_act_id = card.current_act.id
110
- action.draft = true
111
- action.save
107
+ card.current_act.update_attributes! :card_id => card.id
108
+ card.current_action.update_attributes! :card_id => card.id, :draft=>true # the unsaved action with the new changes
112
109
  card.store_changes # deletes action if there are no changes
113
110
 
114
111
  # as a consequence card.current_act.actions can be empty when both users made exactly the same changes
115
112
  # but an act is always supposed to have at least one action, so we have to delete the act to avoid bad things
116
- card.current_act.reload
117
- if card.current_act.actions.empty?
113
+ #card.current_act.reload
114
+ if card.current_act.actions(true).empty?
118
115
  card.current_act.delete
119
116
  card.current_act = nil
120
117
  end
@@ -138,6 +135,7 @@ format :html do
138
135
  end
139
136
 
140
137
  view :errors, :perms=>:none do |args|
138
+
141
139
  if card.errors.any?
142
140
  title = %{ Problems #{%{ with #{card.name} } unless card.name.blank?} }
143
141
  frame args.merge(:panel_class=>"panel panel-warning", :title=>title, :hide=>'menu' ) do
@@ -2,10 +2,14 @@
2
2
  # EXPERIMENTAL
3
3
  # the following methods are for visualing card events
4
4
  # not ready for prime time!
5
+ # not working with Rails 4
5
6
 
6
7
  def events action
7
8
  @action = action
8
- root = _validate_callbacks + _save_callbacks
9
+
10
+ # don't know what this line is for but it breaks with Rails 4
11
+ # root = _validate_callbacks + _save_callbacks
12
+
9
13
  events = [ events_tree(:validation), events_tree(:save)]
10
14
  @action = nil
11
15
  puts_events events
@@ -21,19 +25,19 @@ def puts_events events, prefix='', depth=0
21
25
 
22
26
  #FIXME - this is not right. before and around callbacks are processed in declaration order regardless of kind.
23
27
  # not all befores then all arounds
24
-
28
+
25
29
  if e[:before]
26
30
  r += puts_events( e[:before], space+'v ', depth)
27
31
  end
28
32
  if e[:around]
29
33
  r += puts_events( e[:around], space+'vv ', depth )
30
34
  end
31
-
32
-
35
+
36
+
33
37
  output = "#{prefix}#{e[:name]}"
34
38
  #warn output
35
39
  r+= "#{output}\n"
36
-
40
+
37
41
  if e[:after]
38
42
  r += puts_events( e[:after ].reverse, space+'^ ', depth )
39
43
  end
@@ -46,7 +50,7 @@ def events_tree filt
46
50
  if respond_to? "_#{filt}_callbacks"
47
51
  send( "_#{filt}_callbacks" ).each do |callback|
48
52
  next unless callback.applies? self
49
- hash[callback.kind] ||= []
53
+ hash[callback.kind] ||= []
50
54
  hash[callback.kind] << events_tree( callback.filter )
51
55
  end
52
56
  end
@@ -14,6 +14,25 @@ format do
14
14
  end
15
15
  end
16
16
 
17
+ # link to url, view, card or related card
18
+ #
19
+ def smart_link link_text, target, html_args={}
20
+ if (view = target.delete(:view))
21
+ view_link link_text, view, html_args.merge(:path_opts=>target)
22
+ elsif (page = target.delete(:card))
23
+ card_link page, html_args.merge(:path_opts=>target, :text=>link_text)
24
+ elsif target[:related]
25
+ if target[:related].kind_of? String
26
+ target[:related] = {:name=>"+#{target[:related]}"}
27
+ end
28
+ view_link link_text, :related, html_args.merge(:path_opts=>target)
29
+ elsif target[:web]
30
+ else
31
+ link_to link_text, target, html_args
32
+ end
33
+ end
34
+
35
+
17
36
  # link to a specific url or path
18
37
  def web_link href, opts={}
19
38
  text = opts.delete(:text) || href
@@ -72,24 +91,29 @@ format do
72
91
 
73
92
 
74
93
  def path opts={}
75
- name = opts.delete(:name) || card.name
76
- base = opts[:action] ? "card/#{ opts.delete :action }/" : ''
94
+ if opts[:action] == :new && opts[:type] && !(opts[:name] || opts[:card] || opts[:id])
95
+ opts.delete(:action)
96
+ base = "new/#{opts.delete(:type)}"
97
+ else
98
+ name = opts.delete(:name) || card.name
99
+ base = opts[:action] ? "card/#{ opts.delete :action }/" : ''
77
100
 
78
- opts[:no_id] = true if [:new, :create].member? opts[:action]
79
- #generalize. dislike hardcoding views/actions here
101
+ opts[:no_id] = true if [:new, :create].member? opts[:action]
102
+ #generalize. dislike hardcoding views/actions here
80
103
 
81
- linkname = name.to_name.url_key
82
- unless name.empty? || opts.delete(:no_id)
83
- base += ( opts[:id] ? "~#{ opts.delete :id }" : linkname )
84
- end
104
+ linkname = name.to_name.url_key
105
+ unless name.empty? || opts.delete(:no_id)
106
+ base += ( opts[:id] ? "~#{ opts.delete :id }" : linkname )
107
+ end
85
108
 
86
- opts[:card] ||= {}
87
- opts[:card][:name] = name if opts.delete(:known)==false && name.present? && name.to_s != linkname
109
+ opts[:card] ||= {}
110
+ opts[:card][:name] = name if opts.delete(:known)==false && name.present? && name.to_s != linkname
88
111
 
89
- if type = opts.delete(:type) and Card.known?( type )
90
- opts[:card][:type] = type
112
+ if type = opts.delete(:type) and Card.known?( type )
113
+ opts[:card][:type] = type
114
+ end
115
+ opts.delete(:card) if opts[:card].empty?
91
116
  end
92
- opts.delete(:card) if opts[:card].empty?
93
117
 
94
118
  query = opts.empty? ? '' : "?#{opts.to_param}"
95
119
  internal_url( base + query )
@@ -5,21 +5,29 @@ end
5
5
  format :html do
6
6
 
7
7
  def show view, args
8
- if Env.ajax?
9
- view ||= args[:home_view] || :open
10
- @inclusion_opts = args.delete(:items)
11
- render view, args
12
- else
8
+ if show_layout?
13
9
  args.merge! :view=>view if view
14
10
  @main_opts = args
15
11
  self.render :layout
12
+ else
13
+ view ||= args[:home_view] || :open
14
+ @inclusion_opts = args.delete(:items)
15
+ render view, args
16
16
  end
17
17
  end
18
18
 
19
+ def show_layout?
20
+ !Env.ajax? || params[:layout]
21
+ end
22
+
19
23
  view :layout, :perms=>:none do |args|
20
- process_content get_layout_content, :content_opts=>{ :chunk_list=>:references }
24
+ output [
25
+ process_content(get_layout_content, :content_opts=>{ :chunk_list=>:references }),
26
+ _render_modal_slot(args)
27
+ ]
21
28
  end
22
29
 
30
+
23
31
  view :content do |args|
24
32
  wrap args.reverse_merge(:slot_class=>'card-content') do
25
33
  [
@@ -65,10 +73,9 @@ format :html do
65
73
 
66
74
  view :title do |args|
67
75
  title = fancy_title args[:title], args[:title_class]
68
- title = _optional_render( :title_toolbar, args, (show_view?(:toolbar,args.merge(:default_visibility=>:hide)) || toolbar_pinned? ? :show : :hide)) ||
69
- _optional_render( :title_link, args.merge( :title_ready=>title ), :hide ) ||
76
+ title = _optional_render( :title_editable, args, :hide) ||
77
+ _optional_render( :title_link, args.merge( :title_ready=>title ), :hide ) ||
70
78
  title
71
- #title += " (#{card.type_name})" if Card[:show_cardtype].content == 'true'
72
79
  add_name_context
73
80
  title
74
81
  end
@@ -77,7 +84,15 @@ format :html do
77
84
  card_link card.cardname, :text=>( args[:title_ready] || showname(args[:title]) )
78
85
  end
79
86
 
80
- view :title_toolbar do |args|
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
93
+ end
94
+
95
+ view :title_editable do |args|
81
96
  links = card.cardname.parts.map do |name|
82
97
  card_link name
83
98
  end
@@ -88,7 +103,7 @@ format :html do
88
103
  end
89
104
  res += ' '
90
105
  res.concat view_link(glyphicon('edit','header-icon'),:edit_name, :class=>'slotter', 'data-toggle'=>'tooltip', :title=>'edit name')
91
- res
106
+ res.concat _optional_render(:type_link,args,:show)
92
107
  end
93
108
 
94
109
  view :open, :tags=>:comment do |args|
@@ -116,7 +131,7 @@ format :html do
116
131
  end
117
132
 
118
133
  view :closed do |args|
119
- frame args.reverse_merge(:content=>true, :body_class=>'closed-content', :toggle_mode=>:close, :optional_toggle=>:show, :optional_edit_toolbar=>:hide ) do
134
+ frame args.reverse_merge(:content=>true, :body_class=>'closed-content', :toggle_mode=>:close, :optional_toggle=>:show, :optional_toolbar=>:hide ) do
120
135
  _optional_render :closed_content, args
121
136
  end
122
137
  end
@@ -142,25 +157,38 @@ format :html do
142
157
 
143
158
 
144
159
  view :related do |args|
160
+ if args[:related_card]
161
+ frame args.merge(:optional_toolbar=>:show) do
162
+ nest( args[:related_card], args[:related_args])
163
+ end
164
+ end
165
+ end
166
+
167
+ def default_related_args args
145
168
  if rparams = args[:related] || params[:related]
146
169
  rcard = rparams[:card] || begin
147
170
  rcardname = rparams[:name].to_name.to_absolute_name( card.cardname)
148
171
  Card.fetch rcardname, :new=>{}
149
172
  end
150
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
151
177
  nest_args = ( rparams[:slot] || {} ).deep_symbolize_keys.reverse_merge(
152
178
  :view => ( rparams[:view] || :open ),
179
+ :optional_header => :hide,
180
+ :optional_menu => :show,
181
+ :subheader => subheader,
153
182
  :optional_toggle => :hide,
154
183
  :optional_help => :show,
155
- :optional_menu => :show,
156
- :optional_close_related_link => :show,
157
- :parent => card
184
+ :parent => card,
185
+ :subframe => true,
186
+ :subslot => true
158
187
  )
159
188
  nest_args[:optional_comment_box] = :show if rcard.show_comment_box_in_related?
160
189
 
161
- frame args do
162
- nest rcard, nest_args
163
- end
190
+ args[:related_args] = nest_args
191
+ args[:related_card] = rcard
164
192
  end
165
193
  end
166
194
 
@@ -64,7 +64,7 @@ format :html do
64
64
 
65
65
 
66
66
  view :edit, :perms=>:update, :tags=>:unknown_ok do |args|
67
- frame_and_form :update, args do
67
+ frame_and_form :update, args.merge(:optional_toolbar=>:show) do
68
68
  [
69
69
  _optional_render( :content_formgroup, args ),
70
70
  _optional_render( :button_formgroup, args )
@@ -75,8 +75,7 @@ format :html do
75
75
 
76
76
  def default_edit_args args
77
77
  args[:optional_help] ||= :show
78
- args[:optional_edit_toolbar] ||= :show
79
- args[:active_toolbar_view] ||= :edit
78
+ args[:optional_toolbar] ||= :show
80
79
 
81
80
  args[:buttons] ||= %{
82
81
  #{ button_tag 'Submit', :class=>'submit-button', :disable_with=>'Submitting', :situation=>'primary' }
@@ -123,8 +122,7 @@ format :html do
123
122
  :referers => referers.size,
124
123
  :card => { :update_referencers => false }
125
124
  )
126
- args[:optional_edit_toolbar] ||= :show
127
- args[:active_toolbar_view] ||= :edit_name
125
+ args[:optional_toolbar] ||= :show
128
126
  args[:buttons] = %{
129
127
  #{ button_tag 'Rename and Update', :disable_with=>'Renaming', :class=>'renamer-updater', :situation=>'primary' }
130
128
  #{ button_tag 'Rename', :disable_with=>'Renaming', :class=>'renamer' }
@@ -146,8 +144,7 @@ format :html do
146
144
 
147
145
  def default_edit_type_args args
148
146
  args[:variety] = :edit #YUCK!
149
- args[:optional_edit_toolbar] ||= :show
150
- args[:active_toolbar_view] ||= :edit_type
147
+ args[:optional_toolbar] ||= :show
151
148
  args[:hidden] ||= { :success=>{:view=>:edit} }
152
149
  args[:buttons] = %{
153
150
  #{ button_tag 'Submit', :disable_with=>'Submitting', :situation=>'primary' }
@@ -156,14 +153,16 @@ format :html do
156
153
  end
157
154
 
158
155
  view :edit_rules, :tags=>:unknown_ok do |args|
159
- frame args do
160
- subformat( current_set_card ).render_content args
161
- end
156
+ view = args[:rule_view] || :common_rules
157
+ _render_related args.merge(:related=>{:card=>current_set_card, :view=>:open, :slot=>{ :rule_view=>view, :optional_set_navbar=>:show, :optional_set_label=>:hide, :optional_rule_navbar=>:hide}})
158
+
159
+ # frame args do
160
+ # subformat( current_set_card ).render(view, args)
161
+ # end
162
162
  end
163
163
 
164
164
  def default_edit_rules_args args
165
- args[:optional_edit_toolbar] ||= :show
166
- args[:active_toolbar_view] ||= :edit_rules
165
+ args[:optional_toolbar] ||= :show
167
166
  end
168
167
 
169
168
  view :options, {:view=>:edit_rules, :mod=>All::RichHtml::Editing::HtmlFormat} # for backwards compatibility
@@ -178,27 +177,32 @@ format :html do
178
177
  end
179
178
 
180
179
  def default_edit_structure_args args
181
- args[:optional_edit_toolbar] ||= :show
182
- args[:active_toolbar_view] ||= :edit_structure
180
+ args[:optional_toolbar] ||= :show
183
181
  end
184
182
 
185
183
  view :edit_nests do |args|
186
- #nests = card.fetch(:trait=>:includes)
187
- includes = Card::Content.new(card.content, card).find_chunks( Card::Chunk::Include )
188
-
189
184
  frame args do
190
- includes.map do |chunk|
191
- if chunk.referee_card
192
- nest chunk.referee_card, :view=>:edit_rules, :hide=>'set_label'
193
- end
185
+ with_inclusion_mode :edit do
186
+ process_relative_tags :optional_toolbar=>:hide
194
187
  end
195
- #nest nests, :view=>:content, :items=>{:view=>:edit_rules, :hide=>'set_label'}
196
188
  end
197
189
  end
198
-
199
190
  def default_edit_nests_args args
200
- args[:optional_edit_toolbar] ||= :show
201
- args[:active_toolbar_view] ||= :edit_nests
191
+ args[:optional_toolbar] ||= :show
192
+ end
193
+
194
+ view :edit_nest_rules do |args|
195
+ view = args[:rule_view] || :field_related_rules
196
+ frame args do
197
+ # with_inclusion_mode :edit do
198
+ nested_fields(args).map do |chunk|
199
+ nest Card.fetch("#{chunk.referee_name}+*self"), :view=>:titled, :rule_view=>view, :optional_set_label=>:hide, :optional_rule_navbar=>:show
200
+ end
201
+ end
202
+ end
203
+
204
+ def default_edit_nest_rules_args args
205
+ args[:optional_toolbar] ||= :show
202
206
  end
203
207
  end
204
208