card 1.103.2 → 1.104.1
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/environments/development.rb +4 -2
- data/config/environments/production.rb +9 -9
- data/config/environments/test.rb +1 -1
- data/config/initializers/01_core_extensions/array.rb +4 -1
- data/config/initializers/01_core_extensions/object.rb +1 -1
- data/config/initializers/02_patches/active_record.rb +16 -17
- data/config/locales/de.yml +8 -564
- data/config/locales/es.yml +2 -3
- data/db/migrate/20110511221913_require_earlier_migrations.rb +1 -1
- data/db/migrate/20120105203350_require_1_8_migrations.rb +1 -1
- data/db/migrate/20121111025347_require_1_10_migrations.rb +1 -1
- data/db/migrate/20211128040849_virtuals_updated_at.rb +11 -0
- data/db/migrate_core_cards/20130411191151_renaming_for_menu.rb +0 -1
- data/db/migrate_core_cards/20140317035504_account_requests_to_signups.rb +0 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +0 -2
- data/db/migrate_core_cards/20190417142612_reorganize_scripts_2.rb +1 -3
- data/db/migrate_core_cards/20190502130029_add_shark_and_help_desk_role.rb +1 -2
- data/db/migrate_core_cards/20190710090209_homepage_tweaks.rb +3 -7
- data/db/migrate_core_cards/20190823220018_cleanup_for_decko_1_0.rb +2 -4
- data/db/migrate_core_cards/20190902193208_input_type.rb +3 -8
- data/db/migrate_core_cards/20190904174403_token_upgrade.rb +1 -1
- data/db/migrate_core_cards/data/1.12_stylesheets/traditional.scss +1 -2
- data/db/schema.rb +19 -16
- data/db/seed/new/card_actions.yml +2615 -3383
- data/db/seed/new/card_acts.yml +3 -3
- data/db/seed/new/card_references.yml +1588 -1707
- data/db/seed/new/cards.yml +5450 -8416
- data/db/seed/new/schema_migrations.yml +2 -0
- data/db/seed/new/schema_migrations_core_cards.yml +8 -0
- data/db/seed/test/fixtures/card_actions.yml +4304 -5144
- data/db/seed/test/fixtures/card_acts.yml +780 -840
- data/db/seed/test/fixtures/card_changes.yml +110 -110
- data/db/seed/test/fixtures/card_references.yml +2908 -2992
- data/db/seed/test/fixtures/cards.yml +8775 -11955
- data/db/seed/test/fixtures/schema_migrations.yml +2 -0
- data/db/seed/test/fixtures/schema_migrations_core_cards.yml +8 -0
- data/db/test_seed.rb +2 -5
- data/db/version.txt +1 -1
- data/db/version_core_cards.txt +1 -1
- data/lib/card/auth/current.rb +1 -1
- data/lib/card/auth/permissions.rb +37 -35
- data/lib/card/content/all.rb +3 -3
- data/lib/card/content/chunk.rb +1 -1
- data/lib/card/content/diff/summary.rb +14 -18
- data/lib/card/content.rb +9 -1
- data/lib/card/director/act_direction.rb +6 -6
- data/lib/card/director/card_methods.rb +0 -1
- data/lib/card/director/phases.rb +1 -0
- data/lib/card/director/stages.rb +2 -0
- data/lib/card/director.rb +1 -0
- data/lib/card/fetch/all.rb +3 -3
- data/lib/card/fetch/card_class.rb +5 -11
- data/lib/card/fetch/results.rb +8 -8
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/migration_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/ruby_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card/source_file.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/abstract_file_card.rb +0 -5
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/haml_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/output_helper.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/script_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator → file_card_creator}/style_card.rb +0 -0
- data/lib/card/{tasks/card/file_card_creator.rb → file_card_creator.rb} +0 -5
- data/lib/card/format/content.rb +5 -7
- data/lib/card/format/error.rb +2 -2
- data/lib/card/format/render.rb +10 -10
- data/lib/card/format.rb +3 -8
- data/lib/card/lexicon.rb +30 -7
- data/lib/card/model/save_helper/save_arguments.rb +2 -2
- data/lib/card/model/save_helper.rb +3 -3
- data/lib/card/name/all/descendants.rb +9 -7
- data/lib/card/name/all/parts.rb +1 -1
- data/lib/card/name/all.rb +4 -3
- data/lib/card/name/card_class.rb +2 -1
- data/lib/card/name/fields_and_traits.rb +6 -30
- data/lib/card/name/name_variants.rb +5 -1
- data/lib/card/name.rb +6 -14
- data/lib/card/query/abstract_query/tie.rb +2 -3
- data/lib/card/query/card_query/normalization.rb +1 -1
- data/lib/card/query/sql_statement/order.rb +5 -6
- data/lib/card/query/value.rb +10 -7
- data/lib/card/reference/all.rb +9 -7
- data/lib/card/reference.rb +36 -41
- data/lib/card/rule/all.rb +3 -3
- data/lib/card/set/advanced_api.rb +5 -0
- data/lib/card/set/card_methods.rb +13 -0
- data/lib/card/set/event/delayed_event.rb +8 -1
- data/lib/card/set/event/skip_and_trigger.rb +8 -0
- data/lib/card/set/event.rb +1 -0
- data/lib/card/set/format/abstract_format/wrapper.rb +1 -1
- data/lib/card/set/format/abstract_format.rb +2 -1
- data/lib/card/set/format.rb +2 -3
- data/lib/card/set/helpers.rb +68 -0
- data/lib/card/set/inheritance.rb +1 -1
- data/lib/card/set/pattern/all.rb +20 -10
- data/lib/card/set/pattern/base.rb +12 -18
- data/lib/card/set/pattern/class_methods.rb +13 -13
- data/lib/card/set/pattern.rb +46 -24
- data/lib/card/set/registrar.rb +8 -2
- data/lib/card/set/trait.rb +16 -1
- data/lib/card/set/type.rb +3 -0
- data/lib/card/set.rb +14 -7
- data/lib/card/subcards/add.rb +1 -3
- data/lib/card/subcards/all.rb +30 -56
- data/lib/card/view/classy.rb +15 -27
- data/lib/card/view/options/voo_api.rb +3 -1
- data/lib/card/view/options.rb +7 -5
- data/lib/card/view/permission.rb +4 -11
- data/lib/card/view.rb +1 -0
- data/lib/card.rb +9 -11
- data/lib/cardio/cli.rb +1 -0
- data/lib/cardio/commands/custom.rb +60 -0
- data/lib/cardio/commands/rake_command/parser.rb +49 -48
- data/lib/cardio/commands/rake_command.rb +17 -15
- data/lib/cardio/commands/rspec_command.rb +2 -0
- data/lib/cardio/commands.rb +69 -69
- data/lib/cardio/generators/deck_helper.rb +0 -4
- data/lib/cardio/generators.rb +56 -3
- data/lib/cardio/migration/deck.rb +0 -0
- data/lib/cardio/migration/deck_structure.rb +2 -0
- data/lib/cardio/migration/import/import_data/card_content.rb +1 -1
- data/lib/cardio/migration/import.rb +2 -2
- data/lib/cardio/migration.rb +26 -2
- data/lib/cardio/mod/class_methods.rb +112 -0
- data/lib/cardio/mod/dirs.rb +15 -11
- data/lib/cardio/mod/eat/edibles.rb +92 -0
- data/lib/cardio/mod/eat.rb +81 -0
- data/lib/cardio/mod/load_strategy/set_tmp_files.rb +10 -4
- data/lib/cardio/mod/load_strategy/tmp_files.rb +1 -1
- data/lib/cardio/mod/load_strategy.rb +3 -4
- data/lib/cardio/mod/loader/set_loader.rb +13 -13
- data/lib/cardio/mod/loader.rb +1 -1
- data/lib/cardio/mod/modfile_api.rb +5 -0
- data/lib/cardio/mod/poop.rb +135 -0
- data/lib/cardio/mod.rb +20 -80
- data/lib/cardio/railtie.rb +24 -6
- data/lib/cardio/schema.rb +11 -10
- data/lib/cardio/version.rb +35 -0
- data/lib/cardio.rb +4 -0
- data/lib/generators/deck/deck_generator.rb +3 -2
- data/lib/generators/deck/templates/Gemfile.erb +1 -5
- data/lib/generators/deck/templates/Rakefile.erb +6 -2
- data/lib/generators/deck/templates/rspec.erb +1 -1
- data/lib/generators/deck/templates/simplecov.rb.erb +7 -11
- data/lib/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb +0 -1
- data/lib/generators/mod/USAGE +1 -0
- data/lib/{card/tasks → tasks}/card/create.rake +0 -0
- data/lib/{card/tasks → tasks}/card/migrate.rake +41 -1
- data/lib/{card/tasks → tasks}/card/mod.rake +15 -8
- data/lib/tasks/card.rake +65 -0
- data/mod/admin/locales/de.yml +4 -0
- data/mod/admin/set/all/admin.rb +16 -0
- data/mod/admin/set/self/admin.rb +12 -14
- data/mod/admin/set/self/admin_info.rb +2 -5
- data/mod/core/data/production.yml +7 -0
- data/mod/core/data/test.yml +30 -0
- data/mod/core/locales/de.yml +28 -0
- data/mod/core/locales/en.yml +4 -5
- data/mod/core/set/all/assign_attributes.rb +1 -33
- data/mod/core/set/all/content.rb +3 -1
- data/mod/core/set/all/initialize.rb +1 -4
- data/mod/core/set/all/name_events.rb +3 -18
- data/mod/core/set/all/reference_events.rb +32 -36
- data/mod/core/set/all/subcards.rb +6 -2
- data/mod/core/set/all/trash.rb +4 -6
- data/mod/core/set/all/type.rb +67 -18
- data/mod/core/set/self/version.rb +1 -1
- data/mod/core/spec/set/all/name_events_spec.rb +10 -10
- data/mod/core/spec/set/all/trash_spec.rb +1 -1
- data/mod/core/spec/set/self/trash_spec.rb +1 -1
- data/mod/standard/{file → data/files}/favicon/image-icon.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-large.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-medium.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-original.png +0 -0
- data/mod/standard/{file → data/files}/favicon/image-small.png +0 -0
- data/mod/standard/{file → data/files}/logo/image-original.svg +0 -0
- metadata +52 -42
- data/db/migrate_core_cards/20150605115802_add_performance_log_card.rb +0 -7
- data/lib/card/set/basket.rb +0 -59
- data/lib/card/set/code_nest.rb +0 -15
- data/lib/card/tasks/card/asset.rake +0 -22
- data/lib/card/tasks/card.rake +0 -105
- data/lib/card/version.rb +0 -11
- data/lib/cardio/commands/USAGE +0 -28
- data/lib/cardio/generators/class_methods.rb +0 -35
- data/mod/core/spec/set/all/clean_me_spec.rb +0 -258
- data/mod/core/spec/set/all/export_spec.rb +0 -71
- data/tmpsets/set_pattern/100-all.rb +0 -22
- data/tmpsets/set_pattern/101-all_plus.rb +0 -24
- data/tmpsets/set_pattern/102-type.rb +0 -40
- data/tmpsets/set_pattern/103-star.rb +0 -26
- data/tmpsets/set_pattern/104-rstar.rb +0 -28
- data/tmpsets/set_pattern/105-rule.rb +0 -28
- data/tmpsets/set_pattern/106-right.rb +0 -35
- data/tmpsets/set_pattern/107-type_plus_right.rb +0 -43
- data/tmpsets/set_pattern/108-self.rb +0 -34
data/lib/cardio/mod.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "cardio/mod/class_methods"
|
2
|
+
|
1
3
|
module Cardio
|
2
4
|
# A Card Mod (short for "module" or "modification") is a discrete piece of Decko
|
3
5
|
# functionality. Mods are how the Decko community develops and shares code.
|
@@ -60,11 +62,13 @@ module Cardio
|
|
60
62
|
# or types of sets.
|
61
63
|
# - **file** for fixed initial card content
|
62
64
|
class Mod
|
65
|
+
extend ClassMethods
|
66
|
+
|
63
67
|
attr_reader :name, :path, :index
|
64
68
|
|
65
69
|
def initialize name, path, index
|
66
70
|
@name = Mod.normalize_name name
|
67
|
-
@path = path
|
71
|
+
@path = required_path path
|
68
72
|
@index = index
|
69
73
|
end
|
70
74
|
|
@@ -76,30 +80,34 @@ module Cardio
|
|
76
80
|
"mod_#{name}"
|
77
81
|
end
|
78
82
|
|
83
|
+
def subpath *parts
|
84
|
+
path = File.join [@path] + parts
|
85
|
+
path if File.exist? path
|
86
|
+
end
|
87
|
+
|
79
88
|
def tmp_dir type
|
80
89
|
File.join Cardio.paths["tmp/#{type}"].first,
|
81
90
|
"mod#{'%03d' % (@index + 1)}-#{@name}"
|
82
91
|
end
|
83
92
|
|
84
|
-
def
|
85
|
-
File.join @path, "public"
|
86
|
-
end
|
87
|
-
|
88
|
-
def assets_path
|
89
|
-
File.join @path, "assets"
|
90
|
-
end
|
91
|
-
|
92
|
-
def ensure_mod_installed
|
93
|
+
def ensure
|
93
94
|
Card::Auth.as_bot do
|
94
|
-
card =
|
95
|
+
card = ensure_card
|
95
96
|
card.ensure_mod_script_card
|
96
97
|
card.ensure_mod_style_card
|
98
|
+
Card::Cache.reset_all
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
100
102
|
private
|
101
103
|
|
102
|
-
def
|
104
|
+
def required_path path
|
105
|
+
return path if File.exist? path
|
106
|
+
|
107
|
+
raise Card::Error::NotFound, "mod not found: #{@name}"
|
108
|
+
end
|
109
|
+
|
110
|
+
def ensure_card
|
103
111
|
if Card::Codename.exists? codename
|
104
112
|
card = Card.fetch codename.to_sym
|
105
113
|
card.update type: :mod unless card.type_code == :mod
|
@@ -108,73 +116,5 @@ module Cardio
|
|
108
116
|
Card.create name: mod_card_name, type: :mod, codename: codename
|
109
117
|
end
|
110
118
|
end
|
111
|
-
|
112
|
-
class << self
|
113
|
-
def load
|
114
|
-
return if ENV["CARD_MODS"] == "none"
|
115
|
-
|
116
|
-
if Card.take
|
117
|
-
Loader.load_mods
|
118
|
-
else
|
119
|
-
Rails.logger.warn "empty database"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
# @return an array of Rails::Path objects
|
124
|
-
def dirs
|
125
|
-
@dirs ||= Mod::Dirs.new(Cardio.paths["mod"].existent)
|
126
|
-
end
|
127
|
-
|
128
|
-
def dependencies name, nickname=true
|
129
|
-
return unless (spec = gem_spec name, nickname)
|
130
|
-
|
131
|
-
deps = spec&.dependencies || []
|
132
|
-
dep_names = deps.map { |dep| dependencies dep.name, false }
|
133
|
-
(dep_names << spec).flatten.compact.uniq
|
134
|
-
end
|
135
|
-
|
136
|
-
def each_path &block
|
137
|
-
each_simple_path(&block)
|
138
|
-
each_gem_path(&block)
|
139
|
-
end
|
140
|
-
|
141
|
-
# @return [Hash] in the form{ modname(String) => Gem::Specification }
|
142
|
-
def gem_specs
|
143
|
-
Bundler.definition.specs.each_with_object({}) do |gem_spec, h|
|
144
|
-
h[gem_spec.name] = gem_spec if gem_spec? gem_spec
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def normalize_name name
|
149
|
-
name.to_s.sub(/^card-mod-/, "")
|
150
|
-
end
|
151
|
-
|
152
|
-
private
|
153
|
-
|
154
|
-
def gem_spec name, nickname=true
|
155
|
-
name = "card-mod-#{name}" if nickname && !name.match?(/^card-mod/)
|
156
|
-
spec = Gem::Specification.stubs_for(name)&.first
|
157
|
-
gem_spec?(spec) ? spec : nil
|
158
|
-
end
|
159
|
-
|
160
|
-
def each_simple_path &block
|
161
|
-
Cardio.paths["mod"].each do |mods_path|
|
162
|
-
Dir.glob("#{mods_path}/*").each(&block)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def each_gem_path
|
167
|
-
gem_specs.each_value do |spec|
|
168
|
-
yield spec.full_gem_path
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
# @return [True/False]
|
173
|
-
def gem_spec? spec
|
174
|
-
return unless spec
|
175
|
-
|
176
|
-
spec.name.match?(/^card-mod-/) || spec.metadata["card-mod"].present?
|
177
|
-
end
|
178
|
-
end
|
179
119
|
end
|
180
120
|
end
|
data/lib/cardio/railtie.rb
CHANGED
@@ -3,7 +3,6 @@ module Cardio
|
|
3
3
|
class Railtie < Rails::Railtie
|
4
4
|
# if you disable inline styles tinymce's formatting options stop working
|
5
5
|
config.allow_inline_styles = true
|
6
|
-
config.delaying = nil
|
7
6
|
config.token_expiry = 2.days
|
8
7
|
|
9
8
|
config.recaptcha_public_key = nil # deprecated; use recaptcha_site_key instead
|
@@ -15,6 +14,8 @@ module Cardio
|
|
15
14
|
config.recaptcha_minimum_score = 0.5
|
16
15
|
|
17
16
|
config.google_analytics_key = nil
|
17
|
+
config.google_analytics_tracker_key = nil
|
18
|
+
config.google_analytics_four_key = nil
|
18
19
|
|
19
20
|
config.override_host = nil
|
20
21
|
config.override_protocol = nil
|
@@ -31,6 +32,9 @@ module Cardio
|
|
31
32
|
config.closed_search_limit = 10
|
32
33
|
config.paging_limit = 20
|
33
34
|
|
35
|
+
config.delaying = false
|
36
|
+
config.active_job.queue_adapter = :delayed_job
|
37
|
+
|
34
38
|
config.non_createable_types = %w[
|
35
39
|
signup
|
36
40
|
setting
|
@@ -38,6 +42,14 @@ module Cardio
|
|
38
42
|
session
|
39
43
|
bootswatch_skin
|
40
44
|
customized_bootswatch_skin
|
45
|
+
local_folder_group
|
46
|
+
local_manifest_group
|
47
|
+
local_script_folder_group
|
48
|
+
local_script_manifest_group
|
49
|
+
local_style_folder_group
|
50
|
+
local_style_manifest_group
|
51
|
+
remote_manifest_group
|
52
|
+
mod
|
41
53
|
]
|
42
54
|
|
43
55
|
config.view_cache = false
|
@@ -47,7 +59,7 @@ module Cardio
|
|
47
59
|
config.encoding = "utf-8"
|
48
60
|
config.request_logger = false
|
49
61
|
config.performance_logger = false
|
50
|
-
config.sql_comments =
|
62
|
+
config.sql_comments = false
|
51
63
|
|
52
64
|
config.file_storage = :local
|
53
65
|
config.file_buckets = {}
|
@@ -58,8 +70,8 @@ module Cardio
|
|
58
70
|
|
59
71
|
config.persistent_cache = true
|
60
72
|
config.prepopulate_cache = false
|
61
|
-
config.
|
62
|
-
config.
|
73
|
+
config.asset_refresh = :cautious
|
74
|
+
config.compress_assets = true
|
63
75
|
|
64
76
|
config.allow_irreversible_admin_tasks = false
|
65
77
|
config.raise_all_rendering_errors = false
|
@@ -83,16 +95,18 @@ module Cardio
|
|
83
95
|
|
84
96
|
c.paths.tap do |p|
|
85
97
|
p["config/environments"].unshift "#{card_root}/config/environments"
|
86
|
-
|
87
98
|
p["config/initializers"] << "#{card_root}/config/initializers"
|
88
99
|
p.add "late/initializers", glob: "**/*.rb"
|
89
100
|
|
90
|
-
p["lib/tasks"] << "#{card_root}/lib/
|
101
|
+
p["lib/tasks"] << "#{card_root}/lib/tasks"
|
91
102
|
|
92
103
|
p.add "mod", with: "#{card_root}/mod"
|
93
104
|
p["mod"] << "mod"
|
94
105
|
p.add "files"
|
95
106
|
|
107
|
+
p.add "lib/graph_q_l/types/query.rb"
|
108
|
+
p.add "mod-data"
|
109
|
+
|
96
110
|
p.add "db", with: "#{card_root}/db"
|
97
111
|
p.add "db/seeds.rb", with: "#{card_root}/db/seeds.rb"
|
98
112
|
p.add "db/migrate", with: "#{card_root}/db/migrate"
|
@@ -105,9 +119,13 @@ module Cardio
|
|
105
119
|
c.autoload_paths += Dir["#{mod_path}/lib"]
|
106
120
|
c.watchable_dirs["#{mod_path}/set"] = %i[rb haml]
|
107
121
|
|
122
|
+
p["lib/graph_q_l/types/query.rb"] <<
|
123
|
+
"#{mod_path}/lib/graph_q_l/types/query.rb"
|
108
124
|
p["config/initializers"] << "#{mod_path}/init/early"
|
109
125
|
p["late/initializers"] << "#{mod_path}/init/late"
|
110
126
|
p["config/locales"] << "#{mod_path}/locales"
|
127
|
+
p["lib/tasks"] << "#{mod_path}/lib/tasks"
|
128
|
+
p["mod-data"] << "#{mod_path}/data"
|
111
129
|
end
|
112
130
|
|
113
131
|
p["app/models"] = []
|
data/lib/cardio/schema.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Cardio
|
2
2
|
module Schema
|
3
3
|
class << self
|
4
|
-
def assume_migrated_upto_version type
|
5
|
-
mode type do |
|
6
|
-
|
4
|
+
def assume_migrated_upto_version type, version=nil
|
5
|
+
mode type do |_paths|
|
6
|
+
version ||= version type
|
7
|
+
ActiveRecord::Schema.assume_migrated_upto_version version
|
7
8
|
end
|
8
9
|
end
|
9
10
|
|
@@ -53,6 +54,13 @@ module Cardio
|
|
53
54
|
list.flatten
|
54
55
|
end
|
55
56
|
|
57
|
+
def migration_context type
|
58
|
+
with_suffix type do
|
59
|
+
yield ActiveRecord::MigrationContext.new(migration_paths(type),
|
60
|
+
ActiveRecord::SchemaMigration)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
56
64
|
private
|
57
65
|
|
58
66
|
def deck_migration? type
|
@@ -82,13 +90,6 @@ module Cardio
|
|
82
90
|
ActiveRecord::SchemaMigration.table_name = old_table_name
|
83
91
|
ActiveRecord::SchemaMigration.reset_column_information
|
84
92
|
end
|
85
|
-
|
86
|
-
def migration_context type
|
87
|
-
with_suffix type do
|
88
|
-
yield ActiveRecord::MigrationContext.new(migration_paths(type),
|
89
|
-
ActiveRecord::SchemaMigration)
|
90
|
-
end
|
91
|
-
end
|
92
93
|
end
|
93
94
|
end
|
94
95
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module Cardio
|
4
|
+
module Version
|
5
|
+
class << self
|
6
|
+
CARD_MINOR = { 0 => 90, 1 => 1000 }.freeze # can remove and hardcode after 1.0
|
7
|
+
|
8
|
+
def release
|
9
|
+
@version ||= File.read(File.expand_path("../../../card/VERSION", __dir__)).strip
|
10
|
+
end
|
11
|
+
|
12
|
+
def card_release
|
13
|
+
@card_release ||= [1, minor, point].compact.map(&:to_s).join "."
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def bits
|
19
|
+
release.split(".").map(&:to_i)
|
20
|
+
end
|
21
|
+
|
22
|
+
def major
|
23
|
+
bits[0]
|
24
|
+
end
|
25
|
+
|
26
|
+
def minor
|
27
|
+
CARD_MINOR[major] + bits[1]
|
28
|
+
end
|
29
|
+
|
30
|
+
def point
|
31
|
+
bits[2]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/cardio.rb
CHANGED
@@ -118,10 +118,11 @@ module Cardio
|
|
118
118
|
if options["interactive"]
|
119
119
|
Interactive.new(destination_root, (monkey? || platypus?)).run
|
120
120
|
else
|
121
|
+
prefix = "bundle exec " if options["platypus"]
|
121
122
|
puts "Now:
|
122
123
|
1. Run `cd #{File.basename(destination_root)}` to enter your new deck directory
|
123
|
-
2. Run
|
124
|
-
3. Run
|
124
|
+
2. Run `#{prefix}decko seed` to seed your database (see config/database.yml).
|
125
|
+
3. Run `#{prefix}decko server` to start your server"
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
@@ -30,7 +30,7 @@ gem "card-mod-defaults"<%= repo_path_constraint :mod %>
|
|
30
30
|
# BACKGROUND
|
31
31
|
# A background gem is needed to run tasks like sending notifications in a background
|
32
32
|
# process.
|
33
|
-
# See https://github.com/decko-commons/decko/tree/
|
33
|
+
# See https://github.com/decko-commons/decko/tree/main/card-mod-delayed_job
|
34
34
|
# for additional configuration details.
|
35
35
|
<%= "# " if shark? %>gem "card-mod-delayed_job"<%= repo_path_constraint :mod %>
|
36
36
|
|
@@ -50,7 +50,3 @@ gem "card-mod-defaults"<%= repo_path_constraint :mod %>
|
|
50
50
|
# This mod is strongly recommended for platypuses – coders working on the decko core
|
51
51
|
gem "card-mod-platypus"<%= repo_path_constraint :mod %>
|
52
52
|
<% end %>
|
53
|
-
|
54
|
-
# The following allows simple (non-gem) mods to specify gems via a Gemfile.
|
55
|
-
# You may need to alter this code if you move such mods to an unconventional location.
|
56
|
-
Dir.glob("mod/**/Gemfile").each { |gemfile| instance_eval File.read(gemfile) }
|
@@ -1,5 +1,9 @@
|
|
1
|
-
# Add your own tasks in files
|
2
|
-
#
|
1
|
+
# Add your own tasks in files ending in .rake a mod or deck's lib/tasks directory.
|
2
|
+
#
|
3
|
+
# Deck example: mydeck/lib/tasks/mytasks.rake
|
4
|
+
# Mod example mydecko/mod/mymod/lib/tasks/mytasks.rake
|
5
|
+
#
|
6
|
+
# Tasks in these files will automatically be available to Rake.
|
3
7
|
|
4
8
|
require File.expand_path("../config/application", __FILE__)
|
5
9
|
|
@@ -1,9 +1,11 @@
|
|
1
1
|
|
2
2
|
if ENV["<%= 'REPO_' if platypus? %>TMPSETS"] && ENV["COVERAGE"] != "false"
|
3
3
|
SimpleCov.start do
|
4
|
-
def
|
5
|
-
|
6
|
-
|
4
|
+
def add_mod_groups dir_pattern
|
5
|
+
Dir[dir_pattern].each do |path|
|
6
|
+
modname = File.basename path
|
7
|
+
add_group "Mod: #{modname}", %r{(mod/|mod\d{3}-)#{modname}}
|
8
|
+
end
|
7
9
|
end
|
8
10
|
<% if platypus? %>
|
9
11
|
root "<%= expanded_repo_path %>"
|
@@ -16,15 +18,9 @@ if ENV["<%= 'REPO_' if platypus? %>TMPSETS"] && ENV["COVERAGE"] != "false"
|
|
16
18
|
add_group "Cardname", "cardname"
|
17
19
|
add_group "Decko", "decko"
|
18
20
|
|
19
|
-
|
20
|
-
match = path.match %r{/card[-/]mod[-/](?<modname>.*)$}
|
21
|
-
add_mod_group match[:modname]
|
22
|
-
end
|
21
|
+
add_mod_groups "#{root}/{card/,}/mod/*"
|
23
22
|
<% else %>
|
24
|
-
|
25
|
-
modname = path.gsub "mod/", ""
|
26
|
-
add_mod_group modname
|
27
|
-
end
|
23
|
+
add_mod_groups "mod/*"
|
28
24
|
<% end %>
|
29
25
|
add_filter "/spec/"
|
30
26
|
add_filter "/features/"
|
data/lib/generators/mod/USAGE
CHANGED
File without changes
|
@@ -19,10 +19,12 @@ end
|
|
19
19
|
# in mods in the deck
|
20
20
|
def reset_column_information mod=false
|
21
21
|
Rails.application.eager_load!
|
22
|
-
load_mod_lib if mod
|
22
|
+
load_mod_lib if mod && !ENV["NO_CARD_LOAD"]
|
23
23
|
Cardio::Record.descendants.each(&:reset_column_information)
|
24
24
|
end
|
25
25
|
|
26
|
+
# FIXME: too general
|
27
|
+
# intent is to find Record classes; this gets a lot more.
|
26
28
|
def load_mod_lib
|
27
29
|
Dir.glob(Cardio.root.join("mod/*/lib/*.rb")).sort.each { |x| require x }
|
28
30
|
end
|
@@ -33,6 +35,44 @@ def without_dumping
|
|
33
35
|
end
|
34
36
|
|
35
37
|
namespace :card do
|
38
|
+
desc "migrate structure and cards"
|
39
|
+
task migrate: :environment do
|
40
|
+
ENV["NO_RAILS_CACHE"] = "true"
|
41
|
+
ENV["SCHEMA"] ||= "#{Cardio.gem_root}/db/schema.rb"
|
42
|
+
|
43
|
+
stamp = ENV["STAMP_MIGRATIONS"]
|
44
|
+
|
45
|
+
puts "migrating structure"
|
46
|
+
Rake::Task["card:migrate:structure"].invoke
|
47
|
+
Rake::Task["card:migrate:stamp"].invoke :structure if stamp
|
48
|
+
|
49
|
+
puts "migrating deck structure"
|
50
|
+
Rake::Task["card:migrate:deck_structure"].execute
|
51
|
+
if stamp
|
52
|
+
Rake::Task["card:migrate:stamp"].reenable
|
53
|
+
Rake::Task["card:migrate:stamp"].invoke :core_cards
|
54
|
+
end
|
55
|
+
|
56
|
+
puts "migrating core cards"
|
57
|
+
Card::Cache.reset_all
|
58
|
+
# not invoke because we don't want to reload environment
|
59
|
+
Rake::Task["card:migrate:core_cards"].execute
|
60
|
+
if stamp
|
61
|
+
Rake::Task["card:migrate:stamp"].reenable
|
62
|
+
Rake::Task["card:migrate:stamp"].invoke :core_cards
|
63
|
+
end
|
64
|
+
|
65
|
+
puts "migrating deck cards"
|
66
|
+
# not invoke because we don't want to reload environment
|
67
|
+
Rake::Task["card:migrate:deck_cards"].execute
|
68
|
+
if stamp
|
69
|
+
Rake::Task["card:migrate:stamp"].reenable
|
70
|
+
Rake::Task["card:migrate:stamp"].invoke :deck_cards
|
71
|
+
end
|
72
|
+
|
73
|
+
Card::Cache.reset_all
|
74
|
+
end
|
75
|
+
|
36
76
|
namespace :migrate do
|
37
77
|
desc "migrate cards"
|
38
78
|
task cards: %i[core_cards deck_cards]
|
@@ -1,25 +1,32 @@
|
|
1
1
|
namespace :card do
|
2
2
|
namespace :mod do
|
3
|
+
task list: :environment do
|
4
|
+
Cardio.mods.each { |m| puts "#{m.name}: #{m.path}".green }
|
5
|
+
end
|
6
|
+
|
3
7
|
desc "symlink from deck public/{modname} to mod's public directory"
|
4
8
|
task symlink: :environment do
|
5
9
|
FileUtils.rm_rf public_mod_dir
|
6
10
|
FileUtils.mkdir_p public_mod_dir
|
7
|
-
Cardio::Mod.dirs.
|
11
|
+
Cardio::Mod.dirs.each_subpath "public" do |mod, target|
|
8
12
|
link = public_mod_dir mod
|
9
13
|
FileUtils.rm_rf link
|
10
14
|
FileUtils.ln_sf target, link
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
18
|
+
task missing: :environment do
|
19
|
+
Cardio::Mod.missing.each { |m| puts m.modname.yellow }
|
20
|
+
end
|
21
|
+
|
22
|
+
task uninstall: :environment do
|
23
|
+
Cardio::Mod.ensure_uninstalled
|
24
|
+
end
|
25
|
+
|
14
26
|
desc "install all mods"
|
15
27
|
task install: :environment do
|
16
|
-
|
17
|
-
|
18
|
-
puts "installing card mods".green
|
19
|
-
Cardio::Mod.dirs.mods.each do |mod|
|
20
|
-
mod.ensure_mod_installed
|
21
|
-
Card::Cache.reset_all
|
22
|
-
end
|
28
|
+
Cardio.config.compress_assets = true
|
29
|
+
Cardio::Mod.ensure_installed
|
23
30
|
end
|
24
31
|
|
25
32
|
def public_mod_dir subdir=nil
|
data/lib/tasks/card.rake
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
namespace :card do
|
4
|
+
desc "ingest card data from mod yaml"
|
5
|
+
task eat: :environment do
|
6
|
+
parse_options :eat do
|
7
|
+
add_opt :m, :mod, "only merge cards in given mod"
|
8
|
+
add_opt :e, :env, "environment of yaml source (default is current env)"
|
9
|
+
add_opt :u, :user, "user to credit unless specified (otherwise uses Decko Bot)"
|
10
|
+
flag_opt :v, :verbose, "progress info and error backtraces"
|
11
|
+
end
|
12
|
+
Cardio::Mod::Eat.new(**options).up
|
13
|
+
exit 0
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "export card data to mod yaml"
|
17
|
+
task poop: :environment do
|
18
|
+
parse_options :poop do
|
19
|
+
add_opt :n, :name, "export card with name/mark (handles : and ~ prefixes)"
|
20
|
+
flag_opt :i, :items, "also export card items (with -n)"
|
21
|
+
flag_opt :o, :only_items, "also export card items (with -n)", items: :only
|
22
|
+
add_opt :c, :cql, "export cards found by CQL (in JSON format)"
|
23
|
+
add_opt :m, :mod, "output yaml to data/environment.yml file in mod"
|
24
|
+
add_opt :e, :env, "environment to dump to (default is current env)"
|
25
|
+
add_opt :t, :field_tags, "comma-separated list of field tag marks"
|
26
|
+
end
|
27
|
+
result = Cardio::Mod::Poop.new(**options).out
|
28
|
+
exit 0 if result == :success
|
29
|
+
|
30
|
+
puts "ERROR in card:poop\n #{result}".red
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "reset cache"
|
35
|
+
task reset_cache: :environment do
|
36
|
+
Card::Cache.reset_all
|
37
|
+
end
|
38
|
+
|
39
|
+
def options
|
40
|
+
@options ||= {}
|
41
|
+
end
|
42
|
+
|
43
|
+
def flag_opt letter, key, desc, hash=nil
|
44
|
+
hash ||= { key => true }
|
45
|
+
op.on("-#{letter}", "--#{key.to_s.tr '_', '-'}", desc) { options.merge! hash }
|
46
|
+
end
|
47
|
+
|
48
|
+
def add_opt letter, key, desc
|
49
|
+
op.on "-#{letter}", "--#{key.to_s.tr '_', '-'} #{key.to_s.upcase}", desc do |val|
|
50
|
+
options[key] = val
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def op
|
55
|
+
@op ||= OptionParser.new
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse_options task
|
59
|
+
op.banner = "Usage: rake card:#{task} -- [options]"
|
60
|
+
yield if block_given?
|
61
|
+
args = op.order!(ARGV) {}
|
62
|
+
# args << "-h" if args.empty?
|
63
|
+
op.parse! args
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
basket[:tasks] = []
|
3
|
+
|
4
|
+
# to add an admin task:
|
5
|
+
#
|
6
|
+
# basket[:tasks] << {
|
7
|
+
# name: NAME,
|
8
|
+
# irreversible: TRUE/FALSE,
|
9
|
+
# execute_policy: -> { TASK_CODE },
|
10
|
+
# stats: {
|
11
|
+
# title: TITLE_STRING,
|
12
|
+
# count: -> { COUNT_CODE },
|
13
|
+
# link_text: LINK_STRING,
|
14
|
+
# task:
|
15
|
+
# }
|
16
|
+
# }
|
data/mod/admin/set/self/admin.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
# collect arrays of the form
|
2
|
-
# [task symbol, { execute_policy: block, stats_policy: block }]
|
3
|
-
basket :tasks
|
4
|
-
|
5
1
|
def run_task_from_task_basket task
|
6
2
|
task = task.to_sym
|
7
|
-
task_data = tasks.find { |h| h[:name].to_sym == task.to_sym }
|
3
|
+
task_data = basket[:tasks].find { |h| h[:name].to_sym == task.to_sym }
|
8
4
|
if !irreversibles_tasks_allowed? && task_data[:irreversible]
|
9
5
|
not_allowed task_data[:stats][:link_text]
|
10
6
|
elsif task_data
|
@@ -21,8 +17,8 @@ event :admin_tasks, :initialize, on: :update do
|
|
21
17
|
when :repair_references then Card::Reference.repair_all
|
22
18
|
when :repair_permissions then Card.repair_all_permissions
|
23
19
|
when :clear_solid_cache then Card.clear_solid_cache
|
24
|
-
when :
|
25
|
-
when :
|
20
|
+
when :regenerate_assets then Card::Assets.refresh_assets force: true
|
21
|
+
# when :regenerate_scripts then Card::Assets.refresh_scripts
|
26
22
|
when :clear_history
|
27
23
|
not_allowed "clear history" unless irreversibles_tasks_allowed?
|
28
24
|
Card::Action.delete_old
|
@@ -47,7 +43,7 @@ format :html do
|
|
47
43
|
stats = card_stats
|
48
44
|
stats += cache_stats
|
49
45
|
stats += memory_stats
|
50
|
-
|
46
|
+
basket[:tasks].each do |task|
|
51
47
|
stats += Array.wrap task[:stats]
|
52
48
|
end
|
53
49
|
table_content = stats.map { |args| stat_row(args) }
|
@@ -75,10 +71,12 @@ format :html do
|
|
75
71
|
count: solid_cache_count, unit: " cards",
|
76
72
|
link_text: "clear solid cache",
|
77
73
|
task: "clear_solid_cache" },
|
78
|
-
{ title: "
|
79
|
-
|
80
|
-
|
81
|
-
|
74
|
+
{ title: "style assets",
|
75
|
+
link_text: "regenerate styles and scripts",
|
76
|
+
task: "regenerate_assets" } # ,
|
77
|
+
# { title: "script assets",
|
78
|
+
# link_text: "regenerate scripts",
|
79
|
+
# task: "regenerate_scripts" }
|
82
80
|
]
|
83
81
|
# return stats unless Card.config.view_cache#
|
84
82
|
# stats << { title: "view cache",
|
@@ -121,8 +119,8 @@ format :html do
|
|
121
119
|
Card.search right: { codename: "solid_cache" }, return: "count"
|
122
120
|
end
|
123
121
|
|
124
|
-
def
|
125
|
-
Card
|
122
|
+
def asset_input_cache_count
|
123
|
+
Card.where(right_id: AssetInputCacheID).count
|
126
124
|
end
|
127
125
|
|
128
126
|
def delete_sessions_link months
|