card 1.19.1 → 1.19.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +3 -3
- data/VERSION +1 -1
- data/db/migrate_core_cards/20160908154210_add_trash_card.rb +7 -0
- data/lib/card.rb +2 -2
- data/lib/card/act_manager.rb +143 -0
- data/lib/card/act_manager/stage.rb +56 -0
- data/lib/card/act_manager/stage_director.rb +313 -0
- data/lib/card/act_manager/subdirector_array.rb +43 -0
- data/lib/card/set.rb +1 -0
- data/lib/card/set/i18n_scope.rb +52 -0
- data/lib/card/subcards.rb +2 -3
- data/lib/cardio.rb +4 -4
- data/mod/admin/set/self/admin.rb +1 -2
- data/mod/admin/set/self/trash.rb +29 -0
- data/mod/core/set/abstract/code_file.rb +5 -25
- data/mod/core/set/all/actify.rb +35 -0
- data/mod/core/set/all/fetch.rb +12 -15
- data/mod/core/set/all/i18n.rb +9 -0
- data/mod/core/set/all/phases.rb +1 -1
- data/mod/core/set/all/stages.rb +2 -2
- data/mod/developer/set/all/event_viz.rb +2 -1
- data/mod/email/set/all/notify.rb +1 -1
- data/mod/history/lib/card/act.rb +1 -1
- data/mod/history/lib/card/action.rb +1 -1
- data/mod/history/set/all/history.rb +1 -1
- data/mod/machines/set/abstract/machine.rb +1 -1
- data/mod/machines/spec/set/type/coffeescript_spec.rb +1 -1
- data/mod/machines/spec/set/type/css_spec.rb +1 -1
- data/mod/machines/spec/set/type/javascript_spec.rb +1 -1
- data/mod/machines/spec/set/type/scss_spec.rb +1 -1
- data/mod/machines/spec/set/type/skin_spec.rb +1 -1
- data/mod/machines/spec/{lib/shared_machine_examples.rb → shared_examples/machine.rb} +15 -24
- data/mod/machines/spec/{lib/shared_machine_input_examples.rb → shared_examples/machine_input.rb} +0 -0
- data/mod/settings/spec/set/right/script_spec.rb +1 -1
- data/mod/settings/spec/set/right/style_spec.rb +1 -4
- data/mod/solid_cache/set/abstract/solid_cache.rb +1 -1
- data/spec/lib/card/content_spec.rb +118 -132
- data/spec/lib/card/i18n_spec.rb +6 -7
- data/spec/lib/card/query_spec.rb +5 -4
- data/spec/lib/card/stage_director_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -4
- data/tmpsets/set/{mod002-core → mod001-core}/abstract/code_file.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/actify.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/active_card.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/collection.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/content.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/erb.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/event.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/export.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/fetch.rb +12 -14
- data/tmpsets/set/{mod002-core → mod001-core}/all/haml.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/initialize.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/location_history.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/name.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/name_validations.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/pattern.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/permissions.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/phases.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/references.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/rules.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/stages.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/states.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/subcards.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/templating.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/tracked_attributes.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/trash.rb +0 -50
- data/tmpsets/set/{mod002-core → mod001-core}/all/type.rb +0 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/utils.rb +33 -0
- data/tmpsets/set/{mod002-core → mod001-core}/all/view_cache.rb +0 -0
- data/tmpsets/set/{mod003-history → mod002-history}/all/actions.rb +0 -0
- data/tmpsets/set/{mod003-history → mod002-history}/all/content_history.rb +0 -0
- data/tmpsets/set/{mod003-history → mod002-history}/all/history.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_css.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_csv.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_js.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/base.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/file.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/json.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/rss.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/text.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/self/01_head/javascript.rb +0 -0
- data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/self/head.rb +1 -1
- data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/01_pointer.rb +0 -0
- data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/01_pointer/edit.rb +0 -0
- data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/code_pointer.rb +0 -0
- data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_editors.rb +0 -0
- data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_mods.rb +0 -0
- data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_pointer_config.rb +0 -0
- data/tmpsets/set/{mod005-pointer → mod004-pointer}/type/pointer.rb +0 -0
- data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/abstract/ace_editor.rb +0 -0
- data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/self/script_ace.rb +0 -0
- data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/self/script_ace_config.rb +0 -0
- data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/abstract/prosemirror_editor.rb +0 -0
- data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/self/script_prosemirror.rb +0 -0
- data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/self/script_prosemirror_config.rb +0 -0
- data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/abstract/solid_cache.rb +1 -1
- data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/all/solid_cache.rb +0 -0
- data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/right/solid_cache.rb +0 -0
- data/tmpsets/set/{mod010-basic_types → mod009-basic_types}/type/html.rb +0 -0
- data/tmpsets/set/{mod010-basic_types → mod009-basic_types}/type/plain_text.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/abstract/script.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/all/reset_machines.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_cache.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_input.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_output.rb +1 -9
- data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_card_menu.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_html5shiv_printshiv.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_jquery.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_jquery_helper.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_slot.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_bootstrap_compatible.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_cards.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_jquery_ui_smoothness.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/type/coffee_script.rb +6 -2
- data/tmpsets/set/{mod011-machines → mod010-machines}/type/css.rb +2 -2
- data/tmpsets/set/{mod011-machines → mod010-machines}/type/java_script.rb +2 -2
- data/tmpsets/set/{mod011-machines → mod010-machines}/type/scss.rb +0 -0
- data/tmpsets/set/{mod011-machines → mod010-machines}/type/skin.rb +2 -2
- data/tmpsets/set/{mod012-settings → mod011-settings}/abstract/permission.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/add_help.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/comment.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/create.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/default.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/delete.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/help.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/read.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/script.rb +1 -1
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/structure.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/style.rb +1 -1
- data/tmpsets/set/{mod012-settings → mod011-settings}/right/update.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/accountable.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/add_help.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/autoname.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/captcha.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/create.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/default.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/default_html_view.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/delete.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/follow_fields.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/help.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/input.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/layout.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_create.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_delete.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_update.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/options.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/options_label.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/read.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/recent_settings.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/script.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/structure.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/style.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/table_of_contents.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/thanks.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/self/update.rb +0 -0
- data/tmpsets/set/{mod012-settings → mod011-settings}/type/setting.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/all/email_html.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/all/email_text.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/all/follow.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/all/notify.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/all/observer.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/bcc.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/cc.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/follow.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/follow_fields.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/followers.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/following.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/from.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/html_message.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/right/to.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/self/always.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/self/created.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/self/edited.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/self/follow.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/self/follow_defaults.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/self/never.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/type/email_template.rb +0 -0
- data/tmpsets/set/{mod013-email → mod012-email}/type_plus_right/user/follow.rb +8 -4
- data/tmpsets/set/mod016-standard/all/links.rb +2 -2
- data/tmpsets/set/mod018-bootstrap/all/bootstrap/table.rb +1 -1
- data/tmpsets/set/mod018-bootstrap/self/bootswatch_shared.rb +1 -1
- metadata +149 -163
- data/lib/card/director_register.rb +0 -101
- data/lib/card/stage.rb +0 -106
- data/lib/card/stage_director.rb +0 -310
- data/lib/card/subdirector_array.rb +0 -43
- data/tmpsets/set/mod001-admin/self/admin.rb +0 -130
- data/tmpsets/set/mod001-admin/self/admin_info.rb +0 -110
- data/tmpsets/set/mod001-admin/self/version.rb +0 -15
- data/tmpsets/set/mod002-core/all/debug.rb +0 -30
- data/tmpsets/set/mod002-core/all/update_read_rules.rb +0 -91
- data/tmpsets/set/mod011-machines/abstract/machine.rb +0 -277
- data/tmpsets/set/mod011-machines/abstract/machine_input.rb +0 -83
- data/tmpsets/set/mod014-developer/all/event_viz.rb +0 -59
- data/tmpsets/set/mod014-developer/all/view_viz.rb +0 -30
- data/tmpsets/set/mod014-developer/right/debug.rb +0 -96
- data/tmpsets/set/mod015-carrierwave/abstract/attachment.rb +0 -118
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/paths.rb +0 -57
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/storage_type.rb +0 -326
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/upload_cache.rb +0 -84
- data/tmpsets/set/mod015-carrierwave/all/file_utils.rb +0 -35
- data/tmpsets/set/mod015-carrierwave/self/admin.rb +0 -30
- data/tmpsets/set/mod015-carrierwave/type/file.rb +0 -158
- data/tmpsets/set/mod015-carrierwave/type/image.rb +0 -97
@@ -0,0 +1,43 @@
|
|
1
|
+
class Card
|
2
|
+
class ActManager
|
3
|
+
class SubdirectorArray < Array
|
4
|
+
def self.initialize_with_subcards parent
|
5
|
+
dir_array = new(parent)
|
6
|
+
parent.card.subcards.each_card do |subcard|
|
7
|
+
dir_array.add subcard
|
8
|
+
end
|
9
|
+
dir_array
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize parent
|
13
|
+
@parent = parent
|
14
|
+
super()
|
15
|
+
end
|
16
|
+
|
17
|
+
def add card, opts={}
|
18
|
+
card = card.card if card.is_a? StageDirector
|
19
|
+
each { |dir| return dir if dir.card == card }
|
20
|
+
dir = ActManager.fetch card, parent: @parent
|
21
|
+
dir.main = false
|
22
|
+
dir.parent = @parent
|
23
|
+
dir.transact_in_stage = opts[:transact_in_stage]
|
24
|
+
self << dir
|
25
|
+
dir
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method :delete_director, :delete
|
29
|
+
|
30
|
+
def delete card
|
31
|
+
if card.is_a? StageDirector
|
32
|
+
delete_director card
|
33
|
+
else
|
34
|
+
delete_if { |dir| dir.card == card }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_director dir
|
39
|
+
add dir.card
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/card/set.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
class Card
|
2
|
+
module Set
|
3
|
+
module I18nScope
|
4
|
+
# return scope for I18n
|
5
|
+
def scope backtrace
|
6
|
+
parts = tmp_set_path_parts backtrace
|
7
|
+
"mod.#{parts.first}.set.#{parts[1..-1].join '.'}"
|
8
|
+
end
|
9
|
+
|
10
|
+
# extract the mod name from the path of a set's tmp file
|
11
|
+
def mod_name backtrace
|
12
|
+
tmp_set_path_parts(backtrace).first
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# extract mod and set from tmp path
|
18
|
+
# @example
|
19
|
+
# a tmp paths looks like ~/mydeck/tmp/set/mod002-core/all/event.rb/
|
20
|
+
# this method returns ["core", "all", "event"]
|
21
|
+
def tmp_set_path_parts backtrace
|
22
|
+
path_parts = find_tmp_set_path(backtrace).split(File::SEPARATOR)
|
23
|
+
res = path_parts[path_mod_index(path_parts)..-1]
|
24
|
+
res[0] = mod_name_from_tmp_dir res.first
|
25
|
+
res[-1] = res.last.split(".").first
|
26
|
+
res
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_tmp_set_path backtrace
|
30
|
+
path = backtrace.find { |line| line.include? "tmp/set/" }
|
31
|
+
unless path
|
32
|
+
raise Error, "couldn't find set path in backtrace: #{backtrace}"
|
33
|
+
end
|
34
|
+
path
|
35
|
+
end
|
36
|
+
|
37
|
+
# index of the mod part in the tmp path
|
38
|
+
def path_mod_index parts
|
39
|
+
unless (set_index = parts.index("set")) &&
|
40
|
+
parts.size >= set_index + 2
|
41
|
+
raise Error, "not a valid set path: #{path}"
|
42
|
+
end
|
43
|
+
set_index + 1
|
44
|
+
end
|
45
|
+
|
46
|
+
def mod_name_from_tmp_dir dir
|
47
|
+
match = dir.match(/^mod\d+-(?<mod_name>.+)$/)
|
48
|
+
match[:mod_name]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/card/subcards.rb
CHANGED
@@ -12,7 +12,6 @@
|
|
12
12
|
class Card
|
13
13
|
def subcards
|
14
14
|
@subcards ||= Subcards.new(self)
|
15
|
-
# @subcards ||= (director && director.subcards)
|
16
15
|
end
|
17
16
|
|
18
17
|
def expire_subcards
|
@@ -82,7 +81,7 @@ class Card
|
|
82
81
|
def clear
|
83
82
|
@keys.each do |key|
|
84
83
|
if (subcard = fetch_subcard key)
|
85
|
-
|
84
|
+
ActManager.delete subcard.director
|
86
85
|
end
|
87
86
|
Card.cache.soft.delete key
|
88
87
|
end
|
@@ -104,7 +103,7 @@ class Card
|
|
104
103
|
@keys.delete key
|
105
104
|
removed_card = fetch_subcard key
|
106
105
|
removed_card.current_action.delete if removed_card.current_action
|
107
|
-
|
106
|
+
ActManager.deep_delete removed_card.director
|
108
107
|
Card.cache.soft.delete key
|
109
108
|
removed_card
|
110
109
|
end
|
data/lib/cardio.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
require "active_support/core_ext/numeric/time"
|
4
|
-
|
4
|
+
djar = "delayed_job_active_record"
|
5
|
+
require djar if Gem::Specification.find_all_by_name(djar).any?
|
5
6
|
require "cardio/schema.rb"
|
6
7
|
|
7
8
|
ActiveSupport.on_load :card do
|
@@ -16,11 +17,11 @@ module Cardio
|
|
16
17
|
extend Schema
|
17
18
|
CARD_GEM_ROOT = File.expand_path("../..", __FILE__)
|
18
19
|
|
19
|
-
mattr_reader :paths, :config
|
20
|
+
mattr_reader :paths, :config
|
20
21
|
|
21
22
|
class << self
|
22
23
|
def cache
|
23
|
-
|
24
|
+
@cache ||= ::Rails.cache
|
24
25
|
end
|
25
26
|
|
26
27
|
def default_configs
|
@@ -63,7 +64,6 @@ module Cardio
|
|
63
64
|
|
64
65
|
def set_config config
|
65
66
|
@@config = config
|
66
|
-
@@root = config.root
|
67
67
|
|
68
68
|
config.autoload_paths += Dir["#{gem_root}/lib/**/"]
|
69
69
|
config.autoload_paths += Dir["#{gem_root}/mod/*/lib/**/"]
|
data/mod/admin/set/self/admin.rb
CHANGED
@@ -5,7 +5,6 @@ basket :tasks
|
|
5
5
|
event :admin_tasks, :initialize, on: :update do
|
6
6
|
return unless (task = Env.params[:task])
|
7
7
|
raise Card::Error::PermissionDenied, self unless Auth.always_ok?
|
8
|
-
|
9
8
|
case task.to_sym
|
10
9
|
when :clear_cache then Card::Cache.reset_all
|
11
10
|
when :repair_references then Card::Reference.repair_all
|
@@ -15,7 +14,7 @@ event :admin_tasks, :initialize, on: :update do
|
|
15
14
|
when :clear_solid_cache then Card.clear_solid_cache
|
16
15
|
when :clear_machine_cache then Card.reset_all_machines
|
17
16
|
else
|
18
|
-
task_data = tasks.find { |h| h[:name].to_sym == task }
|
17
|
+
task_data = tasks.find { |h| h[:name].to_sym == task.to_sym }
|
19
18
|
task_data[:execute_policy].call if task_data
|
20
19
|
end
|
21
20
|
abort :success
|
@@ -0,0 +1,29 @@
|
|
1
|
+
format :html do
|
2
|
+
def trashed_cards
|
3
|
+
Card.where(trash: true)
|
4
|
+
end
|
5
|
+
|
6
|
+
view :core do |_args|
|
7
|
+
rows =
|
8
|
+
trashed_cards.map do |card|
|
9
|
+
[card.name, Card[card.updater_id].name, put_back_link(card)]
|
10
|
+
end
|
11
|
+
output [
|
12
|
+
(content_tag(:p, empty_trash_link) if rows.present?),
|
13
|
+
table(rows, header: ["card", "deleted by", ""])
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
def empty_trash_link
|
18
|
+
card_link :admin, path_opts: { action: :update, task: :empty_trash,
|
19
|
+
success: { id: "~#{card.id}" } },
|
20
|
+
text: "empty trash"
|
21
|
+
end
|
22
|
+
|
23
|
+
def put_back_link card
|
24
|
+
before_delete = card.actions[-2]
|
25
|
+
link_path = path action: :update, view: :open, action_ids: [before_delete],
|
26
|
+
success: { id: card.name }
|
27
|
+
link_to "put back", link_path, method: :post, rel: "nofollow"
|
28
|
+
end
|
29
|
+
end
|
@@ -1,24 +1,6 @@
|
|
1
1
|
def self.included host_class
|
2
2
|
host_class.mattr_accessor :file_content_mod_name
|
3
|
-
host_class.file_content_mod_name = mod_name(caller)
|
4
|
-
end
|
5
|
-
|
6
|
-
# try to extract the mod name from the path of the set's tmp file
|
7
|
-
# the caller that included the set file is set.rb
|
8
|
-
def self.mod_name backtrace
|
9
|
-
mod_dir = tmp_mod_dir backtrace
|
10
|
-
raise Error, "not a valid set path: #{path}" unless mod_dir
|
11
|
-
match = mod_dir.match(/^mod\d+-(?<mod_name>.+)$/)
|
12
|
-
match[:mod_name]
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.tmp_mod_dir backtrace
|
16
|
-
path = backtrace.find { |line| line.include? "tmp/set/" }
|
17
|
-
raise Error, "couldn't find set path in backtrace: #{backtrace}" unless path
|
18
|
-
path_parts = path.split(File::SEPARATOR)
|
19
|
-
path_parts.fetch(path_parts.index("set") + 1) do
|
20
|
-
raise Error, "not a valid set path: #{path}"
|
21
|
-
end
|
3
|
+
host_class.file_content_mod_name = Card::Set.mod_name(caller)
|
22
4
|
end
|
23
5
|
|
24
6
|
# @return [Array<String>, String] the name of file(s) to be loaded
|
@@ -39,12 +21,10 @@ def source_dir
|
|
39
21
|
end
|
40
22
|
|
41
23
|
def find_file filename
|
42
|
-
Card.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
nil
|
24
|
+
mod_path = Card::Mod::Loader.mod_dirs.path file_content_mod_name
|
25
|
+
file_path = File.join(mod_path, "lib", source_dir, filename)
|
26
|
+
return unless File.exist? file_path
|
27
|
+
file_path
|
48
28
|
end
|
49
29
|
|
50
30
|
def existing_source_paths
|
data/mod/core/set/all/actify.rb
CHANGED
@@ -19,6 +19,41 @@ def abort status, msg="action canceled"
|
|
19
19
|
raise Card::Error::Abort.new(status, msg)
|
20
20
|
end
|
21
21
|
|
22
|
+
def act opts={}
|
23
|
+
if ActManager.act_card
|
24
|
+
add_to_act opts
|
25
|
+
main_act_block = false
|
26
|
+
else
|
27
|
+
start_new_act opts
|
28
|
+
main_act_block = true
|
29
|
+
end
|
30
|
+
yield
|
31
|
+
ensure
|
32
|
+
ActManager.clear if main_act_block
|
33
|
+
end
|
34
|
+
|
35
|
+
def start_new_act opts
|
36
|
+
ActManager.clear
|
37
|
+
self.director = nil
|
38
|
+
ActManager.act_card = self
|
39
|
+
if opts && opts[:success]
|
40
|
+
Env[:success] = Env::Success.new(cardname, Env.params[:success])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_to_act opts
|
45
|
+
# if only_storage_phase is true the card is already part of the act
|
46
|
+
return if ActManager.act_card == self || only_storage_phase
|
47
|
+
director.reset_stage
|
48
|
+
if opts && opts[:trash]
|
49
|
+
@action = :delete
|
50
|
+
else
|
51
|
+
identify_action
|
52
|
+
end
|
53
|
+
director.update_card self
|
54
|
+
self.only_storage_phase = true
|
55
|
+
end
|
56
|
+
|
22
57
|
module ClassMethods
|
23
58
|
def create! opts
|
24
59
|
card = Card.new opts
|
data/mod/core/set/all/fetch.rb
CHANGED
@@ -8,21 +8,18 @@ module ClassMethods
|
|
8
8
|
# * database
|
9
9
|
# * virtual cards
|
10
10
|
#
|
11
|
-
# @param
|
12
|
-
# one of three unique identifiers
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# :local_only Use only local cache for lookup and storing
|
24
|
-
# new: { opts for Card#new } Return a new card when not found
|
25
|
-
#
|
11
|
+
# @param args [Integer, String, Card::Name, Symbol]
|
12
|
+
# one or more of the three unique identifiers
|
13
|
+
# 1. a numeric id (Integer)
|
14
|
+
# 2. a name/key (String or Card::Name)
|
15
|
+
# 3. a codename (Symbol)
|
16
|
+
# If you pass more then one mark they get joined with a '+'.
|
17
|
+
# The final argument can be a hash to set the following options
|
18
|
+
# :skip_virtual Real cards only
|
19
|
+
# :skip_modules Don't load Set modules
|
20
|
+
# :look_in_trash Return trashed card objects
|
21
|
+
# :local_only Use only local cache for lookup and storing
|
22
|
+
# new: { opts for Card#new } Return a new card when not found
|
26
23
|
# @return [Card]
|
27
24
|
def fetch *args
|
28
25
|
mark, opts = normalize_fetch_args args
|
data/mod/core/set/all/phases.rb
CHANGED
data/mod/core/set/all/stages.rb
CHANGED
@@ -15,7 +15,8 @@ require_dependency 'active_support/callbacks_ext'
|
|
15
15
|
# prevent events from showing up in the tree.
|
16
16
|
def events action
|
17
17
|
@action = action
|
18
|
-
events =
|
18
|
+
events =
|
19
|
+
ActManager::Stage::STAGES.map { |stage| events_tree("#{stage}_stage") }
|
19
20
|
@action = nil
|
20
21
|
puts_events events
|
21
22
|
end
|
data/mod/email/set/all/notify.rb
CHANGED
data/mod/history/lib/card/act.rb
CHANGED
@@ -70,7 +70,7 @@ class Card
|
|
70
70
|
# @return [Card]
|
71
71
|
def card
|
72
72
|
res = Card.fetch card_id, look_in_trash: true, skip_modules: true
|
73
|
-
return res unless res.type_id.in?
|
73
|
+
return res unless res && res.type_id.in?([FileID, ImageID])
|
74
74
|
res.include_set_modules
|
75
75
|
end
|
76
76
|
|
@@ -62,7 +62,7 @@ class Card
|
|
62
62
|
# @return [Card]
|
63
63
|
def card
|
64
64
|
res = Card.fetch card_id, look_in_trash: true, skip_modules: true
|
65
|
-
return res unless res.type_id.in?
|
65
|
+
return res unless res && res.type_id.in?([FileID, ImageID])
|
66
66
|
res.include_set_modules
|
67
67
|
end
|
68
68
|
|
@@ -239,7 +239,7 @@ def unlock!
|
|
239
239
|
end
|
240
240
|
|
241
241
|
def update_input_card
|
242
|
-
if
|
242
|
+
if Card::ActManager.running_act?
|
243
243
|
input_card = attach_subcard! machine_input_card
|
244
244
|
input_card.content = ""
|
245
245
|
engine_input.each { |input| input_card << input }
|
@@ -6,7 +6,7 @@ describe Card::Set::Type::CoffeeScript do
|
|
6
6
|
let(:changed_coffee) { 'alert "Hello" ' }
|
7
7
|
let(:compressed_changed_coffee) { '(function(){alert("Hello")}).call(this);' }
|
8
8
|
|
9
|
-
it_should_behave_like "content machine",
|
9
|
+
it_should_behave_like "content machine", that_produces: :js do
|
10
10
|
let(:machine_card) do
|
11
11
|
Card.gimme! "coffee machine", type: Card::CoffeeScriptID,
|
12
12
|
content: coffee
|
@@ -30,7 +30,7 @@ describe Card::Set::Type::Css do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
it_behaves_like "content machine",
|
33
|
+
it_behaves_like "content machine", that_produces: :css do
|
34
34
|
let(:machine_card) { Card.gimme! "test css", type: :css, content: css }
|
35
35
|
let(:card_content) do
|
36
36
|
{ in: css, out: compressed_css,
|
@@ -10,7 +10,7 @@ describe Card::Set::Type::JavaScript do
|
|
10
10
|
"//#{source}\n#{content}"
|
11
11
|
end
|
12
12
|
|
13
|
-
it_should_behave_like "content machine",
|
13
|
+
it_should_behave_like "content machine", that_produces: :js do
|
14
14
|
let(:machine_card) do
|
15
15
|
Card.gimme! "test javascript", type: :java_script, content: js
|
16
16
|
end
|