card 1.93.13 → 1.94.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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/config/initializers/01_core_extensions/persistent_identifiers.rb +8 -0
  4. data/config/locales/de.yml +1 -0
  5. data/config/locales/en.yml +1 -0
  6. data/lib/card.rb +2 -1
  7. data/lib/card/cache.rb +1 -1
  8. data/lib/card/content/clean.rb +6 -4
  9. data/lib/card/format/error.rb +1 -1
  10. data/lib/card/format/render.rb +1 -1
  11. data/lib/card/mod.rb +6 -1
  12. data/lib/card/mod/loader.rb +2 -0
  13. data/lib/card/name.rb +25 -5
  14. data/lib/card/query/attributes.rb +13 -8
  15. data/lib/card/set/event.rb +1 -1
  16. data/lib/card/tasks/card.rake +12 -0
  17. data/lib/card/tasks/card/migrate.rake +2 -0
  18. data/lib/card/view/options.rb +2 -1
  19. data/lib/cardio.rb +6 -6
  20. data/lib/cardio/utils.rb +30 -0
  21. data/mod/account/set/self/signin.rb +3 -13
  22. data/mod/account/set/type/signup.rb +1 -1
  23. data/mod/account/spec/set/self/signin_spec.rb +1 -1
  24. data/mod/basic_formats/set/all/base.rb +11 -3
  25. data/mod/basic_formats/set/all/json.rb +1 -0
  26. data/mod/basic_formats/set/self/head.rb +2 -3
  27. data/mod/bootstrap/db/migrate_core_cards/20170719163733_update_bootswatch_themes_to_4_beta.rb +2 -95
  28. data/mod/bootstrap/db/migrate_core_cards/lib/skin.rb +94 -0
  29. data/mod/bootstrap/script/update_skin_thumbnails.rb +9 -0
  30. data/mod/carrierwave/set/type/image.rb +1 -1
  31. data/mod/core/chunk/query_reference.rb +9 -2
  32. data/mod/core/set/all/event_conditions.rb +18 -8
  33. data/mod/core/set/all/fetch_helper.rb +11 -11
  34. data/mod/core/set/all/utils.rb +0 -12
  35. data/mod/core/spec/format/html_format_spec.rb +3 -3
  36. data/mod/core/spec/set/all/event_conditions_spec.rb +15 -0
  37. data/mod/core/spec/set/all/name_spec.rb +7 -0
  38. data/mod/core/spec/set/all/name_validations_spec.rb +0 -10
  39. data/mod/core/spec/set/all/rename_spec.rb +2 -2
  40. data/mod/pointer/set/abstract/02_pointer.rb +4 -0
  41. data/mod/search/set/abstract/00_filter_helper.rb +1 -1
  42. data/mod/search/set/abstract/02_search_params.rb +18 -0
  43. data/mod/search/set/abstract/search.rb +1 -1
  44. data/mod/search/set/self/navbox.rb +2 -2
  45. data/mod/search/set/self/search.rb +1 -19
  46. data/mod/search/spec/set/self/search_spec.rb +1 -1
  47. data/mod/standard/set/all/error.rb +6 -6
  48. data/mod/standard/set/all/rich_html/content.rb +2 -27
  49. data/mod/standard/set/all/rich_html/editing.rb +1 -1
  50. data/mod/standard/set/all/rich_html/title.rb +39 -0
  51. data/mod/standard/set/all/rich_html/toolbar.rb +1 -1
  52. data/mod/standard/set/type/cardtype.rb +8 -2
  53. data/mod/standard/spec/{chunk → content/chunk}/include_spec.rb +5 -5
  54. data/mod/standard/spec/{chunk → content/chunk}/link_spec.rb +1 -1
  55. data/mod/standard/spec/{chunk → content/chunk}/query_reference_spec.rb +0 -0
  56. metadata +11 -7
@@ -1,14 +1,4 @@
1
1
  describe Card::Set::All::NameValidations, "validate name" do
2
- it "errors on name with /" do
3
- expect { create "testname/" }
4
- .to raise_error /Name may not contain/
5
- end
6
-
7
- it "errors on junction name with /" do
8
- expect { create "jasmin+ri/ce" }
9
- .to raise_error /Name may not contain/
10
- end
11
-
12
2
  it "does not allow empty name" do
13
3
  expect { create "" }
14
4
  .to raise_error /Name can't be blank/
@@ -81,8 +81,8 @@ RSpec.describe Card::Set::All::Rename do
81
81
  end
82
82
 
83
83
  it "fails if name is invalid" do
84
- expect { update "T", name: "YT/Yo" }
85
- .to raise_error(/Validation failed: Name may not contain/)
84
+ expect { update "T", name: "" }
85
+ .to raise_error(/Name can't be blank/)
86
86
  end
87
87
 
88
88
  example "simple to simple" do
@@ -55,6 +55,10 @@ end
55
55
 
56
56
  format :html do
57
57
  view :core, cache: :never do
58
+ standard_pointer_core
59
+ end
60
+
61
+ def standard_pointer_core
58
62
  with_paging do |paging_args|
59
63
  wrap_with :div, pointer_items(paging_args.extract!(:limit, :offset)),
60
64
  class: "pointer-list"
@@ -42,7 +42,7 @@ end
42
42
 
43
43
  format :html do
44
44
  def extra_paging_path_args
45
- { filter: filter_hash }.merge sort_hash
45
+ super.merge(filter: filter_hash).merge sort_hash
46
46
  end
47
47
 
48
48
  def filter_active?
@@ -11,9 +11,22 @@ format do
11
11
 
12
12
  # used for override
13
13
  def default_search_params
14
+ if (qparams = query_params)
15
+ paging_params.merge vars: qparams
16
+ else
17
+ paging_params
18
+ end
19
+ end
20
+
21
+ def paging_params
14
22
  { limit: limit_param, offset: offset_param }
15
23
  end
16
24
 
25
+ def query_params
26
+ return nil unless (vars = params[:query])
27
+ Card.safe_param vars
28
+ end
29
+
17
30
  def default_limit
18
31
  100
19
32
  end
@@ -23,6 +36,11 @@ format :html do
23
36
  def default_limit
24
37
  Cardio.config.paging_limit || 20
25
38
  end
39
+
40
+ def extra_paging_path_args
41
+ return {} unless (vars = query_params)
42
+ { query: vars }
43
+ end
26
44
  end
27
45
 
28
46
  format :json do
@@ -1,5 +1,5 @@
1
- include_set Abstract::SearchParams
2
1
  include_set Abstract::Paging
2
+ include_set Abstract::SearchParams
3
3
  include_set Abstract::Filter
4
4
 
5
5
  def search _args={}
@@ -2,8 +2,8 @@
2
2
  format :html do
3
3
  view :raw do
4
4
  wrap_with :div, class: "form-group w-100" do
5
- text_field_tag :_keyword, "", class: "_navbox navbox form-control w-100",
6
- placeholder: navbar_placeholder
5
+ text_field_tag "query[keyword]", "", class: "_navbox navbox form-control w-100",
6
+ placeholder: navbar_placeholder
7
7
  end
8
8
  end
9
9
 
@@ -14,16 +14,6 @@ def keyword_contains_wql? hash
14
14
  end
15
15
 
16
16
  format do
17
- def default_search_params
18
- hash = super
19
- hash[:vars] = params[:vars] || {}
20
- params.each do |key, val|
21
- next unless key.to_s =~ /^\_(\w+)$/
22
- hash[:vars][Regexp.last_match(1).to_sym] = val
23
- end
24
- hash
25
- end
26
-
27
17
  view :search_error, cache: :never do
28
18
  sr_class = search_with_params.class.to_s
29
19
 
@@ -33,14 +23,6 @@ format do
33
23
  end
34
24
 
35
25
  format :html do
36
- def extra_paging_path_args
37
- vars = query_with_params.vars
38
- return {} unless vars.is_a? Hash
39
- vars.each_with_object({}) do |(key, value), hash|
40
- hash["_#{key}"] = value
41
- end
42
- end
43
-
44
26
  view :title, cache: :never do
45
27
  return super() unless (keyword = search_keyword) &&
46
28
  (title = keyword_search_title(keyword))
@@ -104,7 +86,7 @@ format :json do
104
86
  end
105
87
 
106
88
  def complete_term
107
- term = params["_keyword"]
89
+ term = query_params[:keyword]
108
90
  if (term =~ /^\+/) && (main = params["main"])
109
91
  term = main + term
110
92
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  describe Card::Set::Self::Search do
4
4
  def keyword_search value
5
- Card::Env.params[:vars] = { keyword: value }
5
+ Card::Env.params[:query] = { keyword: value }
6
6
  Card[:search].format.search_with_params
7
7
  end
8
8
 
@@ -18,7 +18,7 @@ format do
18
18
  end
19
19
 
20
20
  view :not_found, perms: :none, error_code: 404 do |_args|
21
- error_name = card.name.present? ? card.name : "the card requested"
21
+ error_name = card.name.present? ? safe_name : "the card requested"
22
22
  %( Could not find #{error_name}. )
23
23
  end
24
24
 
@@ -75,7 +75,7 @@ format :html do
75
75
  warning = alert("warning", true) do
76
76
  %{
77
77
  <h3>Error message (visible to admin only)</h3>
78
- <p><strong>#{exception.message}</strong></p>
78
+ <p><strong>#{CGI.escapeHTML exception.message}</strong></p>
79
79
  <div>#{exception.backtrace * "<br>\n"}</div>
80
80
  }
81
81
  end
@@ -105,7 +105,7 @@ format :html do
105
105
  end
106
106
 
107
107
  view :closed_missing, perms: :none do
108
- wrap_with :span, title_in_context, class: "faint"
108
+ wrap_with :span, h(title_in_context), class: "faint"
109
109
  end
110
110
 
111
111
  view :conflict, error_code: 409, cache: :never do
@@ -136,20 +136,20 @@ format :html do
136
136
  frame do
137
137
  card.errors.map do |attrib, msg|
138
138
  alert "warning", true do
139
- attrib == :abort ? msg : standard_error_message(attrib, msg)
139
+ attrib == :abort ? h(msg) : standard_error_message(attrib, msg)
140
140
  end
141
141
  end
142
142
  end
143
143
  end
144
144
 
145
145
  def standard_error_message attribute, message
146
- "<strong>#{attribute.to_s.upcase}:</strong> #{message}"
146
+ "<strong>#{h attribute.to_s.upcase}:</strong> #{h message}"
147
147
  end
148
148
 
149
149
  view :not_found do # ug. bad name.
150
150
  voo.hide! :menu
151
151
  voo.title = "Not Found"
152
- card_label = card.name.present? ? "<em>#{card.name}</em>" : "that"
152
+ card_label = card.name.present? ? "<em>#{safe_name}</em>" : "that"
153
153
  frame do
154
154
  [wrap_with(:h2) { "Could not find #{card_label}." },
155
155
  sign_in_or_up_links]
@@ -21,7 +21,7 @@ format :html do
21
21
  args[:view] = view if view
22
22
  @main = false
23
23
  @main_opts = args
24
- render! :layout, title: params[:layout]
24
+ render! :layout, layout: params[:layout]
25
25
  # FIXME: using title because it's a standard view option. hack!
26
26
  end
27
27
 
@@ -32,7 +32,7 @@ format :html do
32
32
  end
33
33
 
34
34
  view :layout, perms: :none, cache: :never do
35
- layout = process_content get_layout_content(voo.title),
35
+ layout = process_content get_layout_content(voo.layout),
36
36
  content_opts: { chunk_list: :references }
37
37
  output [layout, _render_modal_slot]
38
38
  end
@@ -89,20 +89,6 @@ format :html do
89
89
  end
90
90
  end
91
91
 
92
- view :title do
93
- title = fancy_title super()
94
- if show_view? :title_link, :hide
95
- title = _render_title_link title_ready: title
96
- end
97
- add_name_context
98
- title
99
- end
100
-
101
- view :title_link do |args|
102
- title_text = args[:title_ready] || pov_name(voo.title)
103
- link_to_card card.name, title_text
104
- end
105
-
106
92
  view :type_info do
107
93
  return unless show_view?(:toolbar, :hide) && card.type_code != :basic
108
94
  wrap_with :span, class: "type-info float-right" do
@@ -236,15 +222,4 @@ format :html do
236
222
  </span>
237
223
  )
238
224
  end
239
-
240
- def fancy_title title=nil
241
- wrap_with :span, class: classy("card-title") do
242
- title.to_name.parts.join fancy_joint
243
- end
244
- end
245
-
246
- def fancy_joint
247
- wrap_with :span, "+", classy("joint")
248
- end
249
225
  end
250
-
@@ -69,7 +69,7 @@ format :html do
69
69
  end
70
70
 
71
71
  def rename_confirmation_alert
72
- msg = "<h5>Are you sure you want to rename <em>#{card.name}</em>?</h5>"
72
+ msg = "<h5>Are you sure you want to rename <em>#{safe_name}</em>?</h5>"
73
73
  msg << rename_effects_and_options
74
74
  alert("warning") { msg }
75
75
  end
@@ -0,0 +1,39 @@
1
+ format :html do
2
+ view :title do
3
+ title = wrapped_title(super())
4
+ title = link_to_card card.name, title if show_view? :title_link, :hide
5
+ add_name_context
6
+ title
7
+ end
8
+
9
+ view :title_link do
10
+ render_title show: :title_link
11
+ end
12
+
13
+ def title_with_link link_text
14
+ link_to_card card.name, link_text
15
+ end
16
+
17
+ view :name do
18
+ h(super())
19
+ end
20
+
21
+ def safe_name
22
+ h super
23
+ end
24
+
25
+ def title_in_context title=nil
26
+ h super
27
+ end
28
+
29
+ def wrapped_title title
30
+ wrap_with :span, class: classy("card-title") do
31
+ escaped_parts = title.to_name.parts.map { |part| h part }
32
+ escaped_parts.join wrapped_joint
33
+ end
34
+ end
35
+
36
+ def wrapped_joint
37
+ wrap_with :span, "+", classy("joint")
38
+ end
39
+ end
@@ -218,7 +218,7 @@ format :html do
218
218
  end
219
219
 
220
220
  view :delete_button do |_args|
221
- confirm = "Are you sure you want to delete #{card.name}?"
221
+ confirm = "Are you sure you want to delete #{safe_name}?"
222
222
  success = main? ? "REDIRECT: *previous" : "TEXT: #{card.name} deleted"
223
223
  toolbar_button "delete", :trash,
224
224
  path: { action: :delete, success: success },
@@ -12,14 +12,14 @@ format :html do
12
12
 
13
13
  view :type_formgroup do
14
14
  if card.cards_of_type_exist?
15
- wrap_with :div, tr(:cards_exist, cardname: card.name)
15
+ wrap_with :div, tr(:cards_exist, cardname: safe_name)
16
16
  else
17
17
  super()
18
18
  end
19
19
  end
20
20
 
21
21
  view :add_link do |args|
22
- voo.title ||= tr(:add_card, cardname: card.name)
22
+ voo.title ||= tr(:add_card, cardname: safe_name)
23
23
  title = _render_title args
24
24
  link_to title, path: _render_add_path(args), class: args[:css_class]
25
25
  end
@@ -82,3 +82,9 @@ event :check_for_cards_of_type_when_type_changed, :validate, changed: :type do
82
82
  errors.add :cardtype, tr(:error_cant_alter, name: name)
83
83
  end
84
84
  end
85
+
86
+ event :validate_cardtype_name, :validate, on: :save, changed: :name do
87
+ if name =~ %r{[<>/]}
88
+ errors.add :name, tr(:error_invalid_character_in_cardtype, banned: "<, >, /")
89
+ end
90
+ end
@@ -2,16 +2,16 @@
2
2
 
3
3
  describe Card::Content::Chunk::Nest, "Inclusion" do
4
4
  context "syntax parsing" do
5
- before do
6
- @class = Card::Content::Chunk::Nest
7
- end
8
-
9
5
  let :instance do
10
- @class.new(@class.full_match(@chunk), nil)
6
+ described_class.new(described_class.full_match(@chunk), nil)
11
7
  end
12
8
  let(:options) { instance.options }
13
9
  let(:name) { instance.name }
14
10
 
11
+ def chunk_nest chunk
12
+ described_class.new(described_class.full_match(chunk), nil)
13
+ end
14
+
15
15
  it "ignores invisible comments" do
16
16
  expect(render_content("{{## now you see nothing}}")).to eq("")
17
17
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- describe Card::Content::Chunk::Link do
3
+ RSpec.describe Card::Content::Chunk::Link do
4
4
  def assert_link target, args
5
5
  text = args.delete(:text)
6
6
  format_args = args.delete(:format_args)
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.93.13
4
+ version: 1.94.0
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: 2018-03-01 00:00:00.000000000 Z
14
+ date: 2018-03-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: cardname
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.3.13
22
+ version: 0.4.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.3.13
29
+ version: 0.4.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: haml
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -572,6 +572,7 @@ files:
572
572
  - lib/card/view/visibility.rb
573
573
  - lib/cardio.rb
574
574
  - lib/cardio/schema.rb
575
+ - lib/cardio/utils.rb
575
576
  - lib/generators/card.rb
576
577
  - lib/generators/card/format/USAGE
577
578
  - lib/generators/card/format/format_generator.rb
@@ -664,6 +665,7 @@ files:
664
665
  - mod/bootstrap/db/migrate_core_cards/data/custom_theme/fonts.scss
665
666
  - mod/bootstrap/db/migrate_core_cards/data/custom_theme/more.scss
666
667
  - mod/bootstrap/db/migrate_core_cards/data/custom_theme/spacing.scss
668
+ - mod/bootstrap/db/migrate_core_cards/lib/skin.rb
667
669
  - mod/bootstrap/file/cerulean_skin_image/image-icon.png
668
670
  - mod/bootstrap/file/cerulean_skin_image/image-large.png
669
671
  - mod/bootstrap/file/cerulean_skin_image/image-medium.png
@@ -799,6 +801,7 @@ files:
799
801
  - mod/bootstrap/lib/stylesheets/smartmenu.css
800
802
  - mod/bootstrap/lib/stylesheets/style_bootstrap_cards.scss
801
803
  - mod/bootstrap/lib/stylesheets/style_select2_bootstrap.scss
804
+ - mod/bootstrap/script/update_skin_thumbnails.rb
802
805
  - mod/bootstrap/set/abstract/bootstrap_code_file.rb
803
806
  - mod/bootstrap/set/all/bootstrap/accordion.rb
804
807
  - mod/bootstrap/set/all/bootstrap/form.rb
@@ -3654,6 +3657,7 @@ files:
3654
3657
  - mod/standard/set/all/rich_html/new.rb
3655
3658
  - mod/standard/set/all/rich_html/overlay.rb
3656
3659
  - mod/standard/set/all/rich_html/overlay/overlay_header.haml
3660
+ - mod/standard/set/all/rich_html/title.rb
3657
3661
  - mod/standard/set/all/rich_html/toolbar.rb
3658
3662
  - mod/standard/set/all/rich_html/wrapper.rb
3659
3663
  - mod/standard/set/right/discussion.rb
@@ -3679,9 +3683,9 @@ files:
3679
3683
  - mod/standard/set/type/set.rb
3680
3684
  - mod/standard/set/type/toggle.rb
3681
3685
  - mod/standard/set/type/uri.rb
3682
- - mod/standard/spec/chunk/include_spec.rb
3683
- - mod/standard/spec/chunk/link_spec.rb
3684
- - mod/standard/spec/chunk/query_reference_spec.rb
3686
+ - mod/standard/spec/content/chunk/include_spec.rb
3687
+ - mod/standard/spec/content/chunk/link_spec.rb
3688
+ - mod/standard/spec/content/chunk/query_reference_spec.rb
3685
3689
  - mod/standard/spec/format/css_format_spec.rb
3686
3690
  - mod/standard/spec/format/csv_format_spec.rb
3687
3691
  - mod/standard/spec/format/email_html_format_spec.rb