card 1.15.1 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +19 -16
  4. data/config/initializers/recaptcha.rb +1 -0
  5. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +13 -14
  6. data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +30 -0
  7. data/db/migrate_core_cards/20150331135745_new_card_menu.rb +8 -0
  8. data/db/migrate_core_cards/20150508212032_menu_compatibility.rb +27 -0
  9. data/db/migrate_core_cards/20150510031118_fix_skin_images.rb +13 -0
  10. data/db/migrate_core_cards/data/1.12_stylesheets/classic_cards.scss +9 -5
  11. data/db/migrate_core_cards/data/1.12_stylesheets/common.scss +5 -5
  12. data/{test/fixtures/.gitkeep → db/migrate_core_cards/data/themes/bootstrap_default/_bootswatch.scss} +0 -0
  13. data/db/migrate_core_cards/data/themes/bootstrap_default/_variables.scss +866 -0
  14. data/db/migrate_core_cards/data/themes/cerulean/_bootswatch.scss +125 -0
  15. data/db/migrate_core_cards/data/themes/cerulean/_variables.scss +861 -0
  16. data/db/migrate_core_cards/data/themes/cosmo/_bootswatch.scss +237 -0
  17. data/db/migrate_core_cards/data/themes/cosmo/_variables.scss +861 -0
  18. data/db/migrate_core_cards/data/themes/cyborg/_bootswatch.scss +210 -0
  19. data/db/migrate_core_cards/data/themes/cyborg/_variables.scss +861 -0
  20. data/db/migrate_core_cards/data/themes/darkly/_bootswatch.scss +330 -0
  21. data/db/migrate_core_cards/data/themes/darkly/_variables.scss +861 -0
  22. data/db/migrate_core_cards/data/themes/flatly/_bootswatch.scss +313 -0
  23. data/db/migrate_core_cards/data/themes/flatly/_variables.scss +861 -0
  24. data/db/migrate_core_cards/data/themes/journal/_bootswatch.scss +120 -0
  25. data/db/migrate_core_cards/data/themes/journal/_variables.scss +861 -0
  26. data/db/migrate_core_cards/data/themes/lumen/_bootswatch.scss +496 -0
  27. data/db/migrate_core_cards/data/themes/lumen/_variables.scss +861 -0
  28. data/db/migrate_core_cards/data/themes/paper/_bootswatch.scss +607 -0
  29. data/db/migrate_core_cards/data/themes/paper/_variables.scss +861 -0
  30. data/db/migrate_core_cards/data/themes/readable/_bootswatch.scss +174 -0
  31. data/db/migrate_core_cards/data/themes/readable/_variables.scss +861 -0
  32. data/db/migrate_core_cards/data/themes/sandstone/_bootswatch.scss +194 -0
  33. data/db/migrate_core_cards/data/themes/sandstone/_variables.scss +861 -0
  34. data/db/migrate_core_cards/data/themes/simplex/_bootswatch.scss +142 -0
  35. data/db/migrate_core_cards/data/themes/simplex/_variables.scss +861 -0
  36. data/db/migrate_core_cards/data/themes/slate/_bootswatch.scss +417 -0
  37. data/db/migrate_core_cards/data/themes/slate/_variables.scss +861 -0
  38. data/db/migrate_core_cards/data/themes/spacelab/_bootswatch.scss +137 -0
  39. data/db/migrate_core_cards/data/themes/spacelab/_variables.scss +861 -0
  40. data/db/migrate_core_cards/data/themes/superhero/_bootswatch.scss +332 -0
  41. data/db/migrate_core_cards/data/themes/superhero/_variables.scss +861 -0
  42. data/db/migrate_core_cards/data/themes/united/_bootswatch.scss +42 -0
  43. data/db/migrate_core_cards/data/themes/united/_variables.scss +861 -0
  44. data/db/migrate_core_cards/data/themes/yeti/_bootswatch.scss +437 -0
  45. data/db/migrate_core_cards/data/themes/yeti/_variables.scss +861 -0
  46. data/db/seed/README.md +2 -0
  47. data/db/{bootstrap → seed/new}/card_actions.yml +561 -295
  48. data/db/{bootstrap → seed/new}/card_acts.yml +1 -1
  49. data/db/seed/new/card_changes.yml +29331 -0
  50. data/db/{bootstrap → seed/new}/card_references.yml +1544 -1355
  51. data/db/seed/new/cards.yml +28057 -0
  52. data/db/seed/test/fixtures/.gitkeep +0 -0
  53. data/{test → db/seed/test}/fixtures/card_actions.yml +1501 -1235
  54. data/{test → db/seed/test}/fixtures/card_acts.yml +244 -244
  55. data/db/seed/test/fixtures/card_changes.yml +34527 -0
  56. data/{test → db/seed/test}/fixtures/card_references.yml +2215 -2026
  57. data/db/seed/test/fixtures/cards.yml +32708 -0
  58. data/{test → db/seed/test}/fixtures/mao2.jpg +0 -0
  59. data/{test → db/seed/test}/fixtures/rails.gif +0 -0
  60. data/{test → db/seed/test}/seed.rb +0 -0
  61. data/db/version_core_cards.txt +1 -1
  62. data/lib/card/format.rb +56 -56
  63. data/lib/cardio.rb +7 -5
  64. data/mod/01_core/chunk/include.rb +1 -1
  65. data/mod/01_core/set/all/fetch.rb +27 -27
  66. data/mod/01_core/set/all/rules.rb +53 -53
  67. data/mod/01_core/set/all/states.rb +5 -0
  68. data/mod/01_core/spec/format/html_format_spec.rb +6 -6
  69. data/mod/01_core/spec/set/all/rules2_spec.rb +6 -6
  70. data/mod/01_history/set/all/history.rb +4 -4
  71. data/mod/02_basic_types/set/all/rss.rb +10 -9
  72. data/mod/03_machines/lib/javascript/script_card_menu.js.coffee +20 -0
  73. data/mod/03_machines/lib/javascript/wagn.js.coffee +46 -34
  74. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +36 -148
  75. data/mod/03_machines/lib/stylesheets/style_bootstrap_compatible.css +10 -96
  76. data/mod/03_machines/lib/stylesheets/style_cards.scss +127 -87
  77. data/mod/03_machines/set/self/script_card_menu.rb +10 -2
  78. data/mod/05_email/set/all/follow.rb +38 -22
  79. data/mod/05_email/set/right/follow.rb +79 -1
  80. data/mod/05_email/set/type_plus_right/user/follow.rb +31 -31
  81. data/mod/05_email/spec/set/all/follow_spec.rb +37 -28
  82. data/mod/05_email/spec/set/right/followers_spec.rb +29 -29
  83. data/mod/05_standard/set/all/error.rb +17 -20
  84. data/mod/05_standard/set/all/links.rb +31 -18
  85. data/mod/05_standard/set/all/rich_html/content.rb +41 -18
  86. data/mod/05_standard/set/all/rich_html/editing.rb +21 -17
  87. data/mod/05_standard/set/all/rich_html/header.rb +13 -48
  88. data/mod/05_standard/set/all/rich_html/menu.rb +147 -0
  89. data/mod/05_standard/set/all/rich_html/modal.rb +54 -0
  90. data/mod/05_standard/set/all/rich_html/toolbar.rb +237 -0
  91. data/mod/05_standard/set/all/rich_html/wrapper.rb +43 -25
  92. data/mod/05_standard/set/right/account.rb +8 -7
  93. data/mod/05_standard/set/rstar/rules.rb +111 -84
  94. data/mod/05_standard/set/self/head.rb +15 -15
  95. data/mod/05_standard/set/type/set.rb +65 -34
  96. data/mod/05_standard/spec/set/all/attach_spec.rb +1 -1
  97. data/mod/05_standard/spec/set/all/rich_html/wrapper_spec.rb +13 -9
  98. data/mod/05_standard/spec/set/rstar/rules_spec.rb +1 -1
  99. data/mod/06_bootstrap/lib/javascript/bootstrap.js +108 -97
  100. data/mod/06_bootstrap/lib/javascript/smartmenu.js +94 -0
  101. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_alerts.scss +73 -0
  102. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_badges.scss +68 -0
  103. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_breadcrumbs.scss +26 -0
  104. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_button-groups.scss +243 -0
  105. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_buttons.scss +160 -0
  106. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_carousel.scss +269 -0
  107. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_close.scss +36 -0
  108. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_code.scss +69 -0
  109. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_component-animations.scss +37 -0
  110. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_dropdowns.scss +214 -0
  111. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_forms.scss +578 -0
  112. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_glyphicons.scss +305 -0
  113. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_grid.scss +84 -0
  114. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_input-groups.scss +166 -0
  115. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_jumbotron.scss +50 -0
  116. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_labels.scss +66 -0
  117. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_list-group.scss +124 -0
  118. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_media.scss +61 -0
  119. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_mixins.scss +39 -0
  120. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_modals.scss +150 -0
  121. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_navbar.scss +662 -0
  122. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_navs.scss +242 -0
  123. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_normalize.scss +427 -0
  124. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_pager.scss +54 -0
  125. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_pagination.scss +88 -0
  126. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_panels.scss +265 -0
  127. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_popovers.scss +135 -0
  128. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_print.scss +107 -0
  129. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_progress-bars.scss +87 -0
  130. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_responsive-embed.scss +35 -0
  131. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_responsive-utilities.scss +177 -0
  132. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_scaffolding.scss +162 -0
  133. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_tables.scss +234 -0
  134. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_theme.scss +273 -0
  135. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_thumbnails.scss +38 -0
  136. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_tooltip.scss +102 -0
  137. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_type.scss +298 -0
  138. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_utilities.scss +55 -0
  139. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_variables.scss +866 -0
  140. data/mod/06_bootstrap/lib/stylesheets/bootstrap/_wells.scss +29 -0
  141. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_alerts.scss +14 -0
  142. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_background-variant.scss +11 -0
  143. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_border-radius.scss +18 -0
  144. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_buttons.scss +52 -0
  145. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_center-block.scss +7 -0
  146. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_clearfix.scss +22 -0
  147. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_forms.scss +88 -0
  148. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_gradients.scss +58 -0
  149. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_grid-framework.scss +81 -0
  150. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_grid.scss +122 -0
  151. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_hide-text.scss +21 -0
  152. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_image.scss +33 -0
  153. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_labels.scss +12 -0
  154. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_list-group.scss +31 -0
  155. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
  156. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +9 -0
  157. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_opacity.scss +8 -0
  158. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_pagination.scss +23 -0
  159. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_panels.scss +24 -0
  160. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_progress-bar.scss +10 -0
  161. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_reset-filter.scss +8 -0
  162. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_resize.scss +6 -0
  163. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_responsive-visibility.scss +21 -0
  164. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_size.scss +10 -0
  165. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_tab-focus.scss +9 -0
  166. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_table-row.scss +28 -0
  167. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_text-emphasis.scss +11 -0
  168. data/mod/06_bootstrap/lib/stylesheets/bootstrap/mixins/_text-overflow.scss +8 -0
  169. data/mod/06_bootstrap/lib/stylesheets/{bootswatch_mixins.scss → bootstrap/mixins/_vendor-prefixes.scss} +1 -61
  170. data/mod/06_bootstrap/lib/stylesheets/bootstrap_cards.scss +20 -13
  171. data/mod/06_bootstrap/lib/stylesheets/smartmenu.css +433 -0
  172. data/mod/06_bootstrap/set/all/bootstrap/wrapper.rb +2 -2
  173. data/mod/06_bootstrap/set/all/rich_bootstrap.rb +58 -4
  174. data/mod/06_bootstrap/set/self/bootstrap_js.rb +1 -1
  175. data/mod/06_bootstrap/set/self/bootswatch_shared.rb +32 -0
  176. data/mod/06_bootstrap/set/self/smartmenu_css.rb +7 -0
  177. data/mod/06_bootstrap/set/self/smartmenu_js.rb +7 -0
  178. data/spec/spec_helper.rb +16 -16
  179. metadata +133 -93
  180. data/db/bootstrap/card_changes.yml +0 -12765
  181. data/db/bootstrap/cards.yml +0 -11567
  182. data/db/seeds.rb +0 -8
  183. data/mod/03_machines/lib/javascript/script_card_menu.js +0 -72
  184. data/mod/06_bootstrap/lib/stylesheets/bootstrap_css.css +0 -6565
  185. data/mod/06_bootstrap/lib/stylesheets/theme_bootstrap_default.css +0 -476
  186. data/mod/06_bootstrap/lib/stylesheets/theme_cerulean.css +0 -6721
  187. data/mod/06_bootstrap/lib/stylesheets/theme_cosmo.css +0 -5898
  188. data/mod/06_bootstrap/lib/stylesheets/theme_cyborg.css +0 -5876
  189. data/mod/06_bootstrap/lib/stylesheets/theme_darkly.css +0 -5986
  190. data/mod/06_bootstrap/lib/stylesheets/theme_flatly.css +0 -6830
  191. data/mod/06_bootstrap/lib/stylesheets/theme_journal.css +0 -6647
  192. data/mod/06_bootstrap/lib/stylesheets/theme_lumen.css +0 -6097
  193. data/mod/06_bootstrap/lib/stylesheets/theme_paper.css +0 -6647
  194. data/mod/06_bootstrap/lib/stylesheets/theme_readable.css +0 -5896
  195. data/mod/06_bootstrap/lib/stylesheets/theme_sandstone.css +0 -6733
  196. data/mod/06_bootstrap/lib/stylesheets/theme_simplex.css +0 -5886
  197. data/mod/06_bootstrap/lib/stylesheets/theme_slate.css +0 -7057
  198. data/mod/06_bootstrap/lib/stylesheets/theme_spacelab.css +0 -5935
  199. data/mod/06_bootstrap/lib/stylesheets/theme_superhero.css +0 -5964
  200. data/mod/06_bootstrap/lib/stylesheets/theme_united.css +0 -6588
  201. data/mod/06_bootstrap/lib/stylesheets/theme_yeti.css +0 -6088
  202. data/mod/06_bootstrap/set/self/bootstrap_css.rb +0 -9
  203. data/mod/06_bootstrap/set/self/bootswatch_mixins.rb +0 -9
  204. data/mod/06_bootstrap/set/self/theme_bootstrap_default.rb +0 -2
  205. data/mod/06_bootstrap/set/self/theme_cerulean.rb +0 -9
  206. data/mod/06_bootstrap/set/self/theme_cosmo.rb +0 -2
  207. data/mod/06_bootstrap/set/self/theme_cyborg.rb +0 -2
  208. data/mod/06_bootstrap/set/self/theme_darkly.rb +0 -2
  209. data/mod/06_bootstrap/set/self/theme_flatly.rb +0 -2
  210. data/mod/06_bootstrap/set/self/theme_journal.rb +0 -2
  211. data/mod/06_bootstrap/set/self/theme_lumen.rb +0 -2
  212. data/mod/06_bootstrap/set/self/theme_paper.rb +0 -2
  213. data/mod/06_bootstrap/set/self/theme_readable.rb +0 -2
  214. data/mod/06_bootstrap/set/self/theme_sandstone.rb +0 -2
  215. data/mod/06_bootstrap/set/self/theme_simplex.rb +0 -2
  216. data/mod/06_bootstrap/set/self/theme_slate.rb +0 -2
  217. data/mod/06_bootstrap/set/self/theme_spacelab.rb +0 -2
  218. data/mod/06_bootstrap/set/self/theme_superhero.rb +0 -2
  219. data/mod/06_bootstrap/set/self/theme_united.rb +0 -2
  220. data/mod/06_bootstrap/set/self/theme_yeti.rb +0 -2
  221. data/test/fixtures/card_changes.yml +0 -17961
  222. data/test/fixtures/cards.yml +0 -16218
@@ -1,7 +1,7 @@
1
1
  RuleSQL = %{
2
2
  select rules.id as rule_id, settings.id as setting_id, sets.id as set_id, sets.left_id as anchor_id, sets.right_id as set_tag_id
3
- from cards rules
4
- join cards sets on rules.left_id = sets.id
3
+ from cards rules
4
+ join cards sets on rules.left_id = sets.id
5
5
  join cards settings on rules.right_id = settings.id
6
6
  where sets.type_id = #{Card::SetID } and sets.trash is false
7
7
  and settings.type_id = #{Card::SettingID} and settings.trash is false
@@ -11,8 +11,8 @@ RuleSQL = %{
11
11
 
12
12
  ReadRuleSQL = %{
13
13
  select refs.referee_id as party_id, read_rules.id as read_rule_id
14
- from cards read_rules
15
- join card_references refs on refs.referer_id = read_rules.id
14
+ from cards read_rules
15
+ join card_references refs on refs.referer_id = read_rules.id
16
16
  join cards sets on read_rules.left_id = sets.id
17
17
  where read_rules.right_id = #{Card::ReadID} and read_rules.trash is false and sets.type_id = #{Card::SetID};
18
18
  }
@@ -34,7 +34,7 @@ def is_user_rule?
34
34
  (r = right( :skip_modules=>true )) &&
35
35
  r.type_id == Card::SettingID &&
36
36
  (set = self[0..-3, :skip_modules=>true]) &&
37
- set.type_id == Card::SetID &&
37
+ set.type_id == Card::SetID &&
38
38
  (user = self[-2, :skip_modules=>true] ) &&
39
39
  (user.type_id == Card::UserID || user.codename == 'all' )
40
40
  end
@@ -52,15 +52,15 @@ end
52
52
 
53
53
  def rule_card_id setting_code, options={}
54
54
  fallback = options.delete( :fallback )
55
-
56
- if Card::Setting.user_specific? setting_code
55
+
56
+ if Card::Setting.user_specific? setting_code
57
57
  user_id = options[:user_id] || (options[:user] and options[:user].id) || Auth.current_id
58
58
  if user_id
59
59
  fallback = "#{setting_code}+#{Card[:all].id}"
60
60
  setting_code = "#{setting_code}+#{user_id}"
61
61
  end
62
62
  end
63
-
63
+
64
64
  rule_set_keys.each do |rule_set_key|
65
65
  rule_id = self.class.rule_cache["#{rule_set_key}+#{setting_code}"]
66
66
  rule_id ||= fallback && self.class.rule_cache["#{rule_set_key}+#{fallback}"]
@@ -74,9 +74,9 @@ def related_sets
74
74
 
75
75
  sets = []
76
76
  sets << ["#{name}+*type", Card::TypeSet.label( name) ] if known? && type_id==Card::CardtypeID
77
- sets << ["#{name}+*self", Card::SelfSet.label( name) ]
77
+ #sets << ["#{name}+*self", Card::SelfSet.label( name) ]
78
78
  sets << ["#{name}+*right", Card::RightSet.label(name) ] if known? && cardname.simple?
79
-
79
+
80
80
  # Card.search(:type=>'Set',:left=>{:right=>name},:right=>'*type plus right',:return=>'name').each do |set_name|
81
81
  # sets<< set_name
82
82
  # end
@@ -86,7 +86,7 @@ end
86
86
 
87
87
 
88
88
  module ClassMethods
89
-
89
+
90
90
  # User-specific rule use the pattern
91
91
  # user+set+setting
92
92
  def user_rule_sql user_id=nil
@@ -97,33 +97,33 @@ module ClassMethods
97
97
  end
98
98
 
99
99
  %{
100
- select
101
- user_rules.id as rule_id,
102
- settings.id as setting_id,
103
- sets.id as set_id,
104
- sets.left_id as anchor_id,
100
+ select
101
+ user_rules.id as rule_id,
102
+ settings.id as setting_id,
103
+ sets.id as set_id,
104
+ sets.left_id as anchor_id,
105
105
  sets.right_id as set_tag_id,
106
106
  users.id as user_id
107
- from cards user_rules
108
- join cards user_sets on user_rules.left_id = user_sets.id
107
+ from cards user_rules
108
+ join cards user_sets on user_rules.left_id = user_sets.id
109
109
  join cards settings on user_rules.right_id = settings.id
110
- join cards users on user_sets.right_id = users.id
111
- join cards sets on user_sets.left_id = sets.id
110
+ join cards users on user_sets.right_id = users.id
111
+ join cards sets on user_sets.left_id = sets.id
112
112
  where sets.type_id = #{Card::SetID } and sets.trash is false
113
113
  and settings.type_id = #{Card::SettingID} and settings.trash is false
114
114
  and ( #{user_restriction} or users.codename = 'all' ) and users.trash is false
115
115
  and user_sets.trash is false
116
116
  and user_rules.trash is false;
117
- }
117
+ }
118
118
  end
119
-
120
-
119
+
120
+
121
121
  def setting name
122
122
  Auth.as_bot do
123
123
  card=Card[name] and !card.db_content.strip.empty? and card.db_content
124
124
  end
125
125
  end
126
-
126
+
127
127
  def path_setting name #shouldn't this be in location helper?
128
128
  name ||= '/'
129
129
  return name if name =~ /^(http|mailto)/
@@ -136,14 +136,14 @@ module ClassMethods
136
136
 
137
137
  def cache_key row
138
138
  setting_code = Card::Codename[ row['setting_id'].to_i ] or return false
139
-
139
+
140
140
  anchor_id = row['anchor_id']
141
141
  set_class_id = anchor_id.nil? ? row['set_id'] : row['set_tag_id']
142
142
  set_class_code = Card::Codename[ set_class_id.to_i ] or return false
143
-
143
+
144
144
  key_base = [ anchor_id, set_class_code, setting_code].compact.map( &:to_s ) * '+'
145
145
  end
146
-
146
+
147
147
  def all_rule_keys_with_id
148
148
  ActiveRecord::Base.connection.select_all(RuleSQL).each do |row|
149
149
  if key = cache_key(row)
@@ -151,7 +151,7 @@ module ClassMethods
151
151
  end
152
152
  end
153
153
  end
154
-
154
+
155
155
  def all_user_rule_keys_with_id_and_user_id
156
156
  ActiveRecord::Base.connection.select_all(user_rule_sql).each do |row|
157
157
  if key = cache_key(row) and user_id = row['user_id']
@@ -159,7 +159,7 @@ module ClassMethods
159
159
  end
160
160
  end
161
161
  end
162
-
162
+
163
163
  def all_rule_keys_with_id_for user_id
164
164
  ActiveRecord::Base.connection.select_all(user_rule_sql(user_id)).each do |row|
165
165
  if key = cache_key(row)
@@ -171,7 +171,7 @@ module ClassMethods
171
171
  def cached_rule_keys_for user_id
172
172
  rule_keys_cache[user_id] || []
173
173
  end
174
-
174
+
175
175
  def all_user_ids_with_rule_for set_card, setting_code
176
176
  key = if (l=set_card.left) and (r=set_card.right)
177
177
  set_class_code = Card::Codename[ r.id ]
@@ -186,20 +186,20 @@ module ClassMethods
186
186
  else
187
187
  user_ids
188
188
  end
189
-
189
+
190
190
  end
191
-
191
+
192
192
  def user_rule_cards user_name, setting_code
193
193
  Card.search :right=>{:codename=>setting_code}, :left=>{:left=>{:type_id=>SetID}, :right=>user_name}
194
194
  end
195
-
195
+
196
196
  def rule_cache
197
- Card.cache.read('RULES') || begin
197
+ Card.cache.read('RULES') || begin
198
198
  rule_hash = {}
199
199
  all_rule_keys_with_id do |key,rule_id|
200
200
  rule_hash[key] = rule_id
201
201
  end
202
-
202
+
203
203
  user_ids_hash = {}
204
204
  rule_keys_hash = {}
205
205
  all_user_rule_keys_with_id_and_user_id do |key, rule_id, user_id|
@@ -214,11 +214,11 @@ module ClassMethods
214
214
  write_rule_cache rule_hash
215
215
  end
216
216
  end
217
-
217
+
218
218
  def user_rule_key key, user_id
219
219
  "#{key}+#{user_id}"
220
220
  end
221
-
221
+
222
222
  # all users that have a user-specific rule for a given rule key
223
223
  def user_ids_cache
224
224
  Card.cache.read('USER_IDS') || begin
@@ -226,7 +226,7 @@ module ClassMethods
226
226
  Card.cache.read('USER_IDS')
227
227
  end
228
228
  end
229
-
229
+
230
230
  # all keys of user-specific rules for a given user
231
231
  def rule_keys_cache
232
232
  Card.cache.read('RULE_KEYS') || begin
@@ -234,31 +234,31 @@ module ClassMethods
234
234
  Card.cache.read('RULE_KEYS')
235
235
  end
236
236
  end
237
-
237
+
238
238
  def clear_rule_cache
239
239
  write_rule_cache nil
240
240
  write_user_ids_cache nil
241
241
  write_rule_keys_cache nil
242
242
  end
243
-
243
+
244
244
  def clear_user_rule_cache
245
245
  clear_rule_cache
246
246
  end
247
-
247
+
248
248
  def refresh_rule_cache_for_user user_id
249
249
  rule_hash = rule_cache
250
250
  user_ids_hash = user_ids_cache
251
251
  rule_keys_hash = rule_keys_cache
252
-
252
+
253
253
  cached_rule_keys_for(user_id).each do |key|
254
254
  rule_hash[ user_rule_key(key, user_id) ] = nil
255
255
  user_ids_hash[ key ].delete(user_id)
256
256
  end
257
257
  rule_keys_hash[ user_id ] = nil
258
-
258
+
259
259
  all_rule_keys_with_id_for(user_id) do |key, rule_id|
260
260
  rule_hash[ user_rule_key(key,user_id) ] = rule_id
261
-
261
+
262
262
  user_ids_hash[ key ] ||= []
263
263
  user_ids_hash[ key ] << user_id
264
264
  rule_keys_hash[ user_id ] ||= []
@@ -268,21 +268,21 @@ module ClassMethods
268
268
  write_rule_keys_cache rule_keys_hash
269
269
  write_rule_cache rule_hash
270
270
  end
271
-
271
+
272
272
  def write_rule_cache hash
273
273
  Card.cache.write 'RULES', hash
274
274
  end
275
-
275
+
276
276
  def write_user_ids_cache hash
277
277
  Card.cache.write 'USER_IDS', hash
278
278
  end
279
-
279
+
280
280
  def write_rule_keys_cache hash
281
281
  Card.cache.write 'RULE_KEYS', hash
282
282
  end
283
-
284
-
285
-
283
+
284
+
285
+
286
286
  def read_rule_cache
287
287
  Card.cache.read('READRULES') || begin
288
288
  hash = {}
@@ -294,11 +294,11 @@ module ClassMethods
294
294
  Card.cache.write 'READRULES', hash
295
295
  end
296
296
  end
297
-
297
+
298
298
  def clear_read_rule_cache
299
299
  Card.cache.write 'READRULES', nil
300
300
  end
301
- =begin
301
+ =begin
302
302
  def default_rule setting_code, fallback=nil
303
303
  card = default_rule_card setting_code, fallback
304
304
  return card && card.content
@@ -309,7 +309,7 @@ module ClassMethods
309
309
  rule_id ||= fallback && rule_cache["all+#{fallback}"]
310
310
  Card[rule_id] if rule_id
311
311
  end
312
- =end
312
+ =end
313
313
  end
314
314
 
315
315
 
@@ -1,6 +1,7 @@
1
1
  def new_card?
2
2
  new_record? || !!@from_trash
3
3
  end
4
+ alias_method :new?, :new_card?
4
5
 
5
6
  def known?
6
7
  real? || virtual?
@@ -10,6 +11,10 @@ def real?
10
11
  !new_card?
11
12
  end
12
13
 
14
+ def unknown?
15
+ !known?
16
+ end
17
+
13
18
  def pristine?
14
19
  # has not been edited directly by human users. bleep blorp.
15
20
  new_card? or !actions.joins(:act).where('card_acts.actor_id != ?', Card::WagnBotID).exists?
@@ -63,7 +63,7 @@ describe Card::HtmlFormat do
63
63
  it "renders card content" do
64
64
  assert_view_select @simple_page, 'div[class="card-body panel-body card-content ALL ALL_PLUS TYPE-basic RIGHT-b TYPE_PLUS_RIGHT-basic-b SELF-a-b"]', 'AlphaBeta'
65
65
  end
66
-
66
+
67
67
  it "renders card credit" do
68
68
  assert_view_select @simple_page, 'div[class~="SELF-Xcredit"]' do#, /Wheeled by/ do
69
69
  assert_select 'img'
@@ -81,7 +81,7 @@ describe Card::HtmlFormat do
81
81
  c = Card['*all+*layout'] and c.content = '[[tmp layout]]'
82
82
  @main_card = Card.fetch('Joe User')
83
83
  Card::Env[:main_name] = @main_card.name
84
-
84
+
85
85
  #warn "lay #{@layout_card.inspect}, #{@main_card.inspect}"
86
86
  end
87
87
 
@@ -115,20 +115,20 @@ describe Card::HtmlFormat do
115
115
  @layout_card.content="Mainly {{_main|core}}"
116
116
  Card::Auth.as_bot { @layout_card.save }
117
117
 
118
- rendered = expect(@layout_card.format.render(:layout)).to eq(
118
+ rendered = expect(@layout_card.format.render(:layout)).to eq(
119
119
  %{Mainly <div id="main"><div class="CodeRay">\n <div class="code"><pre>Mainly {{_main|core}}</pre></div>\n</div>\n</div>}
120
120
  )
121
121
  #probably better to check that it matches "Mainly" exactly twice.
122
122
  end
123
-
124
-
123
+
124
+
125
125
  it "should handle nested _main references" do
126
126
  Card::Auth.as_bot do
127
127
  @layout_card.content="{{outer space|core}}"
128
128
  @layout_card.save!
129
129
  Card.create :name=>"outer space", :content=>"{{_main|name}}"
130
130
  end
131
-
131
+
132
132
  expect(@layout_card.format.render(:layout)).to eq('Joe User')
133
133
  end
134
134
  end
@@ -44,13 +44,13 @@ describe Card do
44
44
  end
45
45
 
46
46
  describe ".related_sets" do
47
- it "should have 2 sets (self and right) for a simple card" do
47
+ it "has 1 set (right) for a simple card" do
48
48
  sets = Card['A'].related_sets.map { |s| s[0] }
49
- expect(sets).to eq(['A+*self', 'A+*right'])
49
+ expect(sets).to eq(['A+*right'])
50
50
  end
51
- it "should have 3 sets (self, type, and right) for a cardtype card" do
51
+ it "has 2 sets (type, and right) for a cardtype card" do
52
52
  sets = Card['Cardtype A'].related_sets.map { |s| s[0] }
53
- expect(sets).to eq(['Cardtype A+*type', 'Cardtype A+*self', 'Cardtype A+*right'])
53
+ expect(sets).to eq(['Cardtype A+*type', 'Cardtype A+*right'])
54
54
  end
55
55
  # it "should show type plus right sets when they exist" do
56
56
  # Card::Auth.as_bot { Card.create :name=>'Basic+A+*type plus right', :content=>'' }
@@ -62,9 +62,9 @@ describe Card do
62
62
  # sets = Card['Cardtype A'].related_sets
63
63
  # sets.should == ['Cardtype A+*self', 'Cardtype A+*type', 'Cardtype A+*right', 'Basic+Cardtype A+*type plus right']
64
64
  # end
65
- it "should have sets for a non-simple card" do
65
+ it "is empty for a non-simple card" do
66
66
  sets = Card['A+B'].related_sets.map { |s| s[0] }
67
- expect(sets).to eq(['A+B+*self'])
67
+ expect(sets).to eq([])
68
68
  end
69
69
  end
70
70
  =begin
@@ -95,7 +95,7 @@ end
95
95
 
96
96
  format :html do
97
97
  view :history do |args|
98
- frame args.merge(:body_class=>"history-slot list-group", :content=>true, :subheader=>_render_revision_subheader ) do
98
+ frame args.merge(:body_class=>"history-slot list-group", :content=>true, :subheader=>revision_subheader ) do
99
99
  _render_revisions
100
100
  end
101
101
  end
@@ -109,7 +109,7 @@ format :html do
109
109
  end.join
110
110
  end
111
111
 
112
- view :revision_subheader do |args|
112
+ def revision_subheader
113
113
  intr = card.intrusive_acts.page(params['page']).per(REVISIONS_PER_PAGE)
114
114
  render_haml :intr=>intr do
115
115
  %{
@@ -195,7 +195,7 @@ format :html do
195
195
  link_to name_changes(action, hide_diff),
196
196
  path(:view=>:related, :related=>{:view=>"history",:name=>action.card.name}),
197
197
  :class=>'slotter label-label-default',
198
- :slotSelector=>".card-slot.card-frame",
198
+ 'data-slot-selector'=>".card-slot.history-view",
199
199
  :remote=>true
200
200
  end
201
201
 
@@ -275,7 +275,7 @@ format :html do
275
275
  def rollback_link action_ids
276
276
  if card.ok?(:update)
277
277
  "| " + link_to('Save as current', path(:action=>:update, :view=>:open, :action_ids=>action_ids),
278
- :class=>'slotter',:slotSelector=>'.card-slot.card-frame', :remote=>true, :method=>:post, :rel=>'nofollow')
278
+ :class=>'slotter','data-slot-selector'=>'.card-slot.history-view', :remote=>true, :method=>:post, :rel=>'nofollow')
279
279
  end
280
280
  end
281
281
 
@@ -1,15 +1,16 @@
1
1
 
2
+
2
3
  format :rss do
3
-
4
+
4
5
  attr_accessor :xml
5
-
6
+
6
7
  def initialize card, args
7
8
  super
8
9
  @xml = @parent.xml if @parent
9
10
  end
10
11
 
11
12
  def show view, args
12
- @xml = Builder::XmlMarkup.new
13
+ @xml = ::Builder::XmlMarkup.new
13
14
  view ||= :feed
14
15
  render view, args
15
16
  end
@@ -30,7 +31,7 @@ format :rss do
30
31
  @xml.error "\n\nERROR rendering RSS: #{e.inspect}\n\n #{e.backtrace}"
31
32
  end
32
33
  end
33
-
34
+
34
35
  view :feed_item_list do |args|
35
36
  items = if card.type_id == Card::SearchTypeID #FIXME! yuck.
36
37
  card.item_cards( search_params.merge(:default_limit => 25) )
@@ -43,12 +44,12 @@ format :rss do
43
44
  end
44
45
  end
45
46
  end
46
-
47
-
47
+
48
+
48
49
  view :feed_title do |args|
49
50
  Card.setting(:title) + " : " + card.name.gsub(/^\*/,'')
50
51
  end
51
-
52
+
52
53
  view :feed_item do |args|
53
54
  @xml.title card.name
54
55
  add_name_context
@@ -62,8 +63,8 @@ format :rss do
62
63
  view :feed_description do |args| '' end
63
64
  view :comment_box do |args| '' end
64
65
  view :menu do |args| '' end
65
-
66
-
66
+
67
+
67
68
  view :open, { :view=>:titled, :mod=>All::Base::Format }
68
69
  view :content, { :view=>:core, :mod=>All::Base::Format }
69
70
  view :open_content, { :view=>:core, :mod=>All::Base::Format }