card 1.18.3 → 1.18.4

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +5 -3
  4. data/db/schema.rb +1 -1
  5. data/lib/card/active_record_helper.rb +2 -1
  6. data/lib/card/core_ext.rb +8 -0
  7. data/lib/card/format/nest.rb +13 -2
  8. data/lib/card/format/render.rb +7 -1
  9. data/lib/card/migration.rb +2 -1
  10. data/lib/card/set.rb +55 -70
  11. data/lib/card/set/trait.rb +70 -0
  12. data/lib/card/stage.rb +33 -8
  13. data/lib/card/stage_director.rb +3 -1
  14. data/lib/cardio.rb +2 -1
  15. data/mod/01_core/chunk/link.rb +7 -6
  16. data/mod/01_core/set/all/collection.rb +15 -52
  17. data/mod/01_core/set/all/fetch.rb +26 -6
  18. data/mod/01_core/set/all/references.rb +11 -3
  19. data/mod/01_core/set/all/subcards.rb +2 -2
  20. data/mod/01_core/set/all/tracked_attributes.rb +5 -1
  21. data/mod/01_core/set/all/utils.rb +1 -1
  22. data/mod/01_core/spec/set/all/collection_spec.rb +2 -2
  23. data/mod/01_history/set/all/content_history.rb +10 -11
  24. data/mod/02_basic_types/set/abstract/code_file.rb +57 -0
  25. data/mod/02_basic_types/set/type/pointer.rb +9 -5
  26. data/mod/03_machines/lib/javascript/wagn.js.coffee +4 -1
  27. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +29 -24
  28. data/mod/03_machines/set/self/script_ace.rb +1 -11
  29. data/mod/03_machines/set/self/script_card_menu.rb +1 -10
  30. data/mod/03_machines/set/self/script_html5shiv_printshiv.rb +1 -2
  31. data/mod/03_machines/set/self/script_jquery.rb +1 -2
  32. data/mod/03_machines/set/self/script_jquery_helper.rb +4 -7
  33. data/mod/03_machines/set/self/script_slot.rb +4 -6
  34. data/mod/03_machines/set/self/script_tinymce.rb +1 -2
  35. data/mod/03_machines/set/self/style_bootstrap_compatible.rb +1 -5
  36. data/mod/03_machines/set/self/style_cards.rb +1 -6
  37. data/mod/03_machines/set/self/style_jquery_ui_smoothness.rb +1 -2
  38. data/mod/03_machines/set/type/coffee_script.rb +1 -1
  39. data/mod/03_machines/set/type/css.rb +10 -1
  40. data/mod/03_machines/set/type/java_script.rb +16 -1
  41. data/mod/03_machines/set/type/scss.rb +3 -2
  42. data/mod/05_standard/lib/image_uploader.rb +15 -0
  43. data/mod/05_standard/set/all/rich_html/editing.rb +2 -2
  44. data/mod/05_standard/set/all/rich_html/form.rb +40 -19
  45. data/mod/05_standard/set/all/rich_html/modal.rb +4 -2
  46. data/mod/05_standard/set/all/rich_html/toolbar.rb +88 -39
  47. data/mod/05_standard/set/type/search_type.rb +6 -3
  48. data/mod/06_bootstrap/set/all/bootstrap/table.rb +55 -0
  49. data/mod/06_bootstrap/set/all/bootstrap/tabs.rb +81 -0
  50. data/mod/06_bootstrap/set/self/bootstrap_cards.rb +1 -9
  51. data/mod/06_bootstrap/set/self/bootstrap_js.rb +4 -6
  52. data/mod/06_bootstrap/set/self/bootswatch_shared.rb +11 -3
  53. data/mod/06_bootstrap/set/self/smartmenu_css.rb +3 -5
  54. data/mod/06_bootstrap/set/self/smartmenu_js.rb +3 -5
  55. data/spec/lib/card/set/trait_spec.rb +62 -0
  56. metadata +24 -3
@@ -258,7 +258,7 @@ format :html do
258
258
  %(<div class="search-no-results"></div>)
259
259
  end
260
260
 
261
- view :paging do |_args|
261
+ view :paging do |args|
262
262
  s = card.query search_params
263
263
  offset = s[:offset].to_i
264
264
  limit = s[:limit].to_i
@@ -268,8 +268,11 @@ format :html do
268
268
  total = card.count search_params
269
269
  # should only happen if limit exactly equals the total
270
270
  return '' if limit >= total
271
-
272
- @paging_path_args = { limit: limit, item: nest_defaults(card)[:view] }
271
+ @paging_path_args = { limit: limit,
272
+ slot: {
273
+ item: args[:item] || nest_defaults(card)[:view]
274
+ } }
275
+ @paging_path_args[:view] = args[:home_view] if args[:home_view]
273
276
  @paging_limit = limit
274
277
 
275
278
  s[:vars].each { |key, value| @paging_path_args["_#{key}"] = value }
@@ -0,0 +1,55 @@
1
+ format :html do
2
+ # @param [Array<Array,String>] content the content for the table. Accepts
3
+ # strings or arrays for each row.
4
+ # @param [Hash] opts
5
+ # @option opts [String, Array] :header use first row of content as header or
6
+ # value of this option if it is a string
7
+ # @return [HTML] bootstrap table
8
+ def table content, opts={}
9
+ add_class opts, 'table'
10
+ if opts[:header]
11
+ header = opts[:header].is_a?(Array) ? opts[:header] : content.shift
12
+ end
13
+ wrap_with :table, class: opts[:class] do
14
+ [
15
+ (table_header(header) if header),
16
+ table_body(content)
17
+ ]
18
+ end
19
+ end
20
+
21
+ def table_header entries
22
+ content_tag :thead do
23
+ content_tag :tr do
24
+ entries.map do |item|
25
+ content_tag :th, item
26
+ end.join "\n"
27
+ end
28
+ end
29
+ end
30
+
31
+ def table_body rows
32
+ content_tag :tbody do
33
+ rows.map do |row|
34
+ table_row row
35
+ end.join "\n"
36
+ end
37
+ end
38
+
39
+ def table_row row
40
+ row_content =
41
+ if row.is_a? Array
42
+ row.map do |item|
43
+ if item.is_a? Hash
44
+ content_tag :td, item.delete(:content), item
45
+ else
46
+ content_tag :td, item
47
+ end
48
+ end.join "\n"
49
+ else
50
+ row
51
+ end
52
+
53
+ content_tag :tr, row_content.html_safe
54
+ end
55
+ end
@@ -0,0 +1,81 @@
1
+ format :html do
2
+ # @param tab_type [String] 'tabs' or 'pills'
3
+ # @param tabs [Hash] keys are the labels, values the content for the tabs
4
+ # @param active_name [String] label of the tab that should be active at the
5
+ # beginning (default is the first)
6
+ # @return [HTML] bootstrap tabs element with all content preloaded
7
+ def static_tabs tabs, active_name=nil, tab_type='tabs'
8
+ tab_buttons = ''
9
+ tab_panes = ''
10
+ tabs.each do |tab_name, tab_content|
11
+ active_name ||= tab_name
12
+ active_tab = (tab_name == active_name)
13
+ id = "#{card.cardname.safe_key}-#{tab_name.to_name.safe_key}"
14
+ tab_buttons += tab_button("##{id}", tab_name, active_tab)
15
+ tab_panes += tab_pane(id, tab_content, active_tab)
16
+ end
17
+ tab_panel tab_buttons, tab_panes, tab_type
18
+ end
19
+
20
+ # @param [Hash] tabs keys are the labels for the tabs, values the urls to
21
+ # load the content from
22
+ # @param [String] active_name label of the tab that should be active at the
23
+ # beginning
24
+ # @param [String] active_content content of the active tab
25
+ # @param [Hash] args options
26
+ # @option args [String] :type ('tabs') use pills or tabs
27
+ # @option args [Hash] :panel_args html args used for the panel div
28
+ # @option args [Hash] :pane_args html args used for the pane div
29
+ # @return [HTML] bootstrap tabs element with content only for the active
30
+ # tab; other tabs get loaded via ajax when selected
31
+ def lazy_loading_tabs tabs, active_name, active_content, args={}
32
+ tab_buttons = ''
33
+ tab_panes = ''
34
+ tabs.each do |tab_name, url|
35
+ active_tab = (active_name == tab_name)
36
+ id = "#{card.cardname.safe_key}-#{tab_name.to_name.safe_key}"
37
+ tab_buttons += tab_button(
38
+ "##{id}", tab_name, active_tab,
39
+ 'data-url' => url.html_safe,
40
+ class: (active_tab ? nil : 'load')
41
+ )
42
+ tab_content = active_tab ? active_content : ''
43
+ tab_panes += tab_pane(id, tab_content, active_tab, args[:pane_args])
44
+ end
45
+ tab_type = args.delete(:type) || 'tabs'
46
+ tab_panel tab_buttons, tab_panes, tab_type, args[:panel_args]
47
+ end
48
+
49
+ def tab_panel tab_buttons, tab_panes, tab_type='tabs', args=nil
50
+ args ||= {}
51
+ add_class args, 'tabbable'
52
+ args.reverse_merge! role: 'tabpanel'
53
+ wrap_with :div, args do
54
+ [
55
+ content_tag(:ul, tab_buttons.html_safe,
56
+ class: "nav nav-#{tab_type}",
57
+ role: 'tablist'),
58
+ content_tag(:div, tab_panes.html_safe, class: 'tab-content')
59
+ ]
60
+ end
61
+ end
62
+
63
+ def tab_button target, text, active=false, link_attr={}
64
+ link = link_to(
65
+ fancy_title(text),
66
+ target,
67
+ link_attr.merge('role' => 'tab', 'data-toggle' => 'tab'))
68
+ li_args = { role: :presentation }
69
+ li_args[:class] = 'active' if active
70
+ content_tag :li, link, li_args
71
+ end
72
+
73
+ def tab_pane id, content, active=false, args=nil
74
+ args ||= {}
75
+ args.reverse_merge! role: :tabpanel,
76
+ id: id
77
+ add_class args, 'tab-pane'
78
+ add_class args, 'active' if active
79
+ content_tag :div, content.html_safe, args
80
+ end
81
+ end
@@ -1,9 +1 @@
1
- view :raw do |_args|
2
- File.read "#{Cardio.gem_root}/mod/06_bootstrap/lib/stylesheets/#{card.codename}.scss"
3
- end
4
-
5
- format :html do
6
- view :editor do |_args|
7
- "Content is stored in file and can't be edited."
8
- end
9
- end
1
+ include_set Abstract::CodeFile
@@ -1,7 +1,5 @@
1
- view :raw do |_args|
2
- ['bootstrap.js', 'bootstrap_modal_wagn.js'].map do |name|
3
- File.read "#{Cardio.gem_root}/mod/06_bootstrap/lib/javascript/#{name}"
4
- end.join("\n")
5
- end
1
+ include_set Abstract::CodeFile
6
2
 
7
- format(:html) { include BootstrapCards::HtmlFormat }
3
+ def source_files
4
+ %w( bootstrap.js bootstrap_modal_wagn.js )
5
+ end
@@ -1,5 +1,9 @@
1
+ include_set Abstract::CodeFile
2
+
1
3
  view :raw do |_args|
2
- bootstrap_path = "#{Cardio.gem_root}/mod/06_bootstrap/lib/stylesheets/bootstrap"
4
+ bootstrap_path = File.join Cardio.gem_root, 'mod',
5
+ card.file_content_mod_name, 'lib',
6
+ 'stylesheets', 'bootstrap'
3
7
 
4
8
  # variables
5
9
  content = File.read("#{bootstrap_path}/_variables.scss")
@@ -17,14 +21,18 @@ view :raw do |_args|
17
21
  # Core CSS
18
22
  %w(scaffolding type code grid tables forms buttons),
19
23
  # Components
20
- %w(component-animations dropdowns button-groups input-groups navs navbar breadcrumbs pagination pager labels badges jumbotron thumbnails alerts progress-bars media list-group panels responsive-embed wells close),
24
+ %w(component-animations dropdowns button-groups input-groups navs navbar
25
+ breadcrumbs pagination pager labels badges jumbotron thumbnails alerts
26
+ progress-bars media list-group panels responsive-embed wells close),
21
27
  # Components w/ JavaScript
22
28
  %w(modals tooltip popovers carousel),
23
29
  # Utility classes
24
30
  %w(utilities responsive-utilities)
25
31
  ].map do |names|
26
32
  names.map do |name|
27
- File.read File.join(bootstrap_path, "_#{name}.scss")
33
+ path = File.join(bootstrap_path, "_#{name}.scss")
34
+ Rails.logger.info "reading file: #{path}"
35
+ File.read path
28
36
  end.join "\n"
29
37
  end.join "\n"
30
38
 
@@ -1,7 +1,5 @@
1
- view :raw do |_args|
2
- File.read "#{Cardio.gem_root}/mod/06_bootstrap/lib/stylesheets/smartmenu.css"
3
- end
1
+ include_set Abstract::CodeFile
4
2
 
5
- view :editor do |_args|
6
- "Content is stored in file and can't be edited."
3
+ def source_files
4
+ 'startmenu.css'
7
5
  end
@@ -1,7 +1,5 @@
1
- view :raw do |_args|
2
- File.read "#{Cardio.gem_root}/mod/06_bootstrap/lib/javascript/smartmenu.js"
3
- end
1
+ include_set Abstract::CodeFile
4
2
 
5
- view :editor do |_args|
6
- "Content is stored in file and can't be edited."
3
+ def source_files
4
+ 'startmenu.js'
7
5
  end
@@ -0,0 +1,62 @@
1
+
2
+ describe Card::Set::Trait do
3
+ class Card
4
+ module Set
5
+ module Type
6
+ module Phrase
7
+ extend Card::Set
8
+ card_accessor :write, type: :pointer
9
+ card_accessor :read, type_id: Card::PointerID
10
+ end
11
+ end
12
+
13
+ module TypePlusRight
14
+ module Phrase
15
+ module Write
16
+ extend Card::Set
17
+ def type_plus_right_module_loaded
18
+ true
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ subject do
27
+ Card::Auth.as_bot do
28
+ Card.create! name: 'joke',
29
+ type_id: Card::PhraseID,
30
+ '+*write' => 'some content',
31
+ '+*read' => 'some content'
32
+ end
33
+ end
34
+
35
+ context 'if accessor type is defined by a string' do
36
+ it 'has left' do
37
+ in_stage :prepare_to_validate, on: :create,
38
+ trigger: -> { subject } do
39
+ # test API doesn't support sets for event
40
+ # so we check the name
41
+ return unless name == 'joke'
42
+ expect(write_card.left.class).to eq Card
43
+ end
44
+ end
45
+ it 'loads *type plus right set module' do
46
+ in_stage :prepare_to_validate, on: :create,
47
+ trigger: -> { subject } do
48
+ return unless name == 'joke'
49
+ expect(write_card).to respond_to?(:type_plus_right_module_loaded)
50
+ end
51
+ end
52
+ end
53
+ context 'if accessor type is defined by an id' do
54
+ it 'has left' do
55
+ in_stage :prepare_to_validate, on: :create,
56
+ trigger: -> { subject } do
57
+ return unless name == 'joke'
58
+ expect(read_card.left.class).to eq Card
59
+ end
60
+ end
61
+ end
62
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.3
4
+ version: 1.18.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-03-04 00:00:00.000000000 Z
14
+ date: 2016-04-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: smartname
@@ -209,6 +209,20 @@ dependencies:
209
209
  - - "~>"
210
210
  - !ruby/object:Gem::Version
211
211
  version: '1.2'
212
+ - !ruby/object:Gem::Dependency
213
+ name: mime-types
214
+ requirement: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - '='
217
+ - !ruby/object:Gem::Version
218
+ version: 2.99.1
219
+ type: :runtime
220
+ prerelease: false
221
+ version_requirements: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - '='
224
+ - !ruby/object:Gem::Version
225
+ version: 2.99.1
212
226
  description: Cards are data atoms grouped into Sets to which Rules can apply. Cards
213
227
  can formatted with Views and transformed with Events.
214
228
  email:
@@ -408,6 +422,7 @@ files:
408
422
  - lib/card/reference.rb
409
423
  - lib/card/set.rb
410
424
  - lib/card/set/event.rb
425
+ - lib/card/set/trait.rb
411
426
  - lib/card/set_pattern.rb
412
427
  - lib/card/simplecov_helper.rb
413
428
  - lib/card/spec_helper.rb
@@ -518,6 +533,7 @@ files:
518
533
  - mod/02_basic_types/format/json_format.rb
519
534
  - mod/02_basic_types/format/rss_format.rb
520
535
  - mod/02_basic_types/format/xml_format.rb
536
+ - mod/02_basic_types/set/abstract/code_file.rb
521
537
  - mod/02_basic_types/set/all/all_css.rb
522
538
  - mod/02_basic_types/set/all/all_csv.rb
523
539
  - mod/02_basic_types/set/all/all_js.rb
@@ -964,6 +980,8 @@ files:
964
980
  - mod/06_bootstrap/lib/stylesheets/smartmenu.css
965
981
  - mod/06_bootstrap/set/all/bootstrap/form.rb
966
982
  - mod/06_bootstrap/set/all/bootstrap/helper.rb
983
+ - mod/06_bootstrap/set/all/bootstrap/table.rb
984
+ - mod/06_bootstrap/set/all/bootstrap/tabs.rb
967
985
  - mod/06_bootstrap/set/all/bootstrap/wrapper.rb
968
986
  - mod/06_bootstrap/set/all/rich_bootstrap.rb
969
987
  - mod/06_bootstrap/set/self/bootstrap_cards.rb
@@ -984,6 +1002,7 @@ files:
984
1002
  - spec/lib/card/name_spec.rb
985
1003
  - spec/lib/card/query_spec.rb
986
1004
  - spec/lib/card/reference_spec.rb
1005
+ - spec/lib/card/set/trait_spec.rb
987
1006
  - spec/lib/card/set_pattern_spec.rb
988
1007
  - spec/lib/card/set_spec.rb
989
1008
  - spec/lib/card/stage_director_spec.rb
@@ -1180,7 +1199,8 @@ files:
1180
1199
  - tmpsets/set_pattern/107-self.rb
1181
1200
  homepage: http://wagn.org
1182
1201
  licenses:
1183
- - GPL
1202
+ - GPL-2.0
1203
+ - GPL-3.0
1184
1204
  metadata: {}
1185
1205
  post_install_message:
1186
1206
  rdoc_options: []
@@ -1215,6 +1235,7 @@ test_files:
1215
1235
  - spec/lib/card/name_spec.rb
1216
1236
  - spec/lib/card/query_spec.rb
1217
1237
  - spec/lib/card/reference_spec.rb
1238
+ - spec/lib/card/set/trait_spec.rb
1218
1239
  - spec/lib/card/set_pattern_spec.rb
1219
1240
  - spec/lib/card/set_spec.rb
1220
1241
  - spec/lib/card/stage_director_spec.rb