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
File without changes
File without changes
@@ -1 +1 @@
1
- 20150317162412
1
+ 20150510031118
@@ -6,7 +6,7 @@ class Card
6
6
  DEPRECATED_VIEWS = { :view=>:open, :card=>:open, :line=>:closed, :bare=>:core, :naked=>:core }
7
7
  INCLUSION_MODES = { :closed=>:closed, :closed_content=>:closed, :edit=>:edit,
8
8
  :layout=>:layout, :new=>:edit, :setup=>:edit, :normal=>:normal, :template=>:template } #should be set in views
9
-
9
+
10
10
  cattr_accessor :ajax_call, :registered
11
11
  [ :perms, :denial_views, :closed_views, :error_codes, :view_tags, :aliases ].each do |acc|
12
12
  cattr_accessor acc
@@ -15,14 +15,14 @@ class Card
15
15
 
16
16
  attr_reader :card, :root, :parent, :main_opts
17
17
  attr_accessor :form, :error_status, :inclusion_opts
18
-
18
+
19
19
  class << self
20
20
  @@registered = []
21
21
 
22
22
  def register format
23
23
  @@registered << format.to_s
24
24
  end
25
-
25
+
26
26
  def format_class_name format
27
27
  format = format.to_s
28
28
  format = '' if format == 'base'
@@ -30,7 +30,7 @@ class Card
30
30
  "#{ format.camelize }Format"
31
31
  end
32
32
 
33
-
33
+
34
34
 
35
35
  def extract_class_vars view, opts
36
36
  return unless opts.present?
@@ -56,12 +56,12 @@ class Card
56
56
  self == klass ? super : klass.new( card, opts )
57
57
  end
58
58
  end
59
-
59
+
60
60
  def tagged view, tag
61
61
  view and tag and view_tags = @@view_tags[view.to_sym] and view_tags[tag.to_sym]
62
62
  end
63
-
64
-
63
+
64
+
65
65
  def format_ancestry
66
66
  ancestry = [ self ]
67
67
  unless self == Card::Format
@@ -75,7 +75,7 @@ class Card
75
75
  end
76
76
  end
77
77
 
78
-
78
+
79
79
  #~~~~~ INSTANCE METHODS
80
80
 
81
81
  def initialize card, opts={}
@@ -92,20 +92,20 @@ class Card
92
92
  include_set_format_modules
93
93
  self
94
94
  end
95
-
96
- def get_context_names
95
+
96
+ def get_context_names
97
97
  case
98
98
  when @context_names
99
99
  part_keys = @card.cardname.part_names.map &:key
100
100
  @context_names.reject { |n| !part_keys.include? n.key }
101
101
  when params[:slot]
102
- context_name_list = params[:slot][:name_context].to_s
102
+ context_name_list = params[:slot][:name_context].to_s
103
103
  context_name_list.split(',').map &:to_name
104
104
  else
105
105
  []
106
106
  end
107
107
  end
108
-
108
+
109
109
  def include_set_format_modules
110
110
  self.class.format_ancestry.reverse.each do |klass|
111
111
  card.set_format_modules( klass ).each do |m|
@@ -113,7 +113,7 @@ class Card
113
113
  end
114
114
  end
115
115
  end
116
-
116
+
117
117
  def inclusion_defaults nested_card
118
118
  @inclusion_defaults ||= begin
119
119
  defaults = get_inclusion_defaults(nested_card).clone
@@ -121,19 +121,19 @@ class Card
121
121
  defaults
122
122
  end
123
123
  end
124
-
124
+
125
125
  def get_inclusion_defaults nested_card
126
126
  { :view => :name }
127
127
  end
128
-
128
+
129
129
  def params
130
130
  Env.params
131
131
  end
132
-
132
+
133
133
  def controller
134
134
  Env[:controller] ||= CardController.new
135
135
  end
136
-
136
+
137
137
  def session
138
138
  Env.session
139
139
  end
@@ -145,7 +145,7 @@ class Card
145
145
  @showname ||= card.cardname.to_show *@context_names
146
146
  end
147
147
  end
148
-
148
+
149
149
  def main?
150
150
  @depth == 0
151
151
  end
@@ -169,14 +169,14 @@ class Card
169
169
 
170
170
  def method_missing method, *opts, &proc
171
171
  case method
172
- when /(_)?(optional_)?render(_(\w+))?/
173
- view = $3 ? $4 : opts.shift
174
- args = opts[0] ? opts.shift.clone : {}
172
+ when /(_)?(optional_)?render(_(\w+))?/
173
+ view = $3 ? $4 : opts.shift
174
+ args = opts[0] ? opts.shift.clone : {}
175
175
  args.merge!( :optional=>true, :default_visibility=>opts.shift) if $2
176
176
  args[ :skip_permissions ] = true if $1
177
- render view, args
177
+ render view, args
178
178
  when /^_view_(\w+)/
179
- view = @current_view || $1
179
+ view = @current_view || $1
180
180
  unsupported_view view
181
181
  else
182
182
  proc = proc { |*a| raw yield *a } if proc
@@ -188,12 +188,12 @@ class Card
188
188
  #
189
189
  # ---------- Rendering ------------
190
190
  #
191
-
192
-
191
+
192
+
193
193
 
194
194
  def render view, args={}
195
195
  unless args.delete(:optional) && !show_view?( view, args )
196
- @current_view = view = ok_view canonicalize_view( view ), args
196
+ @current_view = view = ok_view canonicalize_view( view ), args
197
197
  args = default_render_args view, args
198
198
  with_inclusion_mode view do
199
199
  Card.with_logging :view, :message=>view, :context=>card.name, :details=>args do
@@ -205,34 +205,34 @@ class Card
205
205
  rescue_view e, view
206
206
  end
207
207
 
208
-
208
+
209
209
  def show_view? view, args
210
210
  default = args.delete(:default_visibility) || :show #FIXME - ugly
211
211
  view_key = canonicalize_view view
212
212
  api_option = args["optional_#{ view_key }".to_sym]
213
- case
213
+ case
214
214
  # args remove option
215
215
  when api_option == :always ; true
216
216
  when api_option == :never ; false
217
- # wagneer's choice
217
+ # wagneer's choice
218
218
  when show_views( args ).member?( view_key ) ; true
219
219
  when hide_views( args ).member?( view_key ) ; false
220
- # args override default
220
+ # args override default
221
221
  when api_option == :show ; true
222
222
  when api_option == :hide ; false
223
- # default
223
+ # default
224
224
  else ; default==:show
225
225
  end
226
226
  end
227
-
227
+
228
228
  def show_views args
229
229
  parse_view_visibility args[:show]
230
230
  end
231
-
231
+
232
232
  def hide_views args
233
233
  parse_view_visibility args[:hide]
234
234
  end
235
-
235
+
236
236
  def parse_view_visibility val
237
237
  case val
238
238
  when Array; val
@@ -241,7 +241,7 @@ class Card
241
241
  else raise Card::Error, "bad show/hide argument: #{val}"
242
242
  end.map{ |view| canonicalize_view view }
243
243
  end
244
-
244
+
245
245
 
246
246
  def default_render_args view, a=nil
247
247
  args = case a
@@ -250,7 +250,7 @@ class Card
250
250
  when Array ; a[0].merge a[1]
251
251
  else ; raise Card::Error, "bad render args: #{a}"
252
252
  end
253
-
253
+
254
254
  view_key = canonicalize_view view
255
255
  default_method = "default_#{ view }_args"
256
256
  if respond_to? default_method
@@ -258,7 +258,7 @@ class Card
258
258
  end
259
259
  args
260
260
  end
261
-
261
+
262
262
 
263
263
  def rescue_view e, view
264
264
  if Rails.env =~ /^cucumber|test$/
@@ -274,7 +274,7 @@ class Card
274
274
  def error_cardname
275
275
  card && card.name.present? ? card.name : 'unknown card'
276
276
  end
277
-
277
+
278
278
  def unsupported_view view
279
279
  "view (#{view}) not supported for #{error_cardname}"
280
280
  end
@@ -321,9 +321,9 @@ class Card
321
321
  when args.delete(:skip_permissions) # permission skipping specified in args
322
322
  view
323
323
  when !card.known? && !tagged(view, :unknown_ok) # handle unknown cards (where view not exempt)
324
- view_for_unknown view, args
324
+ view_for_unknown view, args
325
325
  else # run explicit permission checks
326
- permitted_view view, args
326
+ permitted_view view, args
327
327
  end
328
328
 
329
329
  args[:denied_view] = view if approved_view != view
@@ -332,11 +332,11 @@ class Card
332
332
  end
333
333
  approved_view
334
334
  end
335
-
335
+
336
336
  def tagged view, tag
337
337
  self.class.tagged view, tag
338
338
  end
339
-
339
+
340
340
  def permitted_view view, args
341
341
  perms_required = @@perms[view] || :read
342
342
  args[:denied_task] =
@@ -345,21 +345,21 @@ class Card
345
345
  else
346
346
  [perms_required].flatten.find { |task| !ok? task }
347
347
  end
348
-
348
+
349
349
  if args[:denied_task]
350
350
  @@denial_views[view] || :denial
351
351
  else
352
352
  view
353
353
  end
354
354
  end
355
-
355
+
356
356
  def ok? task
357
357
  task = :create if task == :update && card.new_card?
358
358
  @ok ||= {}
359
359
  @ok[task] = card.ok? task if @ok[task].nil?
360
360
  @ok[task]
361
361
  end
362
-
362
+
363
363
  def view_for_unknown view, args
364
364
  # note: overridden in HTML
365
365
  focal? ? :not_found : :missing
@@ -371,7 +371,7 @@ class Card
371
371
  DEPRECATED_VIEWS[view_key] || view_key
372
372
  end
373
373
  end
374
-
374
+
375
375
  def with_inclusion_mode mode
376
376
  if switch_mode = INCLUSION_MODES[ mode ] and @mode != switch_mode
377
377
  old_mode, @mode = @mode, switch_mode
@@ -387,7 +387,7 @@ class Card
387
387
 
388
388
  def prepare_nest opts
389
389
  @char_count ||= 0
390
-
390
+
391
391
  opts ||= {}
392
392
  case
393
393
  when opts.has_key?( :comment ) ; opts[:comment] # as in commented code
@@ -413,8 +413,8 @@ class Card
413
413
  result
414
414
  end
415
415
  end
416
-
417
- def legacy_main_opts_tweaks! opts
416
+
417
+ def legacy_main_opts_tweaks! opts
418
418
  if val=params[:size] and val.present?
419
419
  opts[:size] = val.to_sym
420
420
  end
@@ -432,7 +432,7 @@ class Card
432
432
  #ActiveSupport::Notifications.instrument('card', message: "nest: #{nested_card.name}, #{opts}") do
433
433
  opts.delete_if { |k,v| v.nil? }
434
434
  opts.reverse_merge! inclusion_defaults(nested_card)
435
-
435
+
436
436
  sub = nil
437
437
  if opts[:inc_name] =~ /^_(self)?$/
438
438
  sub = self
@@ -473,7 +473,7 @@ class Card
473
473
  if p = params['subcards'] and card_params = p[cardname.to_s]
474
474
  content = card_params['content']
475
475
  end
476
- content if content.present? # why is this necessary? - efm
476
+ content if content.present? # why is this necessary? - efm
477
477
  # probably for blanks? -- older/wiser efm
478
478
  end
479
479
 
@@ -490,7 +490,7 @@ class Card
490
490
  end
491
491
  args
492
492
  end
493
-
493
+
494
494
  def default_item_view
495
495
  :name
496
496
  end
@@ -503,7 +503,7 @@ class Card
503
503
  def add_class options, klass
504
504
  options[:class] = [ options[:class], klass ].flatten.compact * ' '
505
505
  end
506
-
506
+
507
507
  module Location
508
508
  #
509
509
  # page_path takes a Card::Name, adds the format and query string to url_key (site-absolute)
@@ -518,7 +518,7 @@ class Card
518
518
  query = opts.present? ? "?#{opts.to_param}" : ''
519
519
  card_path "#{action}#{title.to_name.url_key}#{format}#{query}"
520
520
  end
521
-
521
+
522
522
  def card_path rel_path
523
523
  Rails.logger.warn "Pass only strings to card_path: #{rel_path.class}, #{rel_path}" unless String===rel_path
524
524
  if rel_path =~ /^\//
@@ -535,12 +535,12 @@ class Card
535
535
  "#{ Card::Env[:protocol] }#{ Card::Env[:host] }#{ card_path rel }"
536
536
  end
537
537
  end
538
-
538
+
539
539
  end
540
540
  include Location
541
541
 
542
542
  def unique_id
543
- "#{card.key}-#{Time.now.to_i}-#{rand(3)}"
543
+ "#{card.key}-#{Time.now.to_i}-#{rand(3)}"
544
544
  end
545
545
 
546
546
  def format_date date, include_time = true
@@ -8,7 +8,7 @@ module Cardio
8
8
 
9
9
  ActiveSupport.on_load :card do
10
10
  if Card.count > 0
11
- Card::Loader.load_mods
11
+ Card::Loader.load_mods
12
12
  else
13
13
  Rails.logger.warn "empty database"
14
14
  end
@@ -20,7 +20,7 @@ module Cardio
20
20
  def cache
21
21
  @@cache ||= ::Rails.cache
22
22
  end
23
-
23
+
24
24
  def set_config config
25
25
  @@config, @@root = config, config.root
26
26
 
@@ -51,7 +51,7 @@ module Cardio
51
51
  config.closed_search_limit = 50
52
52
  end
53
53
 
54
-
54
+
55
55
  def set_paths paths
56
56
  @@paths = paths
57
57
  add_path 'tmp/set', :root => root
@@ -64,13 +64,15 @@ module Cardio
64
64
  add_path "db/migrate_deck_cards", :root => root, :with => 'db/migrate_cards'
65
65
  add_path "db/seeds", :with => "db/seeds.rb"
66
66
 
67
- add_path 'config/initializers', :glob => '**/*.rb'
67
+ add_path 'config/initializers', :glob => '**/*.rb'
68
+ paths['config/initializers'] << "#{gem_root}/mod/**{,/*/**}/initializers"
69
+ paths['config/initializers'] << "#{root}/mod/**{,/*/**}/initializers"
68
70
  end
69
71
 
70
72
  def root
71
73
  @@config.root
72
74
  end
73
-
75
+
74
76
  def gem_root
75
77
  CARD_GEM_ROOT
76
78
  end
@@ -80,7 +80,7 @@ module Card::Chunk
80
80
  replace_name_reference old_name, new_name
81
81
  @text = "{{#{ [ @name.to_s, @opt_lists ].compact * '|' }}}"
82
82
  end
83
-
83
+
84
84
  def explicit_view= view
85
85
  unless @options[:view] #could check to make sure it's not already the default...
86
86
  if @text =~ /\|/
@@ -3,7 +3,7 @@
3
3
  # A multipurpose retrieval operator that incorporates caching, "virtual" card retrieval
4
4
 
5
5
  module ClassMethods
6
-
6
+
7
7
  # === fetch
8
8
  #
9
9
  # looks for cards in
@@ -18,15 +18,15 @@ module ClassMethods
18
18
  # :skip_modules Don't load Set modules
19
19
  # :new => { card opts } Return a new card when not found
20
20
  #
21
-
22
21
 
23
-
24
-
22
+
23
+
24
+
25
25
  def fetch mark, opts={}
26
26
  if String === mark
27
27
  case mark
28
28
  when /^\~(\d+)$/ # get by id
29
- mark = $1.to_i
29
+ mark = $1.to_i
30
30
  when /^\:(\w+)$/ # get by codename
31
31
  mark = $1.to_sym
32
32
  end
@@ -44,20 +44,20 @@ module ClassMethods
44
44
  else
45
45
  return card.renew(opts) if card and card.eager_renew?(opts)
46
46
  if !card or card.type_id==-1 && clean_cache_opts?(opts) # new (or improved) card for cache
47
- needs_caching = true
47
+ needs_caching = true
48
48
  card = new_for_cache mark, opts
49
- end
49
+ end
50
50
  end
51
-
51
+
52
52
  write_to_cache card if Card.cache && needs_caching
53
-
53
+
54
54
  if card.new_card?
55
55
  if opts[:new]
56
56
  return card.renew(opts) if !clean_cache_opts? opts
57
57
  elsif opts[:skip_virtual]
58
58
  return
59
59
  else
60
- card.include_set_modules unless opts[:skip_modules] # need to load modules here to call the right virtual? method
60
+ card.include_set_modules unless opts[:skip_modules] # need to load modules here to call the right virtual? method
61
61
  return unless card.virtual?
62
62
  end
63
63
  card.name = mark.to_s if mark && mark.to_s != card.name
@@ -66,7 +66,7 @@ module ClassMethods
66
66
  card.include_set_modules unless opts[:skip_modules]
67
67
  card
68
68
  end
69
-
69
+
70
70
  def fetch_id mark #should optimize this. what if mark is int? or codename?
71
71
  card = fetch mark, :skip_virtual=>true, :skip_modules=>true
72
72
  card and card.id
@@ -80,7 +80,7 @@ module ClassMethods
80
80
  card = fetch mark, :skip_virtual=>true, :skip_modules=>true
81
81
  card.present?
82
82
  end
83
-
83
+
84
84
  def known? mark
85
85
  card = fetch mark, :skip_modules=>true
86
86
  card.present?
@@ -89,7 +89,7 @@ module ClassMethods
89
89
  def expire name
90
90
  #note: calling instance method breaks on dirty names
91
91
  key = name.to_name.key
92
- if card = Card.cache.read( key )
92
+ if card = Card.cache.read( key )
93
93
  Card.cache.delete key
94
94
  Card.cache.delete "~#{card.id}" if card.id
95
95
  end
@@ -115,15 +115,15 @@ module ClassMethods
115
115
  Card.cache.write skey, h
116
116
  end
117
117
  end
118
-
118
+
119
119
  def cache
120
120
  Card::Cache[Card]
121
121
  end
122
-
122
+
123
123
  def fetch_from_cache cache_key
124
124
  Card.cache.read cache_key if Card.cache
125
125
  end
126
-
126
+
127
127
  def fullname_from_name name, new_opts={}
128
128
  if new_opts and supercard = new_opts[:supercard]
129
129
  name.to_name.to_absolute_name supercard.name
@@ -131,32 +131,32 @@ module ClassMethods
131
131
  name.to_name
132
132
  end
133
133
  end
134
-
134
+
135
135
  def fetch_from_cache_or_db mark, opts
136
- needs_caching = false
136
+ needs_caching = false
137
137
  mark_type = Integer===mark ? :id : :key
138
-
138
+
139
139
  if mark_type == :key
140
140
  mark = fullname_from_name mark, opts[:new]
141
141
  val = mark.key
142
142
  else
143
143
  val = mark
144
144
  end
145
-
145
+
146
146
  card = send( "fetch_from_cache_by_#{mark_type}", val ) || begin
147
147
  needs_caching = true
148
148
  send "find_by_#{mark_type}_and_trash", val, false
149
149
  end
150
-
150
+
151
151
  [ card, mark, needs_caching ]
152
152
  end
153
-
153
+
154
154
  def fetch_from_cache_by_id id
155
155
  if name = fetch_from_cache("~#{id}")
156
156
  fetch_from_cache name
157
157
  end
158
158
  end
159
-
159
+
160
160
  def fetch_from_cache_by_key key
161
161
  fetch_from_cache key
162
162
  end
@@ -168,16 +168,16 @@ module ClassMethods
168
168
  # reinitialization later. *** It should NEVER be seen elsewhere ***
169
169
  new new_args
170
170
  end
171
-
171
+
172
172
  def clean_cache_opts? opts
173
173
  !opts[:skip_virtual] && !opts[:new].present?
174
174
  end
175
-
175
+
176
176
  def write_to_cache card
177
177
  Card.cache.write card.key, card
178
178
  Card.cache.write "~#{card.id}", card.key if card.id and card.id != 0
179
- end
180
-
179
+ end
180
+
181
181
 
182
182
  end
183
183