card 1.15.7 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
@@ -9,12 +9,12 @@ format do
9
9
  super args
10
10
  end
11
11
  end
12
-
12
+
13
13
  def update_machine_output_live?
14
14
  said = card.selected_action_id
15
15
  card.left.kind_of? Machine and # must be a machine
16
- !card.left.locked? and # machine must not already be running
16
+ !card.left.locked? and # machine must not already be running
17
17
  ( card.new_card? or !said or said == card.last_action_id ) # must want current output (won't re-output old stuff)
18
18
  end
19
-
19
+
20
20
  end
@@ -14,7 +14,7 @@ rescue =>e
14
14
  e
15
15
  end
16
16
 
17
- machine_input do
17
+ machine_input do
18
18
  Uglifier.compile( compile_coffee format(:js)._render_raw )
19
19
  end
20
20
 
@@ -26,31 +26,31 @@ end
26
26
 
27
27
 
28
28
  format do
29
- def chunk_list #turn off autodetection of uri's
29
+ def chunk_list #turn off autodetection of uri's
30
30
  :inclusion_only
31
31
  end
32
32
  end
33
33
 
34
34
 
35
35
  format :html do
36
- view :editor, :mod=>PlainText::HtmlFormat
36
+ view :editor, :mod=>Html::HtmlFormat
37
37
 
38
38
  view :content_changes do |args|
39
39
  %{
40
40
  <pre>#{super(args)}</pre>
41
41
  }
42
42
  end
43
-
43
+
44
44
  view :core do |args|
45
45
  js = card.compile_coffee _render_raw
46
46
  highlighted_js = ::CodeRay.scan( js, :js ).div
47
47
  process_content highlighted_js
48
48
  end
49
-
49
+
50
50
  end
51
51
 
52
52
 
53
- format do
53
+ format do
54
54
  view :core do |args|
55
55
  process_content card.compile_coffee(_render_raw)
56
56
  end
@@ -33,7 +33,7 @@ format :html do
33
33
  { :view => :closed }
34
34
  end
35
35
 
36
- view :editor, :mod=>PlainText::HtmlFormat
36
+ view :editor, :mod=>Html::HtmlFormat
37
37
 
38
38
  view :core do |args|
39
39
  # FIXME: scan must happen before process for inclusion interactions to work, but this will likely cause
@@ -6,31 +6,30 @@ include MachineInput
6
6
 
7
7
  store_machine_output :filetype => "js"
8
8
 
9
- machine_input do
9
+ machine_input do
10
10
  Uglifier.compile(format(:js)._render_core)
11
11
  end
12
12
 
13
-
14
13
  def clean_html?
15
14
  false
16
15
  end
17
16
 
18
17
 
19
18
  format do
20
- def chunk_list #turn off autodetection of uri's
19
+ def chunk_list #turn off autodetection of uri's
21
20
  :inclusion_only
22
21
  end
23
22
  end
24
23
 
25
24
  format :html do
26
- view :editor, :mod=>PlainText::HtmlFormat
25
+ view :editor, :mod=>Html::HtmlFormat
27
26
  view :content_changes, :mod=>CoffeeScript::HtmlFormat
28
-
27
+
29
28
  view :core do |args|
30
29
  highlighted_js = ::CodeRay.scan( _render_raw, :js ).div
31
30
  process_content highlighted_js
32
31
  end
33
-
32
+
34
33
  end
35
34
 
36
35
  def diff_args
@@ -33,12 +33,14 @@ shared_examples_for 'machine' do |filetype|
33
33
  end
34
34
 
35
35
  shared_examples_for 'content machine' do |filetype|
36
+
36
37
  it_should_behave_like 'machine', that_produces(filetype) do
37
38
  let(:machine) { machine_card }
38
39
  end
39
40
 
40
-
41
41
  context '+machine_input card' do
42
+
43
+
42
44
  it "points to self" do
43
45
  Card::Auth.as_bot do
44
46
  machine_card.update_input_card
@@ -1,16 +1,16 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  describe Card::Set::Type::Scss do
4
- let(:scss) {
4
+ let(:scss) {
5
5
  %{
6
6
  $link_color: #abcdef;
7
- a { color: $link_color; }
7
+ a { color: $link_color; }
8
8
  }
9
9
  }
10
10
  let(:compressed_css) { "a{color:#abcdef}\n" }
11
- let(:changed_scss) {
11
+ let(:changed_scss) {
12
12
  %{
13
- $link_color: #fedcba;
13
+ $link_color: #fedcba;
14
14
  a { color: $link_color; }
15
15
  }
16
16
  }
@@ -18,22 +18,21 @@ describe Card::Set::Type::Scss do
18
18
  before do
19
19
  @scss_card = Card[:style_cards]
20
20
  end
21
-
22
-
21
+
23
22
  it 'should highlight code in html' do
24
23
  assert_view_select @scss_card.format(:html).render_core, 'div[class=CodeRay]'
25
24
  end
26
-
25
+
27
26
  it 'should not highlight code in css' do
28
27
  expect(@scss_card.format(:css).render_core).not_to match(/CodeRay/)
29
28
  end
30
-
29
+
31
30
  it_should_behave_like "machine input" do
32
31
  let(:create_machine_input_card) { Card.gimme! "test scss", :type => :scss, :content => scss }
33
32
  let(:create_another_machine_input_card) { Card.gimme! "more scss", :type => :scss, :content => scss }
34
33
  let(:create_machine_card) { Card.gimme! "style with scss+*style", :type => :pointer }
35
34
  let(:card_content) do
36
- { in: scss, out: compressed_css,
35
+ { in: scss, out: compressed_css,
37
36
  changed_in: changed_scss, changed_out: compressed_changed_css }
38
37
  end
39
38
  end
@@ -49,7 +48,7 @@ describe Card::Set::Type::Scss do
49
48
  it_should_behave_like 'content machine', that_produces_css do
50
49
  let(:machine_card) { Card.gimme! "test scss", :type => :scss, :content => scss }
51
50
  let(:card_content) do
52
- { in: scss, out: compressed_css,
51
+ { in: scss, out: compressed_css,
53
52
  changed_in: changed_scss, changed_out: compressed_changed_css }
54
53
  end
55
54
  end
@@ -8,34 +8,36 @@ class Card
8
8
  # E = Card::Set::Self::Create (module extended with M)
9
9
  # O = Card["*create"] (object)
10
10
  attr_accessor :codename # accessible in E
11
- mattr_accessor :groups, :group_names, :user_specific # accessible in E and M
12
- def self.extended(host_class)
11
+ mattr_accessor :groups, :group_names, :user_specific # accessible in E and M
12
+ def self.extended(host_class)
13
13
  host_class.mattr_accessor :restricted_to_type, :rule_type_editable # accessible in E and O
14
14
  end
15
-
16
- @@groups = { :permission =>[], :look_and_feel=>[], :communication => [], :pointer=>[], :other =>[] }
15
+
17
16
  @@group_names = {
18
- :permission => "Permission",
19
- :look_and_feel => "Look and Feel",
20
- :communication => "Communication",
17
+ :templating => "Templating",
18
+ :permission => "Permissions",
19
+ :webpage => "Webpage",
21
20
  :pointer => "Pointer",
22
- :other => "Other"
21
+ :editing_cue => "Editing cues",
22
+ :event => "Events",
23
+ :other => "Other"
23
24
  }
25
+ @@groups = @@group_names.keys.each_with_object({}) { |key, groups| groups[key] = [] }
24
26
  @@user_specific = ::Set.new
25
27
 
26
28
  def self.user_specific? codename
27
29
  @@user_specific.include? codename
28
30
  end
29
-
31
+
30
32
  def to_type_id type
31
33
  type.is_a?(Fixnum) ? type : Card::Codename[type]
32
34
  end
33
-
35
+
34
36
  # usage:
35
- # setting_opts :group => :permission | :look_and_feel | ...
37
+ # setting_opts :group => :permission | :event | ...
36
38
  # :position => <Fixnum> (starting at 1, default: add to end)
37
39
  # :rule_type_editable => true | false (default: false)
38
- # :restricted_to_type => <cardtype> | [ <cardtype>, ...]
40
+ # :restricted_to_type => <cardtype> | [ <cardtype>, ...]
39
41
  def setting_opts opts
40
42
  group = opts[:group] || :other
41
43
  @@groups[group] ||= []
@@ -48,7 +50,7 @@ class Card
48
50
  else
49
51
  @@groups[group] << self
50
52
  end
51
-
53
+
52
54
  @codename = opts[:codename] || self.name.match(/::(\w+)$/)[1].underscore.to_sym
53
55
  self.rule_type_editable = opts[:rule_type_editable]
54
56
  self.restricted_to_type = opts[:restricted_to_type] ? ::Set.new([opts[:restricted_to_type]].flatten.map{ |cardtype| to_type_id(cardtype) }) : false
@@ -56,7 +58,7 @@ class Card
56
58
  @@user_specific << @codename
57
59
  end
58
60
  end
59
-
61
+
60
62
  def applies_to_cardtype type_id
61
63
  !self.restricted_to_type or self.restricted_to_type.include? type_id
62
64
  end
@@ -1,4 +1,10 @@
1
1
 
2
+ format :rss do
3
+ def raw_feed_items
4
+ [card]
5
+ end
6
+ end
7
+
2
8
  format :html do
3
9
  include AddHelp::HtmlFormat
4
10
  end
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:communication, :position=>2, :rule_type_editable => true
2
+ setting_opts :group=>:editing_cue, :position=>2, :rule_type_editable => true
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:other, :position=>1
2
+ setting_opts :group=>:templating, :position=>3
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:other, :position=>3
2
+ setting_opts :group=>:permission, :position=>5
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=> :look_and_feel, :position=>1, :rule_type_editable => true
2
+ setting_opts :group=> :templating, :position=>2, :rule_type_editable => true
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:communication, :position=>1, :rule_type_editable => true
2
+ setting_opts :group=>:editing_cue, :position=>1, :rule_type_editable => true
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:pointer, :position=>3, :restricted_to_type => :pointer, :rule_type_editable => false
2
+ setting_opts :group=>:pointer, :position=>3, :restricted_to_type => [:pointer,:session], :rule_type_editable => false
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:look_and_feel, :position=>3, :rule_type_editable => false
2
+ setting_opts :group=>:webpage, :position=>3, :rule_type_editable => false
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:communication, :position=>4 , :rule_type_editable => false
2
+ setting_opts :group=>:event, :position=>1 , :rule_type_editable => false
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:communication, :position=>5, :rule_type_editable => false
2
+ setting_opts :group=>:event, :position=>3, :rule_type_editable => false
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:communication, :position=>4, :rule_type_editable => false
2
+ setting_opts :group=>:event, :position=>2, :rule_type_editable => false
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:pointer, :position=>1, :restricted_to_type => :pointer, :rule_type_editable=>true
2
+ setting_opts :group=>:pointer, :position=>1, :restricted_to_type => [:pointer,:session], :rule_type_editable=>true
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:pointer, :position=>2, :restricted_to_type => :pointer, :rule_type_editable => false
2
+ setting_opts :group=>:pointer, :position=>2, :restricted_to_type => [:pointer,:session], :rule_type_editable => false
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=> :look_and_feel, :position=>5
2
+ setting_opts :group=>:webpage, :position=>5
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=> :look_and_feel, :position=>2, :rule_type_editable => true
2
+ setting_opts :group=> :templating, :position=>2, :rule_type_editable => true
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:look_and_feel, :position=>4
2
+ setting_opts :group=>:webpage, :position=>4
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=> :look_and_feel, :position=>6, :rule_type_editable=>false
2
+ setting_opts :group=> :other, :position=>1, :rule_type_editable=>false
@@ -1,2 +1,2 @@
1
1
  extend Card::Setting
2
- setting_opts :group=>:communication, :position=>3, :rule_type_editable => false
2
+ setting_opts :group=>:other, :position=>3, :rule_type_editable => false
@@ -35,7 +35,7 @@ format do
35
35
  end
36
36
  follow_rule_name = card.default_follow_set_card.follow_rule_name( Auth.current.name )
37
37
  hash[:path] = path :name=>follow_rule_name, :action=>:update,
38
- :success=>{ :view=>:modal_content },
38
+ :success=>{ :layout=>:modal, :view=>:follow_status },
39
39
  :card=>{ :content=>"[[#{hash[:content]}]]" }
40
40
  hash
41
41
  end
@@ -52,26 +52,8 @@ format :html do
52
52
 
53
53
  view :follow_link, :tags=>:unknown_ok, :perms=>:none do |args|
54
54
  hash = follow_link_hash args
55
- text = %[<span class="follow-verb">#{hash[:verb]}</span> #{args[:label]}]
56
- opts = {
57
- :title => hash[:title],
58
- :class => "follow-toggle #{hash[:class]}",
59
- 'data-follow' => JSON(hash),
60
- 'data-rule_name' => card.default_follow_set_card.follow_rule_name( Auth.current.name ).to_name.url_key,
61
- 'data-card_key' => card.key
62
- }
63
- link_to text, '', opts
64
- end
65
-
66
- def default_follow_link_args args
67
- args[:toggle] ||= card.followed? ? :off : :on
68
- args[:label] ||= card.follow_label
69
- end
70
-
71
-
72
- view :follow_modal_link, :tags=>:unknown_ok, :perms=>:none do |args|
73
- hash = follow_link_hash args
74
- text = %[#{glyphicon 'flag'}<span class="follow-verb menu-item-label">#{hash[:verb]}</span>]
55
+ text = args[:icon] ? glyphicon('flag') : ''
56
+ text += %[<span class="follow-verb menu-item-label">#{hash[:verb]}</span>].html_safe
75
57
  follow_rule_card = Card.fetch(card.default_follow_set_card.follow_rule_name( Auth.current.name ), :new=>{})
76
58
  opts = ( args[:html_args] || {} ).clone
77
59
  opts.merge!(
@@ -57,15 +57,31 @@ def act_card
57
57
  @supercard || self
58
58
  end
59
59
 
60
+
61
+ def followable?
62
+ true
63
+ end
64
+
65
+ def notable_change?
66
+ !supercard && current_act && Card::Auth.current_id != WagnBotID && followable?
67
+ end
68
+
69
+ event :notify_followers_after_save, :after=>:subsequent, :on=>:save, :when=>proc{ |ca| ca.notable_change? } do
70
+ notify_followers
71
+ end
72
+
73
+ # in the delete case we have to calculate the follower_stash beforehand
74
+ # but we can't pass the follower_stash through the ActiveJob queue.
75
+ # We have to deal with the notifications in the extend phase instead of the subsequent phase
60
76
  event :stash_followers, :after=>:approve, :on=>:delete do
61
77
  act_card.follower_stash ||= FollowerStash.new
62
78
  act_card.follower_stash.add_affected_card self
63
79
  end
80
+ event :notify_followers_after_delete, :after=>:extend, :on=>:delete, :when=>proc{ |ca| ca.notable_change? } do
81
+ notify_followers
82
+ end
64
83
 
65
- event :notify_followers, :after=>:extend, :when=>proc{ |c|
66
- !c.supercard and c.current_act and Card::Auth.current_id != WagnBotID
67
- } do
68
-
84
+ def notify_followers
69
85
  begin
70
86
  @current_act.reload
71
87
  @follower_stash ||= FollowerStash.new
@@ -44,33 +44,31 @@ format :html do
44
44
  end
45
45
  end
46
46
 
47
- def default_modal_content_args args
47
+ def default_follow_status_args args
48
48
  args[:card_key] ||= card.set_prototype.key
49
49
  end
50
50
 
51
- view :modal_header do |args|
51
+ view :follow_status do |args|
52
+ # #{ link_to '&times;', '', 'aria-hidden'=>true, :class=>'close update-follow-link', 'data-dismiss'=>'modal', 'data-card_key'=>args[:card_key] }
52
53
  %{
53
- #{ link_to '&times;', '', 'aria-hidden'=>true, :class=>'close update-follow-link', 'data-dismiss'=>'modal', 'data-card_key'=>args[:card_key] }
54
- <h4 class="modal-title">Get notified about changes</h4>
55
- }
56
- end
57
54
 
58
- view :modal_body do |args|
59
- wrap_with :ul, :class=>'delete-list list-group' do
60
- card.item_names.map do |option|
61
- content_tag :li, :class=>'list-group-item' do
62
- subformat(card).render_follow_item :condition=>(option == '*never' ? '*always' : option)
63
- end
64
- end.join "\n"
65
- end
66
- end
55
+ <h4>Get notified about changes</h4>
67
56
 
57
+ #{
58
+ wrap_with( :ul, :class=>'delete-list list-group') do
59
+ card.item_names.map do |option|
60
+ content_tag :li, :class=>'list-group-item' do
61
+ subformat(card).render_follow_item :condition=>(option == '*never' ? '*always' : option)
62
+ end
63
+ end.join "\n"
64
+ end
65
+ }
68
66
 
69
- view :modal_footer do |args|
70
- card_link(args[:card_key], :text=>'more options', :path_opts=>{:view=>:related, :related=>{:name=>card.name,:view=>:related_edit_rule}}, :class=>'btn update-follow-link', 'data-card_key'=>args[:card_key]) +
71
- link_to('Close', '', :class=>'btn btn-default update-follow-link', 'data-dismiss'=>'modal', 'data-card_key'=>args[:card_key])
67
+ #{ card_link(args[:card_key], :text=>'more options', :path_opts=>{:view=>:related, :related=>{:name=>card.name,:view=>:related_edit_rule}}, :class=>'btn update-follow-link', 'data-card_key'=>args[:card_key]) }
68
+ }
72
69
  end
73
70
 
71
+
74
72
  view :delete_follow_rule_button do |args|
75
73
  button_tag :type=>:submit, :class=>'btn-xs btn-item-delete btn-primary', 'aria-label'=>'Left Align' do
76
74
  tag :span, :class=>"glyphicon glyphicon-ok", 'aria-hidden'=>"true"