card 1.93.3 → 1.93.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 (160) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/db/migrate/20170908114452_increase_text_size_for_delayed_jobs.rb +9 -0
  4. data/db/migrate_core_cards/data/cards/*header +2 -2
  5. data/lib/card/format/nest.rb +12 -5
  6. data/lib/card/format/nest/fetch.rb +1 -2
  7. data/lib/card/format/render.rb +2 -2
  8. data/lib/card/model/save_helper.rb +1 -1
  9. data/lib/card/set/format/haml_views.rb +7 -3
  10. data/lib/card/subcards.rb +27 -228
  11. data/lib/card/subcards/add.rb +121 -0
  12. data/lib/card/subcards/relate.rb +27 -0
  13. data/lib/card/subcards/remove.rb +42 -0
  14. data/lib/card/tasks/card/create.rake +35 -132
  15. data/lib/card/tasks/card/file_card_creator.rb +25 -0
  16. data/lib/card/tasks/card/file_card_creator/abstract_file_card.rb +44 -0
  17. data/lib/card/tasks/card/file_card_creator/abstract_file_card/migration_file.rb +49 -0
  18. data/lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb +30 -0
  19. data/lib/card/tasks/card/file_card_creator/abstract_file_card/source_file.rb +36 -0
  20. data/lib/card/tasks/card/file_card_creator/haml_card.rb +42 -0
  21. data/lib/card/tasks/card/file_card_creator/output_helper.rb +50 -0
  22. data/lib/card/tasks/card/file_card_creator/script_card.rb +33 -0
  23. data/lib/card/tasks/card/file_card_creator/style_card.rb +25 -0
  24. data/lib/generators/card/template/template_generator.rb +1 -1
  25. data/mod/account/set/self/account_links.rb +1 -1
  26. data/mod/basic_formats/set/all/all_csv.rb +63 -0
  27. data/mod/basic_formats/set/all/json.rb +4 -1
  28. data/mod/bootstrap/db/migrate_cards/20170719163733_update_bootswatch_themes_to_4_beta.rb +5 -2
  29. data/mod/carrierwave/set/abstract/attachment.rb +1 -2
  30. data/mod/core/set/abstract/haml_file.rb +20 -0
  31. data/mod/core/set/all/chunk.rb +125 -0
  32. data/mod/core/set/all/collection.rb +2 -351
  33. data/mod/core/set/all/content.rb +26 -7
  34. data/mod/core/set/all/extended.rb +45 -0
  35. data/mod/core/set/all/haml.rb +3 -7
  36. data/mod/core/set/all/item.rb +92 -0
  37. data/mod/core/set/all/name.rb +36 -0
  38. data/mod/core/set/all/subcards.rb +21 -12
  39. data/mod/core/set/all/tabs.rb +50 -0
  40. data/mod/core/set/all/trash.rb +4 -0
  41. data/mod/core/spec/set/all/chunk_spec.rb +45 -0
  42. data/mod/core/spec/set/all/collection_spec.rb +6 -6
  43. data/mod/history/set/all/action_view.rb +1 -1
  44. data/mod/machines/lib/javascript/decko.js.coffee +3 -0
  45. data/mod/pointer/set/abstract/02_pointer/edit.rb +0 -2
  46. data/mod/search/set/abstract/search.rb +1 -1
  47. data/mod/search/set/all/filter.rb +0 -2
  48. data/mod/search/template/all/filter/_filter_input.haml +1 -1
  49. data/mod/search/template/all/filter/filter_form.haml +1 -1
  50. data/mod/standard/set/all/rich_html/editing.rb +1 -1
  51. data/mod/standard/set/all/rich_html/form.rb +6 -7
  52. data/mod/standard/set/all/rich_html/menu.rb +2 -3
  53. data/mod/standard/set/all/rich_html/toolbar.rb +3 -4
  54. data/mod/standard/set/type/cardtype.rb +1 -1
  55. data/mod/standard/spec/set/all/rich_html/editing_spec.rb +15 -4
  56. data/mod/tinymce_editor/db/migrate_cards/{20171113233150_update_tinymce_config.rb → 20171113233151_update_tinymce_config.rb} +1 -0
  57. metadata +25 -161
  58. data/.rspec +0 -4
  59. data/card.gemspec +0 -87
  60. data/db/seed/test/fixtures/.gitkeep +0 -0
  61. data/mod/bootstrap/vendor/bootstrap/.babelrc.js +0 -16
  62. data/mod/bootstrap/vendor/bootstrap/.editorconfig +0 -17
  63. data/mod/bootstrap/vendor/bootstrap/.eslintignore +0 -3
  64. data/mod/bootstrap/vendor/bootstrap/.gitattributes +0 -16
  65. data/mod/bootstrap/vendor/bootstrap/.github/CONTRIBUTING.md +0 -252
  66. data/mod/bootstrap/vendor/bootstrap/.github/ISSUE_TEMPLATE.md +0 -22
  67. data/mod/bootstrap/vendor/bootstrap/.gitignore +0 -46
  68. data/mod/bootstrap/vendor/bootstrap/.hound.yml +0 -19
  69. data/mod/bootstrap/vendor/bootstrap/.houndignore +0 -4
  70. data/mod/bootstrap/vendor/bootstrap/.travis.yml +0 -32
  71. data/mod/bootstrap/vendor/bootstrap/build/.htmllintrc +0 -19
  72. data/mod/bootstrap/vendor/bootstrap/build/.stylelintrc +0 -248
  73. data/mod/bootstrap/vendor/bootstrap/docs/4.0/examples/.stylelintrc +0 -12
  74. data/mod/bootstrap/vendor/bootstrap/js/.eslintrc.json +0 -240
  75. data/mod/bootstrap/vendor/bootstrap/js/tests/.eslintrc.json +0 -46
  76. data/mod/bootstrap/vendor/bootswatch/.gitignore +0 -7
  77. data/mod/bootstrap/vendor/bootswatch/.npmignore +0 -12
  78. data/mod/bootstrap/vendor/bootswatch/.travis.yml +0 -21
  79. data/mod/bootstrap/vendor/bootswatch/docs/.nojekyll +0 -0
  80. data/mod/bootstrap/vendor/bootswatch/docs/2/.travis.yml +0 -15
  81. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.bower.json +0 -20
  82. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.gitignore +0 -37
  83. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.travis.yml +0 -3
  84. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/js/.jshintrc +0 -12
  85. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/jquery/.bower.json +0 -20
  86. data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/jquery/.gitignore +0 -1
  87. data/mod/bootstrap/vendor/bootswatch/docs/2/swatchmaker/.gitignore +0 -1
  88. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap-sass-official/.bower.json +0 -45
  89. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/.bower.json +0 -44
  90. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/grunt/.jshintrc +0 -7
  91. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/js/.jscsrc +0 -42
  92. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/js/.jshintrc +0 -15
  93. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/less/.csscomb.json +0 -304
  94. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/less/.csslintrc +0 -19
  95. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/font-awesome/.bower.json +0 -14
  96. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/font-awesome/.gitignore +0 -32
  97. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/html5shiv/.bower.json +0 -25
  98. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/jquery/.bower.json +0 -38
  99. data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/respond/.bower.json +0 -20
  100. data/mod/bootstrap/vendor/select2/.editorconfig +0 -6
  101. data/mod/bootstrap/vendor/select2/.github/CONTRIBUTING.md +0 -204
  102. data/mod/bootstrap/vendor/select2/.github/ISSUE_TEMPLATE.md +0 -46
  103. data/mod/bootstrap/vendor/select2/.github/PULL_REQUEST_TEMPLATE.md +0 -13
  104. data/mod/bootstrap/vendor/select2/.gitignore +0 -3
  105. data/mod/bootstrap/vendor/select2/.jshintignore +0 -4
  106. data/mod/bootstrap/vendor/select2/.jshintrc +0 -25
  107. data/mod/bootstrap/vendor/select2/.travis.yml +0 -22
  108. data/script/fetch_bootswatch_themes.rb +0 -38
  109. data/spec/config/initializers/core_extensions_spec.rb +0 -47
  110. data/spec/config/initializers/patches/active_job_spec.rb +0 -7
  111. data/spec/lib/card/action_spec.rb +0 -15
  112. data/spec/lib/card/auth_spec.rb +0 -58
  113. data/spec/lib/card/cache_spec.rb +0 -116
  114. data/spec/lib/card/chunk_spec.rb +0 -18
  115. data/spec/lib/card/codename_spec.rb +0 -66
  116. data/spec/lib/card/content_spec.rb +0 -428
  117. data/spec/lib/card/diff_spec.rb +0 -208
  118. data/spec/lib/card/format/nest_spec.rb +0 -13
  119. data/spec/lib/card/format/render_spec.rb +0 -26
  120. data/spec/lib/card/format_spec.rb +0 -117
  121. data/spec/lib/card/i18n_spec.rb +0 -24
  122. data/spec/lib/card/loader/Modfile +0 -2
  123. data/spec/lib/card/loader_spec.rb +0 -98
  124. data/spec/lib/card/migration/import_spec.rb +0 -80
  125. data/spec/lib/card/mod/loader/mod_dirs.rb +0 -8
  126. data/spec/lib/card/mod/loader/set_loader_spec.rb +0 -19
  127. data/spec/lib/card/mod/loader/set_pattern_loader_spec.rb +0 -19
  128. data/spec/lib/card/name/fields_and_traits_spec.rb +0 -18
  129. data/spec/lib/card/name_spec.rb +0 -70
  130. data/spec/lib/card/query/sorting_spec.rb +0 -68
  131. data/spec/lib/card/query_spec.rb +0 -574
  132. data/spec/lib/card/reference_spec.rb +0 -212
  133. data/spec/lib/card/set/event_spec.rb +0 -22
  134. data/spec/lib/card/set/trait_spec.rb +0 -80
  135. data/spec/lib/card/set_pattern_spec.rb +0 -59
  136. data/spec/lib/card/set_spec.rb +0 -89
  137. data/spec/lib/card/stage_director_spec.rb +0 -482
  138. data/spec/lib/card/subcards_spec.rb +0 -177
  139. data/spec/lib/card/success_spec.rb +0 -148
  140. data/spec/lib/card/view_cache_spec.rb +0 -27
  141. data/spec/mailers/mailer_spec.rb +0 -62
  142. data/spec/models/card/create_spec.rb +0 -119
  143. data/spec/models/card/trash_spec.rb +0 -189
  144. data/spec/models/card_spec.rb +0 -136
  145. data/spec/spec_helper.rb +0 -45
  146. data/spec/support/card_spec_helper.rb +0 -74
  147. data/spec/support/card_spec_loader.rb +0 -112
  148. data/spec/support/helper/card_helper.rb +0 -58
  149. data/spec/support/helper/event_helper.rb +0 -94
  150. data/spec/support/helper/render_helper.rb +0 -44
  151. data/spec/support/helper/save_helper.rb +0 -30
  152. data/spec/support/helper/set_helper.rb +0 -80
  153. data/spec/support/matchers/card_matchers.rb +0 -160
  154. data/spec/support/matchers/expectations.rb +0 -5
  155. data/spec/support/matchers/file_matchers.rb +0 -71
  156. data/spec/support/matchers/html_matchers.rb +0 -29
  157. data/spec/support/matchers/negated_matchers.rb +0 -2
  158. data/spec/support/simplecov_helper.rb +0 -70
  159. data/spec/support/test_mods/mod1/set/all/test_set.rb +0 -3
  160. data/spec/support/test_mods/mod2/set_pattern/test_pattern.rb +0 -0
@@ -1,22 +0,0 @@
1
- language: node_js
2
-
3
- sudo: false
4
-
5
- node_js:
6
- - 0.10
7
-
8
- env:
9
- global:
10
- - secure: XMNK8GVxkwKa6oLl7nJwgg/wmY1YDk5rrMd+UXz26EDCsMDbiy1P7GhN2fEiBSLaQ7YfEuvaDcmzQxTrT0YTHp1PDzb2o9J4tIDdEkqPcv1y8xMaYDfmsN0rBPdBwZEg9H5zUgi7OdUbrGswSYxsKCE3x8EOqK89104HyOo1LN4=
11
- - secure: BU5BPRx6H4O3WJ509YPixjUxg+hDF3z2BVJX6NiGmKWweqvCEYFfiiHLwDEgp/ynRcF9vGVi1V4Ly1jq7f8NIajbDZ5q443XchZFYFg78K/EwD5mK6LYt16zb7+Jn0KbzwHeGRGzc9AvcEYlW6i634cSCm4n3BnqtF5PpogSzdw=
12
-
13
- script:
14
- - grunt ci
15
-
16
- notifications:
17
- email: false
18
- irc:
19
- channels:
20
- - "chat.freenode.net#select2"
21
- on_success: change
22
- on_failure: always
@@ -1,38 +0,0 @@
1
- require "active_support"
2
- require "uri/https"
3
- require "open-uri"
4
- require "fileutils"
5
-
6
- THEMES = %w[Cerulean Cosmo Cyborg Darkly Flatly Journal Litera Lumen Lux Materia Minty
7
- Pulse Sandstone Simplex Slate Solar Spacelab Superhero United Yeti]
8
- .map(&:downcase).freeze
9
-
10
- class Theme
11
- STORE_DIR = File.expand_path("../../db/migrate_core_cards/data/b4_themes", __FILE__).freeze
12
- BOOTSWATCH_HOST = "bootswatch.com".freeze
13
- VERSION = "4-alpha"
14
-
15
- def initialize name
16
- @theme = name
17
- @store_dir = File.join STORE_DIR, @theme
18
- FileUtils.mkdir_p @store_dir
19
- end
20
-
21
- def store_path filename
22
- File.join @store_dir, filename
23
- end
24
-
25
- def uri object
26
- URI::HTTPS.build host: BOOTSWATCH_HOST, path: "/#{VERSION}/#{@theme}/#{object}"
27
- end
28
- end
29
-
30
- THEMES.each do |theme_name|
31
- theme = Theme.new theme_name
32
- %w[_variables.scss _bootswatch.scss thumbnail.png].each do |filename|
33
- File.open(theme.store_path(filename), "w") do |f|
34
- puts theme.uri(filename)
35
- f.puts theme.uri(filename).read
36
- end
37
- end
38
- end
@@ -1,47 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- describe CoreExtensions do
4
- context Hash do
5
- describe "#new_nested" do
6
- it "creates nested hashes" do
7
- nested_hash = Hash.new_nested Hash, Hash
8
- expect(nested_hash[:a]).to be_instance_of Hash
9
- expect(nested_hash[:a][:b]).to be_instance_of Hash
10
- expect(nested_hash[:d][:c]).to be_instance_of Hash
11
- end
12
-
13
- it "creates set in hash" do
14
- nested_hash = Hash.new_nested ::Set
15
- expect(nested_hash[:a]).to be_instance_of ::Set
16
- end
17
- end
18
- end
19
-
20
- context CoreExtensions::PersistentIdentifier do
21
- describe "#name" do
22
- subject { :wagn_bot.cardname }
23
- it "converts into a name" do
24
- is_expected.to be_instance_of Card::Name
25
- expect(subject.s).to eq "Wagn Bot"
26
- end
27
- end
28
-
29
- describe "#card" do
30
- context "called on Integer" do
31
- subject { Card::LogoID.card }
32
- it "converts into a card" do
33
- is_expected.to be_instance_of Card
34
- expect(subject.id).to eq Card::LogoID
35
- end
36
- end
37
-
38
- context "called on Symbol" do
39
- subject { :logo.card }
40
- it "converts into a card" do
41
- is_expected.to be_instance_of Card
42
- expect(subject.key).to eq(:logo.cardname.key)
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,7 +0,0 @@
1
- RSpec.describe ActiveJob::Arguments, "serialize patch" do
2
- it "handles symbols" do
3
- ser = ActiveJob::Arguments.serialize([:sym])
4
- deser = ActiveJob::Arguments.deserialize(ser)
5
- expect(deser).to eq [:sym]
6
- end
7
- end
@@ -1,15 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- describe Card::Action do
4
- describe "#delete_old_actions" do
5
- it "puts all changes on one action" do
6
- a = Card["A"]
7
- a.update_attributes!(name: "New A")
8
- a.update_attributes!(content: "New content")
9
- a.clear_history
10
- expect(a.actions.count).to eq(1)
11
- expect(a.actions.last.card_changes.count).to eq(0)
12
- expect(a.actions.reload.last.value :name).to eq("New A")
13
- end
14
- end
15
- end
@@ -1,58 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- describe Card::Auth do
4
- before do
5
- Card::Auth.current_id = Card::AnonymousID
6
- @joeuserid = Card["Joe User"].id
7
- end
8
-
9
- it "authenticates user" do
10
- authenticated = Card::Auth.authenticate "joe@user.com", "joe_pass"
11
- expect(authenticated.left_id).to eq(@joeuserid)
12
- end
13
-
14
- it "authenticates user despite whitespace" do
15
- authenticated = Card::Auth.authenticate " joe@user.com ", " joe_pass "
16
- expect(authenticated.left_id).to eq(@joeuserid)
17
- end
18
-
19
- it "authenticates user with weird email capitalization" do
20
- authenticated = Card::Auth.authenticate "JOE@user.com", "joe_pass"
21
- expect(authenticated.left_id).to eq(@joeuserid)
22
- end
23
-
24
- it "sets current directly from email" do
25
- Card::Auth.current= "joe@user.com"
26
- expect(Card::Auth.current_id).to eq(@joeuserid)
27
- end
28
-
29
- it "sets current directly from id when mark is id" do
30
- Card::Auth.current= @joeuserid
31
- expect(Card::Auth.current_id).to eq(@joeuserid)
32
- end
33
-
34
- it "sets current directly from id when mark is id" do
35
- Card::Auth.current= @joeuserid
36
- expect(Card::Auth.current_id).to eq(@joeuserid)
37
- end
38
-
39
- context "with token" do
40
- before do
41
- @joeadmin = Card["Joe Admin"]
42
- @token = "abcd"
43
- Card::Auth.as_bot do
44
- @joeadmin.account.token_card.update_attributes! content: @token
45
- end
46
- end
47
-
48
- it "sets current from token" do
49
- Card::Auth.set_current_from_token @token
50
- expect(Card::Auth.current_id).to eq(@joeadmin.id)
51
- end
52
-
53
- it "sets arbitrary current from token on authorized account" do
54
- Card::Auth.set_current_from_token @token, @joeuserid
55
- expect(Card::Auth.current_id).to eq(@joeuserid)
56
- end
57
- end
58
- end
@@ -1,116 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- describe Card::Cache do
4
- describe "with nil store" do
5
- before do
6
- @cache = Card::Cache.new prefix: "prefix"
7
- end
8
-
9
- describe "#basic operations" do
10
- it "works" do
11
- @cache.write("a", "foo")
12
- expect(@cache.read("a")).to eq("foo")
13
- @cache.fetch("b") { "bar" }
14
- expect(@cache.read("b")).to eq("bar")
15
- @cache.reset
16
- end
17
- end
18
- end
19
-
20
- describe "with same cache_id" do
21
- before :each do
22
- @hard = ActiveSupport::Cache::MemoryStore.new
23
- @cache = Card::Cache.new store: @hard
24
- @prefix = @cache.hard.prefix
25
- end
26
-
27
- it "#read" do
28
- expect(@hard).to receive(:read).with("#{@prefix}/foo")
29
- @cache.read("foo")
30
- end
31
-
32
- it "#write" do
33
- expect(@hard).to receive(:write).with("#{@prefix}/foo", "val")
34
- @cache.write("foo", "val")
35
- expect(@cache.read("foo")).to eq("val")
36
- end
37
-
38
- it "#fetch" do
39
- block = proc { "hi" }
40
- expect(@hard).to receive(:fetch).with("#{@prefix}/foo", &block)
41
- @cache.fetch("foo", &block)
42
- end
43
-
44
- it "#delete" do
45
- expect(@hard).to receive(:delete).with("#{@prefix}/foo")
46
- @cache.delete "foo"
47
- end
48
-
49
- it "#soft.write" do
50
- @cache.soft.write("a", "foo")
51
- expect(@cache.read("a")).to eq("foo")
52
- expect(@hard).not_to receive(:write)
53
- expect(@cache.hard.read("a")).to eq(nil)
54
- end
55
- end
56
-
57
- it "#reset" do
58
- @hard = ActiveSupport::Cache::MemoryStore.new
59
- @cache = Card::Cache.new store: @hard, database: "mydb"
60
-
61
- expect(@cache.hard.prefix).to match(/^mydb-/)
62
- @cache.write("foo", "bar")
63
- expect(@cache.read("foo")).to eq("bar")
64
-
65
- # reset
66
- @cache.reset
67
- expect(@cache.hard.prefix).to match(/^mydb-/)
68
- expect(@cache.read("foo")).to be_nil
69
-
70
- cache2 = Card::Cache.new store: @hard, database: "mydb"
71
- expect(cache2.hard.prefix).to match(/^mydb-/)
72
- end
73
-
74
- describe "with file store" do
75
- before do
76
- cache_path = "#{Decko.root}/tmp/cache"
77
- FileUtils.mkdir_p(cache_path) unless File.directory?(cache_path)
78
- @hard = ActiveSupport::Cache::FileStore.new cache_path
79
-
80
- @hard.clear
81
- # cache_path = cache_path + '/prefix'
82
- # p = Pathname.new(cache_path)
83
- # p.mkdir if !p.exist?
84
- #
85
- # root_dirs = Dir.entries(cache_path).reject{|f| ['.', '..'].include?(f)}
86
- # files_to_remove = root_dirs.collect{|f| File.join(cache_path, f)}
87
- # FileUtils.rm_r(files_to_remove)
88
- @cache = Card::Cache.new store: @hard, prefix: "prefix"
89
- end
90
-
91
- describe "#basic operations with special symbols" do
92
- it "works" do
93
- @cache.write('%\\/*:?"<>|', "foo")
94
- cache2 = Card::Cache.new store: @hard, prefix: "prefix"
95
- expect(cache2.read('%\\/*:?"<>|')).to eq("foo")
96
- @cache.reset
97
- end
98
- end
99
-
100
- describe "#basic operations with non-latin symbols" do
101
- it "works" do
102
- @cache.write("(汉语漢語 Hànyǔ; 华语華語 Huáyǔ; 中文 Zhōngwén", "foo")
103
- @cache.write("русский", "foo")
104
- cache3 = Card::Cache.new store: @hard, prefix: "prefix"
105
- cached = cache3.read "(汉语漢語 Hànyǔ; 华语華語 Huáyǔ; 中文 Zhōngwén"
106
- expect(cached).to eq("foo")
107
- expect(cache3.read("русский")).to eq("foo")
108
- @cache.reset
109
- end
110
- end
111
-
112
- describe "#tempfile" do
113
- # TODO
114
- end
115
- end
116
- end
@@ -1,18 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require "card/content/chunk"
3
-
4
- describe Card::Content::Chunk, "Chunk" do
5
- context "Class" do
6
- it "populates prefix map on load" do
7
- expect(Card::Content::Chunk.prefix_map_by_list[:default].keys.size)
8
- .to be > 0
9
- expect(Card::Content::Chunk.prefix_map_by_list[:default]["{"][:class])
10
- .to eq(Card::Content::Chunk::Nest)
11
- end
12
-
13
- it "finds Chunk classes using matched prefix" do
14
- expect(Card::Content::Chunk.find_class_by_prefix("{{"))
15
- .to eq(Card::Content::Chunk::Nest)
16
- end
17
- end
18
- end
@@ -1,66 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- RSpec.describe Card::Codename, "Codename" do
4
- before do
5
- @codename = :default
6
- end
7
-
8
- it "is sane" do
9
- expect(Card[@codename].codename).to eq(@codename)
10
- card_id = Card::Codename.id @codename
11
- expect(card_id).to be_a_kind_of Integer
12
- expect(Card::Codename[card_id]).to eq(@codename)
13
- end
14
-
15
- it "makes cards indestructable" do
16
- Card::Auth.as_bot do
17
- card = Card[@codename]
18
- card.delete
19
- expect(card.errors[:delete].first).to match "is a system card"
20
- expect(Card[@codename]).to be
21
- end
22
- end
23
-
24
- it "raises error for missing codename" do
25
- expect { Card::NotACodenameID }
26
- .to raise_error(Card::Error::UnknownCodename, /unknown codename: not_a_codename/)
27
- end
28
-
29
- describe "#id" do
30
- example "symbol" do
31
- expect(Card::Codename.id(:all)).to eq Card.fetch_id(:all)
32
- end
33
-
34
- example "id" do
35
- all_id = Card.fetch_id(:all)
36
- expect(Card::Codename.id(all_id)).to eq all_id
37
- end
38
-
39
- example "string" do
40
- expect(Card::Codename.id("all")).to eq Card.fetch_id(:all)
41
- end
42
-
43
- example "missing codename" do
44
- expect(Card::Codename.id("unknown")).to eq nil
45
- end
46
- end
47
-
48
- describe "#[]" do
49
- example "symbol" do
50
- expect(Card::Codename[:all]).to eq :all
51
- end
52
-
53
- example "id" do
54
- all_id = Card.fetch_id(:all)
55
- expect(Card::Codename[all_id]).to eq :all
56
- end
57
-
58
- example "string" do
59
- expect(Card::Codename["all"]).to eq :all
60
- end
61
-
62
- example "missing codename" do
63
- expect(Card::Codename["unknown"]).to eq nil
64
- end
65
- end
66
- end
@@ -1,428 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require "card/content"
3
-
4
- describe Card::Content do
5
- EXAMPLES = {
6
- nests: {
7
- content: "Some Literals: \\[{I'm not| a link]}, and " \
8
- '\\{{This Card|Is not Nestd}}' \
9
- ", but " \
10
- "{{this is}}" \
11
- ", and some tail",
12
- rendered: ["Some Literals: \\[{I'm not| a link]}, and ",
13
- "<span>{</span>{This Card|Is not Nestd}}",
14
- ", but ",
15
- { options: { nest_name: "this is",
16
- nest_syntax: "this is" } },
17
- ", and some tail"],
18
- classes: [String, :EscapedLiteral, String, :Nest, String]
19
- },
20
-
21
- links_and_nests: {
22
- content: "Some Links and includes: [[the card|the text]], " \
23
- "and {{This Card|Is Nestd}}{{this too}} " \
24
- "and [[http://external.wagn.org/path|link text]]" \
25
- "{{Nestd|open}}",
26
- rendered: ["Some Links and includes: ",
27
- '<a class="wanted-card" ' \
28
- 'href="/the_card">' \
29
- '<span class="card-title">the text</span></a>',
30
- ", and ",
31
- { options: { view: "Is Nestd",
32
- nest_name: "This Card",
33
- nest_syntax: "This Card|Is Nestd" } },
34
- { options: { nest_name: "this too",
35
- nest_syntax: "this too" } },
36
- " and ",
37
- '<a target="_blank" class="external-link" ' \
38
- 'href="http://external.wagn.org/path">link text</a>',
39
- { options: { view: "open",
40
- nest_name: "Nestd",
41
- nest_syntax: "Nestd|open" } }],
42
- classes: [
43
- String, :Link, String, :Nest, :Nest, String, :Link, :Nest
44
- ]
45
- },
46
-
47
- uris_and_links: {
48
- content: "Some URIs and Links: http://a.url.com/ " \
49
- "More urls: wagn.com/a/path/to.html " \
50
- "http://localhost:2020/path?cgi=foo&bar=baz " \
51
- "[[http://brain.org/Home|extra]] " \
52
- "[ http://gerry.wagn.com/a/path ] " \
53
- "{ https://brain.org/more?args } ",
54
- rendered: ["Some URIs and Links: ",
55
- '<a target="_blank" class="external-link" ' \
56
- 'href="http://a.url.com/">http://a.url.com/</a>',
57
- " More urls: ",
58
- '<a target="_blank" class="external-link" ' \
59
- 'href="http://wagn.com/a/path/to.html">' \
60
- "wagn.com/a/path/to.html</a>",
61
- " ",
62
- '<a target="_blank" class="external-link" ' \
63
- 'href="http://localhost:2020/path?cgi=foo&amp;bar=baz">' \
64
- "http://localhost:2020/path?cgi=foo&bar=baz</a>",
65
- " ",
66
- '<a target="_blank" class="external-link" ' \
67
- 'href="http://brain.org/Home">extra</a>',
68
- " [ ",
69
- '<a target="_blank" class="external-link" ' \
70
- 'href="http://gerry.wagn.com/a/path">' \
71
- "http://gerry.wagn.com/a/path</a>",
72
- " ] { ",
73
- '<a target="_blank" class="external-link" ' \
74
- 'href="https://brain.org/more?args">' \
75
- "https://brain.org/more?args</a>",
76
- " } "],
77
- text_rendered: ["Some URIs and Links: ", "http://a.url.com/",
78
- " More urls: ",
79
- "wagn.com/a/path/to.html[http://wagn.com/a/path/to.html]",
80
- " ",
81
- "http://localhost:2020/path?cgi=foo&bar=baz",
82
- " ",
83
- "extra[http://brain.org/Home]",
84
- " [ ",
85
- "http://gerry.wagn.com/a/path",
86
- " ] { ",
87
- "https://brain.org/more?args",
88
- " } "],
89
- classes: [
90
- String, :URI, String, :HostURI, String, :URI, String, :Link,
91
- String, :URI, String, :URI, String
92
- ]
93
- },
94
-
95
- uris_and_links_2: {
96
- content: "Some URIs and Links: http://a.url.com " \
97
- "More urls: wagn.com/a/path/to.html " \
98
- "[ http://gerry.wagn.com/a/path ] " \
99
- "{ https://brain.org/more?args } " \
100
- "http://localhost:2020/path?cgi=foo&bar=baz " \
101
- "[[http://brain.org/Home|extra]]",
102
- rendered: ["Some URIs and Links: ",
103
- '<a target="_blank" class="external-link" ' \
104
- 'href="http://a.url.com">http://a.url.com</a>',
105
- " More urls: ",
106
- '<a target="_blank" class="external-link" ' \
107
- 'href="http://wagn.com/a/path/to.html">' \
108
- "wagn.com/a/path/to.html</a>",
109
- " [ ",
110
- '<a target="_blank" class="external-link" ' \
111
- 'href="http://gerry.wagn.com/a/path">' \
112
- "http://gerry.wagn.com/a/path</a>",
113
- " ] { ",
114
- '<a target="_blank" class="external-link" ' \
115
- 'href="https://brain.org/more?args">' \
116
- "https://brain.org/more?args</a>",
117
- " } ",
118
- '<a target="_blank" class="external-link" ' \
119
- 'href="http://localhost:2020/path?cgi=foo&amp;bar=baz">' \
120
- "http://localhost:2020/path?cgi=foo&bar=baz</a>",
121
- " ",
122
- '<a target="_blank" class="external-link" ' \
123
- 'href="http://brain.org/Home">extra</a>'],
124
- classes: [
125
- String, :URI, String, :HostURI, String, :URI, String, :URI,
126
- String, :URI, String, :Link
127
- ]
128
- },
129
-
130
- no_chunks: {
131
- content: "No chunks",
132
- rendered: "No chunks"
133
- },
134
-
135
- single_nest: {
136
- content: "{{one nest|size;large}}",
137
- classes: [:Nest]
138
- },
139
-
140
- css: {
141
- content: %(
142
- /* body text */
143
- body {
144
- color: #444444;
145
- }
146
-
147
- /* page - background image and color */
148
- body#wagn {
149
- background: #ffffff;
150
- }
151
-
152
- /* top bar background color; text colors */
153
- #menu {
154
- background: #3260a0;
155
- }
156
- #menu a {
157
- color: #EEEEEE;
158
- }
159
-
160
- /* header text */
161
- h1, h2 {
162
- color: #664444;
163
- }
164
- h1.page-header,
165
- h2.page-header {
166
- color: #222299;
167
- }
168
- )
169
- }
170
- }.freeze
171
-
172
- EXAMPLES.each_value do |val|
173
- next unless val[:classes]
174
- val[:classes] = val[:classes].map do |klass|
175
- klass.is_a?(Class) ? klass : Card::Content::Chunk.const_get(klass)
176
- end
177
- end
178
-
179
- context "instance" do
180
- before do
181
- @check_proc = proc do |m, v|
182
- if m.is_a? Array
183
- wrong_class = m[0] != v.class
184
- expect(wrong_class).to be_falsey
185
- is_last = m.size == 1
186
- is_last ? true : m[1..-1] unless wrong_class
187
- end
188
- end
189
-
190
- assert card = Card["One"]
191
- @card = card
192
-
193
- # non-nil valued opts only ...
194
- @render_block = proc do |opts|
195
- options = opts.inject({}) do |i, v|
196
- i if !v[1].nil? && (i[v[0]] = v[1])
197
- end
198
- { options: options }
199
- end
200
- end
201
-
202
- let(:example) { EXAMPLES[@example] }
203
- let(:cobj) { Card::Content.new example[:content], @card }
204
- let(:classes) { example[:classes] }
205
- let(:rendered) { example[:rendered] }
206
- let(:text_rendered) { example[:text_rendered] }
207
- let(:content) { example[:content] }
208
-
209
- describe "parse" do
210
- def check_chunk_classes
211
- all_classes_pass_check_proc
212
- clist = nonstring_classes
213
- cobj.each_chunk do |chk|
214
- expect(chk).to be_instance_of clist.shift
215
- end
216
- expect(clist).to be_empty
217
- end
218
-
219
- def nonstring_classes
220
- classes.select { |c| String != c }
221
- end
222
-
223
- def all_classes_pass_check_proc
224
- expect(cobj.inject(classes, &@check_proc)).to eq(true)
225
- end
226
-
227
- it "finds all the chunks and strings" do
228
- # note the mixed [} that are considered matching, needs some cleanup ...
229
- @example = :nests
230
- all_classes_pass_check_proc
231
- end
232
-
233
- it "gives just the chunks" do
234
- @example = :nests
235
- check_chunk_classes
236
- end
237
-
238
- it "finds all the chunks links and trasclusions" do
239
- @example = :links_and_nests
240
- all_classes_pass_check_proc
241
- end
242
-
243
- it "finds uri chunks " do
244
- # tried some tougher cases that failed, don't know the spec, so
245
- # hard to form better tests for URIs here
246
- @example = :uris_and_links
247
- check_chunk_classes
248
- end
249
-
250
- it "finds uri chunks (b)" do
251
- # tried some tougher cases that failed, don't know the spec, so
252
- # hard to form better tests for URIs here
253
- @example = :uris_and_links_2
254
- check_chunk_classes
255
- end
256
-
257
- it "parses just a string" do
258
- @example = :no_chunks
259
- expect(cobj).to eq(rendered)
260
- end
261
-
262
- it "parses a single chunk" do
263
- @example = :single_nest
264
- check_chunk_classes
265
- end
266
-
267
- it "leaves css alone" do
268
- @example = :css
269
- expect(cobj).to eq(content)
270
- end
271
- end
272
-
273
- describe "render" do
274
- it "renders all nests" do
275
- @example = :nests
276
- expect(cobj.as_json.to_s).to match(/not rendered/)
277
- cobj.process_each_chunk(&@render_block)
278
- rdr = cobj.as_json.to_json
279
- expect(rdr).not_to match(/not rendered/)
280
- expect(rdr).to eq(rendered.to_json)
281
- end
282
-
283
- it "renders links and nests" do
284
- @example = :links_and_nests
285
- cobj.process_each_chunk(&@render_block)
286
- rdr = cobj.as_json.to_json
287
- expect(rdr).not_to match(/not rendered/)
288
- expect(rdr).to eq(rendered.to_json)
289
- end
290
-
291
- it "renders links correctly for text formatters" do
292
- @example = :uris_and_links
293
- card2 = Card[@card.id]
294
- format = card2.format format: :text
295
- cobj = Card::Content.new content, format
296
- cobj.process_each_chunk(&@render_block)
297
- expect(cobj.as_json.to_json).to eq(text_rendered.to_json)
298
- end
299
-
300
- it "does not need rendering if no nests" do
301
- @example = :uris_and_links
302
- cobj.process_each_chunk(&@render_block)
303
- expect(cobj.as_json.to_json).to eq(rendered.to_json)
304
- end
305
-
306
- it "does not need rendering if no nests (b)" do
307
- @example = :uris_and_links_2
308
- rdr1 = cobj.as_json.to_json
309
- expect(rdr1).to match(/not rendered/)
310
- # links are rendered too, but not with a block
311
- cobj.process_each_chunk(&@render_block)
312
- rdr2 = cobj.as_json.to_json
313
- expect(rdr2).not_to match(/not rendered/)
314
- expect(rdr2).to eq(rendered.to_json)
315
- end
316
- end
317
- end
318
-
319
- UNTAGGED_CASES = [" [grrew][/wiki/grrew]ss ",
320
- " {{this is a test}}, {{this|view|is:too}} and",
321
- " so is http://foo.bar.come//",
322
- ' and foo="my attr, not int a tag" <not a=tag ',
323
- ' p class"foobar"> and more'].freeze
324
-
325
- context "class" do
326
- describe "#clean!" do
327
- it "does not alter untagged content" do
328
- UNTAGGED_CASES.each do |test_case|
329
- assert_equal test_case, Card::Content.clean!(test_case)
330
- end
331
- end
332
-
333
- it "strips disallowed html class attributes" do
334
- assert_equal "<p>html<div>with</div> funky tags</p>",
335
- Card::Content.clean!(
336
- '<p>html<div class="boo">with</div>' \
337
- "<monkey>funky</butts>tags</p>"
338
- )
339
- assert_equal "<span>foo</span>",
340
- Card::Content.clean!('<span class="banana">foo</span>')
341
- end
342
-
343
- it "does not strip permitted_classes" do
344
- has_stripped1 = '<span class="w-spotlight">foo</span>'
345
- assert_equal has_stripped1,
346
- Card::Content.clean!(has_stripped1)
347
- has_stripped2 = '<p class="w-highlight w-ok">foo</p>'
348
- assert_equal has_stripped2,
349
- Card::Content.clean!(has_stripped2)
350
- end
351
-
352
- it "strips permitted_classes " \
353
- "but not permitted ones when both are present" do
354
- assert_equal '<span class="w-spotlight w-ok">foo</span>',
355
- Card::Content.clean!(
356
- '<span class="w-spotlight banana w-ok">foo</span>'
357
- )
358
- assert_equal '<p class="w-highlight">foo</p>',
359
- Card::Content.clean!(
360
- '<p class="w-highlight bad-at end">foo</p>'
361
- )
362
- assert_equal '<p class="w-highlight">foo</p>',
363
- Card::Content.clean!(
364
- '<p class="bad-class w-highlight">foo</p>'
365
- )
366
- end
367
-
368
- it "allows permitted attributes" do
369
- assert_equal '<img src="foo">', Card::Content.clean!('<img src="foo">')
370
- assert_equal "<img alt='foo'>", Card::Content.clean!("<img alt='foo'>")
371
- assert_equal '<img title="foo">',
372
- Card::Content.clean!("<img title=foo>")
373
- assert_equal '<a href="foo">', Card::Content.clean!('<a href="foo">')
374
- assert_equal '<code lang="foo">',
375
- Card::Content.clean!('<code lang="foo">')
376
- assert_equal '<blockquote cite="foo">',
377
- Card::Content.clean!('<blockquote cite="foo">')
378
- end
379
-
380
- it "does not allow nonpermitted attributes" do
381
- assert_equal "<img>", Card::Content.clean!('<img size="25">')
382
- assert_equal "<p>", Card::Content.clean!('<p font="blah">')
383
- end
384
-
385
- it "removes comments" do
386
- assert_equal "yo", Card::Content.clean!("<!-- not me -->yo")
387
- assert_equal "joe",
388
- Card::Content.clean!("<!-- not me -->joe<!-- not me -->")
389
- end
390
-
391
- it "fixes regular nbsp order by default" do
392
- assert_equal "space&nbsp; test&nbsp; two&nbsp;&nbsp; space",
393
- Card::Content.clean!(
394
- "space&nbsp; test &nbsp;two &nbsp;&nbsp;space"
395
- )
396
- end
397
-
398
- # it "doesn't fix regular nbsp order with setting" do
399
- # # manually configure this setting, then make this one live
400
- # # (test above will then fail)
401
- # pending "Can't set Card.config.space_last_in_multispace= false "\
402
- # 'for one test'
403
- # assert_equal 'space&nbsp; test &nbsp;two &nbsp;&nbsp;space',
404
- # Card::Content.clean!(
405
- # 'space&nbsp; test &nbsp;two &nbsp;&nbsp;space'
406
- # )
407
- # end
408
- end
409
- end
410
-
411
- describe "#pieces" do
412
- def pieces content
413
- Card::Content.new(content, Card["A"],).pieces
414
- end
415
-
416
- example "A {{B}}" do
417
- expect(pieces("A {{B}}").size).to eq 2
418
- end
419
-
420
- example "A" do
421
- expect(pieces("A").size).to eq 1
422
- end
423
-
424
- example "{{B}}" do
425
- expect(pieces("{{B}}").size).to eq 1
426
- end
427
- end
428
- end