card 1.93.6 → 1.93.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/initializers/02_patches/active_record.rb +13 -0
- data/config/initializers/patches.rb +6 -0
- data/config/initializers/recaptcha.rb +16 -14
- data/lib/card.rb +4 -3
- data/lib/card/format/nest/fetch.rb +1 -3
- data/lib/card/migration/deck_structure.rb +18 -0
- data/lib/card/query/attributes.rb +1 -1
- data/lib/card/query/clause.rb +6 -7
- data/lib/card/query/interpretation.rb +5 -1
- data/lib/card/query/value.rb +29 -19
- data/lib/card/set/event.rb +52 -28
- data/lib/card/set/event/delayed_event.rb +3 -3
- data/lib/card/set/format/haml_views.rb +1 -1
- data/lib/card/tasks/card.rake +7 -0
- data/lib/card/tasks/card/migrate.rake +29 -0
- data/lib/card/view/options.rb +7 -189
- data/lib/card/view/options/key_lists.rb +41 -0
- data/lib/card/view/options/voo_api.rb +165 -0
- data/lib/cardio.rb +16 -7
- data/lib/cardio/schema.rb +6 -1
- data/mod/basic_formats/set/all/base.rb +7 -3
- data/mod/basic_formats/set/self/head.rb +5 -0
- data/mod/carrierwave/config/core_initializers/carrierwave.rb +7 -0
- data/mod/core/set/all/name_validations.rb +3 -4
- data/mod/machines/file/all_script_machine_output/file.js +75 -23
- data/mod/machines/file/all_style_machine_output/file.css +2 -2
- data/mod/machines/lib/javascript/decko.js.coffee +1 -1
- data/mod/machines/lib/javascript/decko_filter.js.coffee +18 -10
- data/mod/pointer/set/abstract/02_pointer.rb +1 -1
- data/mod/pointer/set/abstract/02_pointer/filtered.rb +3 -1
- data/mod/pointer/template/abstract/02_pointer/filtered/filter_items.haml +2 -1
- data/mod/pointer/template/abstract/02_pointer/filtered/filtered_list_input.haml +3 -2
- data/mod/search/set/abstract/01_filter_form_helper.rb +8 -0
- data/mod/search/set/abstract/{01_search_params.rb → 02_search_params.rb} +0 -0
- data/mod/search/set/abstract/03_filter.rb +1 -1
- data/mod/search/set/abstract/wql_search.rb +7 -0
- data/mod/search/template/abstract/03_filter/filter_form.haml +24 -22
- data/mod/search/template/abstract/search/checkbox_item.haml +1 -1
- metadata +9 -6
- data/mod/search/set/abstract/02_filter_formgroups.rb +0 -134
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c81d66467e56b3af782e751bba26e6827dd6d9a0
|
4
|
+
data.tar.gz: b16da38bf76b952dfa8ee0886a83a32676feaf80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c8a5450fb09bbfd53a6598eb0037ac5efebde683da6fd419ef069709c4e0848754896a5622c97c79baa41e0cfc4769b18e822f98af95f18f6a6e1fa21d2fac7
|
7
|
+
data.tar.gz: 5f635635cefc576134b1f806b2ca8b9b10d1310fa6d4317ce5f92d739dc78bf463d16f43893de4ef741029f092ad931cf1f5cbc043eb87c11967e8077af1692d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
@@ -104,5 +104,18 @@ module Patches
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
+
|
108
|
+
module Migration
|
109
|
+
module ClassMethods
|
110
|
+
def check_pending! connection=::ActiveRecord::Base.connection
|
111
|
+
%i[structure core_cards deck deck_cards].each do |migration_type|
|
112
|
+
Cardio.schema_mode(migration_type) do |paths|
|
113
|
+
::ActiveRecord::Migrator.migrations_paths = paths
|
114
|
+
super
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
107
120
|
end
|
108
121
|
end
|
@@ -19,6 +19,12 @@ module ActiveRecord #:nodoc: all
|
|
19
19
|
include Patches::ActiveRecord::Relation
|
20
20
|
end
|
21
21
|
|
22
|
+
class Migration
|
23
|
+
class << self
|
24
|
+
prepend Patches::ActiveRecord::Migration::ClassMethods
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
module ConnectionAdapters
|
23
29
|
class AbstractAdapter
|
24
30
|
prepend Patches::ActiveRecord::ConnectionAdapters::AbstractAdapter
|
@@ -5,8 +5,8 @@ def load_recaptcha_config setting
|
|
5
5
|
setting = "recaptcha_#{setting}".to_sym
|
6
6
|
Cardio.config.send(
|
7
7
|
"#{setting}=", load_recaptcha_card_config(setting) || # card content
|
8
|
-
|
9
|
-
|
8
|
+
Cardio.config.send(setting) || # application.rb
|
9
|
+
default_setting(setting)
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
@@ -26,18 +26,20 @@ def load_recaptcha_card_config setting
|
|
26
26
|
card && card.db_content.present? && card.db_content
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
29
|
+
ActiveSupport.on_load :after_card do
|
30
|
+
Recaptcha.configure do |config|
|
31
|
+
# the seed task runs initializers so we have to check
|
32
|
+
# if the cards table is ready before we use it here
|
33
|
+
CONFIG_OPTIONS =
|
34
|
+
{
|
35
|
+
public_key: :site_key,
|
36
|
+
private_key: :secret_key,
|
37
|
+
proxy: :proxy
|
38
|
+
}
|
39
|
+
if card_table_ready?
|
40
|
+
CONFIG_OPTIONS.each do |codename, setting|
|
41
|
+
config.send "#{setting}=", load_recaptcha_config(codename)
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
data/lib/card.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require "carrierwave"
|
3
2
|
|
4
3
|
Object.const_remove_if_defined :Card
|
4
|
+
ActiveSupport.run_load_hooks(:before_card, self)
|
5
5
|
# ActiveSupport::Dependencies.loaded.clear
|
6
6
|
|
7
7
|
# Cards are wiki-inspired building blocks.
|
@@ -136,7 +136,7 @@ class Card < ApplicationRecord
|
|
136
136
|
:update_referers, # wrong mechanism for this
|
137
137
|
:update_all_users, # if the above is wrong then this one too
|
138
138
|
:silent_change, # and this probably too
|
139
|
-
:remove_rule_stash,
|
139
|
+
# :remove_rule_stash,
|
140
140
|
:last_action_id_before_edit,
|
141
141
|
:only_storage_phase, # used to save subcards
|
142
142
|
:changed_attributes
|
@@ -174,6 +174,7 @@ class Card < ApplicationRecord
|
|
174
174
|
after_commit :integration_phase, unless: -> { only_storage_phase? }
|
175
175
|
# after_rollback :clean_up, unless: -> { only_storage_phase? }
|
176
176
|
|
177
|
-
extend CarrierWave::Mount
|
178
177
|
ActiveSupport.run_load_hooks(:card, self)
|
179
178
|
end
|
179
|
+
|
180
|
+
ActiveSupport.run_load_hooks(:after_card, self)
|
@@ -49,9 +49,7 @@ class Card
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def nest_content_from_subcard_params nest_name
|
52
|
-
|
53
|
-
return unless (nestcard_params = subcard_params[nest_name])
|
54
|
-
nestcard_params["content"]
|
52
|
+
params.dig "subcards", nest_name, "content"
|
55
53
|
end
|
56
54
|
end
|
57
55
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "card/migration"
|
3
|
+
|
4
|
+
class Card
|
5
|
+
class Migration
|
6
|
+
# Inherit from this migration class to make database table changes
|
7
|
+
# in your deck
|
8
|
+
class DeckStructure < Migration
|
9
|
+
@type = :deck
|
10
|
+
|
11
|
+
def contentedly
|
12
|
+
Cardio.schema_mode :deck do
|
13
|
+
yield
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/card/query/clause.rb
CHANGED
@@ -7,12 +7,11 @@ module Card::Query::Clause
|
|
7
7
|
txt =~ /[^\w\*\(\)\s\.\,]/ ? raise("WQL contains disallowed characters: #{txt}") : txt
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def quote v
|
11
|
+
connection.quote(v)
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
14
|
+
def connection
|
15
|
+
@connection ||= ActiveRecord::Base.connection
|
16
|
+
end
|
18
17
|
end
|
@@ -61,11 +61,15 @@ class Card
|
|
61
61
|
case val
|
62
62
|
when Integer, Float, Symbol, Hash then val
|
63
63
|
when String then normalize_string_value val
|
64
|
-
when Array then val
|
64
|
+
when Array then normalize_array_value val
|
65
65
|
else raise Card::Error::BadQuery, "unknown WQL value type: #{val.class}"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def normalize_array_value val
|
70
|
+
val.map { |v| normalize_value v }
|
71
|
+
end
|
72
|
+
|
69
73
|
def normalize_string_value val
|
70
74
|
case val.to_s
|
71
75
|
when /^\$(\w+)$/ # replace from @vars
|
data/lib/card/query/value.rb
CHANGED
@@ -2,6 +2,7 @@ class Card
|
|
2
2
|
class Query
|
3
3
|
class Value
|
4
4
|
include Clause
|
5
|
+
SQL_FIELD = { name: "key", content: "db_content" }.freeze
|
5
6
|
|
6
7
|
attr_reader :query, :operator, :value
|
7
8
|
|
@@ -14,11 +15,16 @@ class Card
|
|
14
15
|
def parse_value rawvalue
|
15
16
|
case rawvalue
|
16
17
|
when String, Integer then ["=", rawvalue]
|
17
|
-
when Array then
|
18
|
+
when Array then parse_array_value rawvalue
|
18
19
|
else raise("Invalid Condition Clause #{rawvalue}.inspect}")
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
23
|
+
def parse_array_value array
|
24
|
+
operator = operator?(array.first) ? array.shift : :in
|
25
|
+
[operator, array]
|
26
|
+
end
|
27
|
+
|
22
28
|
def canonicalize_operator
|
23
29
|
unless (target = OPERATORS[@operator.to_s])
|
24
30
|
raise Card::Error::BadQuery, "Invalid Operator #{@operator}"
|
@@ -26,6 +32,10 @@ class Card
|
|
26
32
|
@operator = target
|
27
33
|
end
|
28
34
|
|
35
|
+
def operator? key
|
36
|
+
OPERATORS.key? key.to_s
|
37
|
+
end
|
38
|
+
|
29
39
|
def sqlize v
|
30
40
|
case v
|
31
41
|
when Query then v.to_sql
|
@@ -35,27 +45,27 @@ class Card
|
|
35
45
|
end
|
36
46
|
|
37
47
|
def to_sql field
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
when "content"
|
46
|
-
["#{table}.db_content", v]
|
47
|
-
else
|
48
|
-
["#{table}.#{safe_sql field}", v]
|
49
|
-
end
|
50
|
-
|
51
|
-
v = v[0] if Array === v && v.length == 1 && op != "in"
|
52
|
-
if op == "~"
|
53
|
-
cxn, v = match_prep(v)
|
54
|
-
%(#{field} #{cxn.match(sqlize(v))})
|
48
|
+
value = value_sql field, @value
|
49
|
+
"#{field_sql field} #{operational_sql value}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def operational_sql value
|
53
|
+
if @operator == "~"
|
54
|
+
connection.match value
|
55
55
|
else
|
56
|
-
"#{
|
56
|
+
"#{@operator} #{value}"
|
57
57
|
end
|
58
58
|
end
|
59
|
+
|
60
|
+
def field_sql field
|
61
|
+
db_field = SQL_FIELD[field.to_sym] || safe_sql(field.to_s)
|
62
|
+
"#{@query.table_alias}.#{db_field}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def value_sql field, value
|
66
|
+
value = [value].flatten.map(&:to_name).map(&:key) if field.to_sym == :name
|
67
|
+
sqlize value
|
68
|
+
end
|
59
69
|
end
|
60
70
|
end
|
61
71
|
end
|
data/lib/card/set/event.rb
CHANGED
@@ -12,13 +12,7 @@ class Card
|
|
12
12
|
include DelayedEvent
|
13
13
|
|
14
14
|
def event event, stage_or_opts={}, opts={}, &final
|
15
|
-
|
16
|
-
opts[:in] = stage_or_opts
|
17
|
-
else
|
18
|
-
opts = stage_or_opts
|
19
|
-
end
|
20
|
-
process_stage_opts opts
|
21
|
-
|
15
|
+
opts = event_opts stage_or_opts, opts
|
22
16
|
Card.define_callbacks event
|
23
17
|
define_event event, opts, &final
|
24
18
|
set_event_callbacks event, opts
|
@@ -26,27 +20,34 @@ class Card
|
|
26
20
|
|
27
21
|
private
|
28
22
|
|
29
|
-
|
30
|
-
final_method_name = "#{event}_without_callbacks" # should be private?
|
31
|
-
class_eval do
|
32
|
-
define_method final_method_name, &final
|
33
|
-
end
|
23
|
+
# EVENT OPTS
|
34
24
|
|
35
|
-
|
36
|
-
|
25
|
+
def event_opts stage_or_opts, opts
|
26
|
+
opts = normalize_opts stage_or_opts, opts
|
27
|
+
process_stage_opts opts
|
28
|
+
process_action_opts opts
|
29
|
+
opts
|
30
|
+
end
|
31
|
+
|
32
|
+
def normalize_opts stage_or_opts, opts
|
33
|
+
if stage_or_opts.is_a? Symbol
|
34
|
+
opts[:in] = stage_or_opts
|
37
35
|
else
|
38
|
-
|
36
|
+
opts = stage_or_opts
|
39
37
|
end
|
38
|
+
opts
|
39
|
+
end
|
40
|
+
|
41
|
+
def process_action_opts opts
|
42
|
+
opts[:on] = [:create, :update] if opts[:on] == :save
|
40
43
|
end
|
41
44
|
|
42
45
|
def process_stage_opts opts
|
43
46
|
if opts[:after] || opts[:before]
|
44
47
|
# ignore :in options
|
45
|
-
elsif opts
|
46
|
-
opts[:after] =
|
47
|
-
callback_name opts.delete(:in), opts.delete(:after_subcards)
|
48
|
+
elsif (in_opt = opts.delete :in)
|
49
|
+
opts[:after] = callback_name in_opt, opts.delete(:after_subcards)
|
48
50
|
end
|
49
|
-
opts[:on] = [:create, :update] if opts[:on] == :save
|
50
51
|
end
|
51
52
|
|
52
53
|
def callback_name stage, after_subcards=false
|
@@ -54,27 +55,50 @@ class Card
|
|
54
55
|
name.to_sym
|
55
56
|
end
|
56
57
|
|
57
|
-
|
58
|
+
# EVENT DEFINITION
|
59
|
+
|
60
|
+
def define_event event, opts, &final
|
61
|
+
simple_method_name = "#{event}_without_callbacks"
|
62
|
+
define_simple_method event, simple_method_name, &final
|
63
|
+
define_event_method event, simple_method_name, opts
|
64
|
+
end
|
65
|
+
|
66
|
+
def define_simple_method _event, method_name, &method
|
67
|
+
class_eval do
|
68
|
+
define_method method_name, &method
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def define_event_method event, method_name, opts
|
73
|
+
event_type = with_delay?(opts) ? :delayed : :standard
|
74
|
+
send "define_#{event_type}_event_method", event, method_name
|
75
|
+
end
|
76
|
+
|
77
|
+
def define_standard_event_method event, method_name
|
58
78
|
class_eval do
|
59
79
|
define_method event do
|
60
80
|
log_event_call event
|
61
81
|
run_callbacks event do
|
62
|
-
send
|
82
|
+
send method_name
|
63
83
|
end
|
64
84
|
end
|
65
85
|
end
|
66
86
|
end
|
67
87
|
|
88
|
+
# EVENT CALLBACKS
|
89
|
+
|
68
90
|
def set_event_callbacks event, opts
|
69
91
|
opts[:set] ||= self
|
70
92
|
[:before, :after, :around].each do |kind|
|
71
|
-
next unless (object_method = opts.delete
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
93
|
+
next unless (object_method = opts.delete kind)
|
94
|
+
set_event_callback object_method, kind, event, opts
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def set_event_callback object_method, kind, event, opts
|
99
|
+
Card.class_eval do
|
100
|
+
set_callback object_method, kind, event,
|
101
|
+
prepend: true, if: proc { |c| c.event_applies?(opts) }
|
78
102
|
end
|
79
103
|
end
|
80
104
|
end
|
@@ -11,10 +11,10 @@ class Card
|
|
11
11
|
DELAY_STAGES.include?(opts[:after]) || DELAY_STAGES.include?(opts[:before])
|
12
12
|
end
|
13
13
|
|
14
|
-
def define_delayed_event_method event,
|
14
|
+
def define_delayed_event_method event, simple_method_name
|
15
15
|
delaying_method = "#{event}_with_delay"
|
16
|
-
define_event_delaying_method event, delaying_method,
|
17
|
-
|
16
|
+
define_event_delaying_method event, delaying_method, simple_method_name
|
17
|
+
define_standard_event_method event, delaying_method
|
18
18
|
end
|
19
19
|
|
20
20
|
# creates an ActiveJob.
|
@@ -44,7 +44,7 @@ class Card
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
47
|
+
def haml_template_path view=nil, source=nil
|
48
48
|
each_template_path(source) do |template_dir, source_dir|
|
49
49
|
path = try_haml_template_path template_dir, view, source_dir
|
50
50
|
return path if path
|
data/lib/card/tasks/card.rake
CHANGED
@@ -78,6 +78,13 @@ namespace :card do
|
|
78
78
|
Rake::Task["card:migrate:stamp"].invoke :core_cards
|
79
79
|
end
|
80
80
|
|
81
|
+
puts "migrating deck structure"
|
82
|
+
Rake::Task["card:migrate:deck_structure"].execute
|
83
|
+
if stamp
|
84
|
+
Rake::Task["card:migrate:stamp"].reenable
|
85
|
+
Rake::Task["card:migrate:stamp"].invoke :core_cards
|
86
|
+
end
|
87
|
+
|
81
88
|
puts "migrating deck cards"
|
82
89
|
# not invoke because we don't want to reload environment
|
83
90
|
Rake::Task["card:migrate:deck_cards"].execute
|
@@ -19,6 +19,18 @@ def prepare_migration
|
|
19
19
|
# structures are loaded before schema_mode is set
|
20
20
|
end
|
21
21
|
|
22
|
+
# @param mod [Boolean] if true reset column information for models defined in
|
23
|
+
# in mods in the deck
|
24
|
+
def reset_column_information mod=false
|
25
|
+
Rails.application.eager_load!
|
26
|
+
load_mod_lib if mod
|
27
|
+
ApplicationRecord.descendants.each(&:reset_column_information)
|
28
|
+
end
|
29
|
+
|
30
|
+
def load_mod_lib
|
31
|
+
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).each { |x| require_dependency x }
|
32
|
+
end
|
33
|
+
|
22
34
|
namespace :card do
|
23
35
|
namespace :migrate do
|
24
36
|
desc "migrate cards"
|
@@ -32,6 +44,7 @@ namespace :card do
|
|
32
44
|
ActiveRecord::Migrator.migrate paths, version
|
33
45
|
Rake::Task["db:_dump"].invoke # write schema.rb
|
34
46
|
end
|
47
|
+
reset_column_information
|
35
48
|
end
|
36
49
|
|
37
50
|
desc "migrate core cards"
|
@@ -40,6 +53,22 @@ namespace :card do
|
|
40
53
|
run_card_migration :core_cards
|
41
54
|
end
|
42
55
|
|
56
|
+
desc "migrate deck structure"
|
57
|
+
task deck_structure: :environment do
|
58
|
+
migrate_deck_structure
|
59
|
+
end
|
60
|
+
|
61
|
+
def migrate_deck_structure
|
62
|
+
require "card/migration/deck_structure"
|
63
|
+
ENV["SCHEMA"] = "#{Cardio.root}/db/schema.rb"
|
64
|
+
Cardio.schema_mode(:deck) do |paths|
|
65
|
+
ActiveRecord::Migrator.migrations_paths = paths
|
66
|
+
ActiveRecord::Migrator.migrate paths, version
|
67
|
+
Rake::Task["db:_dump"].invoke # write schema.rb
|
68
|
+
end
|
69
|
+
reset_column_information true
|
70
|
+
end
|
71
|
+
|
43
72
|
desc "migrate deck cards"
|
44
73
|
task deck_cards: :environment do
|
45
74
|
require "card/migration"
|