card 1.108.1 → 1.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/environments/development.rb +1 -1
- data/config/environments/production.rb +5 -2
- data/config/initializers/01_core_extensions/array.rb +1 -0
- data/config/initializers/01_core_extensions/hash.rb +4 -0
- data/config/initializers/02_patches/active_record.rb +1 -1
- data/config/initializers/core_extensions.rb +0 -1
- data/config/initializers/deck_config.rb +3 -3
- data/config/initializers/patches.rb +6 -6
- data/lib/card/auth/current.rb +8 -6
- data/lib/card/auth.rb +7 -6
- data/lib/card/cache/class_methods.rb +2 -4
- data/lib/card/cache/shared.rb +1 -1
- data/lib/card/cache/temporary.rb +2 -2
- data/lib/card/codename.rb +0 -1
- data/lib/card/content/chunk/abstract.rb +1 -0
- data/lib/card/content/chunk.rb +0 -1
- data/lib/card/content/clean.rb +4 -2
- data/lib/card/content/diff/l_c_s.rb +1 -2
- data/lib/card/content/diff/result.rb +2 -1
- data/lib/card/content/diff.rb +2 -1
- data/lib/card/content/parser.rb +8 -7
- data/lib/card/content.rb +1 -1
- data/lib/card/director/subdirector_array.rb +1 -0
- data/lib/card/director.rb +1 -1
- data/lib/card/dirty/method_factory.rb +1 -0
- data/lib/card/env/location.rb +3 -3
- data/lib/card/env/location_history.rb +12 -11
- data/lib/card/env/success/target.rb +4 -4
- data/lib/card/env/support.rb +24 -2
- data/lib/card/error.rb +1 -0
- data/lib/card/fetch/store.rb +1 -1
- data/lib/card/format/error.rb +1 -0
- data/lib/card/format/method_delegation.rb +6 -4
- data/lib/card/format/registration.rb +5 -3
- data/lib/card/format/wrapper.rb +1 -0
- data/lib/card/mailer.rb +1 -14
- data/lib/card/name/all/parts.rb +1 -1
- data/lib/card/name/all.rb +1 -0
- data/lib/card/name/name_variants.rb +1 -0
- data/lib/card/query/abstract_query/query_helper.rb +1 -2
- data/lib/card/query/abstract_query/tie.rb +1 -1
- data/lib/card/query/abstract_query.rb +3 -3
- data/lib/card/query/card_class.rb +1 -0
- data/lib/card/query/clause.rb +1 -0
- data/lib/card/query/join.rb +3 -3
- data/lib/card/reference/all.rb +6 -7
- data/lib/card/rule/cache.rb +1 -0
- data/lib/card/rule/preference_cache.rb +2 -0
- data/lib/card/rule/read_rule_cache.rb +3 -0
- data/lib/card/set/event/all.rb +6 -4
- data/lib/card/set/event/callbacks.rb +1 -0
- data/lib/card/set/event/options.rb +3 -2
- data/lib/card/set/event/skip_and_trigger.rb +1 -1
- data/lib/card/set/event.rb +2 -2
- data/lib/card/set/format/abstract_format/view_definition.rb +1 -1
- data/lib/card/set/format/haml_paths.rb +1 -1
- data/lib/card/set/format.rb +4 -4
- data/lib/card/set/helpers.rb +4 -4
- data/lib/card/set/i18n_scanner.rb +23 -22
- data/lib/card/set/i18n_scope.rb +4 -3
- data/lib/card/set/pattern/all.rb +1 -1
- data/lib/card/set/pattern/base.rb +6 -3
- data/lib/card/set/pattern/class_methods.rb +1 -1
- data/lib/card/set/pattern.rb +1 -1
- data/lib/card/set/required_field.rb +3 -0
- data/lib/card/set/trait.rb +6 -1
- data/lib/card/subcards/all.rb +12 -4
- data/lib/card/view/cache/cache_action.rb +1 -1
- data/lib/card/view/cache.rb +1 -1
- data/lib/card/view/classy.rb +5 -5
- data/lib/card/view/options/key_lists.rb +1 -0
- data/lib/card/view/options/voo_api.rb +1 -1
- data/lib/cardio/command/application.rb +1 -1
- data/lib/cardio/command/custom.rb +7 -6
- data/lib/cardio/command/rake_command.rb +3 -2
- data/lib/cardio/command/rspec_command.rb +1 -0
- data/lib/cardio/generators/deck_generator_loader.rb +1 -1
- data/lib/cardio/generators.rb +4 -3
- data/lib/cardio/migration/port.rb +2 -0
- data/lib/cardio/migration/stamp.rb +1 -0
- data/lib/cardio/migration/transform.rb +1 -0
- data/lib/cardio/migration.rb +2 -0
- data/lib/cardio/mod/class_methods.rb +1 -2
- data/lib/cardio/mod/dirs.rb +2 -4
- data/lib/cardio/mod/eat/edibles.rb +8 -6
- data/lib/cardio/mod/eat.rb +6 -5
- data/lib/cardio/mod/load_strategy/set_binding_magic.rb +1 -1
- data/lib/cardio/mod/load_strategy/tmp_files.rb +3 -2
- data/lib/cardio/mod/load_strategy.rb +1 -0
- data/lib/cardio/mod/loader/set_pattern_loader.rb +4 -0
- data/lib/cardio/mod/loader/set_template.rb +14 -4
- data/lib/cardio/mod/loader.rb +2 -2
- data/lib/cardio/mod/sow/card_source.rb +1 -1
- data/lib/cardio/mod/sow/remote_source.rb +32 -0
- data/lib/cardio/mod/sow.rb +10 -10
- data/lib/cardio/railtie.rb +1 -0
- data/lib/cardio/script_loader.rb +1 -1
- data/lib/cardio/seed.rb +1 -1
- data/lib/cardio/utils.rb +1 -1
- data/lib/cardio/version.rb +2 -1
- data/lib/cardio.rb +3 -0
- data/lib/generators/deck/templates/config.ru.erb +1 -1
- data/mod/core/config/locales/en.yml +1 -0
- data/mod/core/data/schema/20141001105348_move_revisions_to_actions.rb +2 -2
- data/mod/core/data/schema/20241017160402_unique_codename.rb +8 -0
- data/mod/core/data/transform/20150724123438_update_file_and_image_cards.rb +1 -1
- data/mod/core/lib/tasks/card/export.rake +28 -0
- data/mod/core/lib/tasks/card/migrate.rake +3 -3
- data/mod/core/lib/tasks/card/seed.rake +2 -1
- data/mod/core/lib/tasks/card.rake +47 -16
- data/mod/core/set/all/admin.rb +1 -2
- data/mod/core/set/all/assign_attributes.rb +3 -2
- data/mod/core/set/all/codename.rb +7 -0
- data/mod/core/set/all/debug.rb +3 -3
- data/mod/core/set/all/initialize.rb +1 -0
- data/mod/core/set/all/states.rb +7 -6
- data/mod/core/set/all/type.rb +2 -0
- data/mod/core/set/all/utils.rb +0 -1
- data/mod/core/set/self/admin.rb +2 -1
- data/mod/core/set/self/autoname.rb +1 -1
- data/mod/core/set/self/mod.rb +4 -4
- data/mod/core/set/self/trash.rb +1 -1
- data/mod/core/set/type/mod.rb +18 -15
- data/mod/core/set_pattern/09_self.rb +4 -0
- data/mod/core/spec/set/all/trash_spec.rb +7 -7
- metadata +42 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae89c5e6253fdbcea6b9ea9e1a5ca94b8f22f0c13c47186d8a2d66d6bfb525b
|
4
|
+
data.tar.gz: babc949cb5a33a9385369e62136b60591e96ac03b09a06660bce43d30165cfce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70439a264188fa2f734ddf9ce6cbd8f7ca790bfcddde0c0accf8a2ffa9d2c575c90220d848678c7f1ac965e734ecf4a4d30e33aaed5b41345958210cd24db84
|
7
|
+
data.tar.gz: 6ff17cfaf5b5a7af5fcca9f95693b083b81aa781de06c244356c8b7e397e4621e7784995613252dae2c2d78406f0347f0977212cf91c79cd77c1b9917813e6ee
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.19.0
|
@@ -26,7 +26,7 @@ Cardio.application.class.configure do
|
|
26
26
|
config.action_controller.perform_caching = false
|
27
27
|
|
28
28
|
# Don't care if the mailer can't send
|
29
|
-
config.action_mailer.raise_delivery_errors = false
|
29
|
+
# config.action_mailer.raise_delivery_errors = false
|
30
30
|
|
31
31
|
# Print deprecation notices to the Rails logger
|
32
32
|
config.active_support.deprecation = :log
|
@@ -4,6 +4,7 @@ Cardio.application.class.configure do
|
|
4
4
|
# Settings specified here will take precedence over those in config/application.rb
|
5
5
|
|
6
6
|
config.eager_load = true
|
7
|
+
config.view_cache = true
|
7
8
|
|
8
9
|
# temporary fix for formerly autoloaded files that stopped autoloading in Rails 5
|
9
10
|
# TODO: configure eager_load_paths explicitly (and remove this)
|
@@ -35,7 +36,8 @@ Cardio.application.class.configure do
|
|
35
36
|
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
36
37
|
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
37
38
|
|
38
|
-
# Force all access to the app over SSL, use Strict-Transport-Security,
|
39
|
+
# Force all access to the app over SSL, use Strict-Transport-Security,
|
40
|
+
# and use secure cookies.
|
39
41
|
# config.force_ssl = true
|
40
42
|
|
41
43
|
# See everything in the log (default is :info)
|
@@ -50,7 +52,8 @@ Cardio.application.class.configure do
|
|
50
52
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
51
53
|
# config.action_controller.asset_host = "http://assets.example.com"
|
52
54
|
|
53
|
-
# Precompile additional assets (application.js, application.css,
|
55
|
+
# Precompile additional assets (application.js, application.css,
|
56
|
+
# and all non-JS/CSS are already added)
|
54
57
|
# config.assets.precompile += %w[application-all.css application-print.css barebones.css
|
55
58
|
# html5shiv-printshiv.js]
|
56
59
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module CoreExtensions
|
2
|
+
# extensions for Ruby Hashes
|
2
3
|
module Hash
|
4
|
+
# extend ruby Hash class
|
3
5
|
module ClassMethods
|
6
|
+
# nested ruby hashes
|
4
7
|
module Nesting
|
5
8
|
# create hash with default nested structures
|
6
9
|
# @example
|
@@ -21,6 +24,7 @@ module CoreExtensions
|
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
27
|
+
# special ruby hash merging behavior
|
24
28
|
module Merging
|
25
29
|
# attach CSS classes
|
26
30
|
# @example
|
@@ -1,3 +1,3 @@
|
|
1
|
-
if File.exist? "config/deck.yml"
|
2
|
-
|
3
|
-
end
|
1
|
+
# if File.exist? "config/deck.yml"
|
2
|
+
# Cardio.application.config.x = OpenStruct.new(Cardio.application.config_for(:deck))
|
3
|
+
# end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Kaminari
|
1
|
+
module Kaminari # :nodoc: all
|
2
2
|
module Helpers
|
3
3
|
class Tag
|
4
4
|
include Patches::Kaminari::Helpers::Tag
|
@@ -7,14 +7,14 @@ module Kaminari #:nodoc: all
|
|
7
7
|
end
|
8
8
|
|
9
9
|
if defined? BetterErrors
|
10
|
-
module BetterErrors
|
10
|
+
module BetterErrors # :nodoc: all
|
11
11
|
class StackFrame
|
12
12
|
# suppress_warnings { include Patches::BetterErrors::StackFrame::TmpPath }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
module ActiveRecord
|
17
|
+
module ActiveRecord # :nodoc: all
|
18
18
|
class Relation
|
19
19
|
include Patches::ActiveRecord::Relation
|
20
20
|
end
|
@@ -48,14 +48,14 @@ module ActiveRecord #:nodoc: all
|
|
48
48
|
end
|
49
49
|
|
50
50
|
module ActiveJob
|
51
|
-
module Arguments
|
51
|
+
module Arguments # :nodoc: all
|
52
52
|
class << self
|
53
53
|
prepend Patches::ActiveJob::Arguments
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
module ActiveSupport
|
58
|
+
module ActiveSupport # :nodoc: all
|
59
59
|
module Callbacks
|
60
60
|
class Callback
|
61
61
|
prepend Patches::ActiveSupport::Callbacks::Callback
|
@@ -63,7 +63,7 @@ module ActiveSupport #:nodoc: all
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
module Zeitwerk
|
66
|
+
module Zeitwerk # :nodoc: all
|
67
67
|
class Loader
|
68
68
|
prepend Patches::Zeitwerk
|
69
69
|
end
|
data/lib/card/auth/current.rb
CHANGED
@@ -34,14 +34,16 @@ class Card
|
|
34
34
|
|
35
35
|
# set current user in process and session
|
36
36
|
def signin cardish
|
37
|
-
|
38
|
-
|
37
|
+
user_id = Card.id(cardish) || AnonymousID
|
38
|
+
(session[session_user_key] = self.current_id = user_id).tap do
|
39
|
+
Env.update_cookie_setting !signed_in?
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
# current user is not anonymous
|
42
44
|
# @return [true/false]
|
43
45
|
def signed_in?
|
44
|
-
current_id !=
|
46
|
+
current_id != AnonymousID
|
45
47
|
end
|
46
48
|
|
47
49
|
# set current from token, api_key, or session
|
@@ -63,7 +65,7 @@ class Card
|
|
63
65
|
# get session object from Env
|
64
66
|
# return [Session]
|
65
67
|
def session
|
66
|
-
|
68
|
+
Env.session
|
67
69
|
end
|
68
70
|
|
69
71
|
# find +\*account card by +\*email card
|
@@ -89,8 +91,8 @@ class Card
|
|
89
91
|
# @return [+*account card, nil]
|
90
92
|
def find_account_by fieldcode, value
|
91
93
|
Auth.as_bot do
|
92
|
-
Card.search({ right_id:
|
93
|
-
right_plus: [
|
94
|
+
Card.search({ right_id: AccountID,
|
95
|
+
right_plus: [Codename.id(fieldcode), { content: value }] },
|
94
96
|
"find +:account with +#{fieldcode} (#{value})").first
|
95
97
|
end
|
96
98
|
end
|
data/lib/card/auth.rb
CHANGED
@@ -19,12 +19,9 @@ class Card
|
|
19
19
|
# @return [+*account card, nil]
|
20
20
|
def authenticate email, password
|
21
21
|
account = Auth.find_account_by_email email
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
when Card.config.no_authentication then account
|
26
|
-
when password_valid?(account, password.strip) then account
|
27
|
-
end
|
22
|
+
return nil unless account&.active?
|
23
|
+
|
24
|
+
account if not_required? || password_valid?(account, password.strip)
|
28
25
|
end
|
29
26
|
|
30
27
|
# check whether password is correct for account card
|
@@ -43,6 +40,10 @@ class Card
|
|
43
40
|
def serialize
|
44
41
|
{ as_id: as_id, current_id: current_id }
|
45
42
|
end
|
43
|
+
|
44
|
+
def not_required?
|
45
|
+
Card.config.no_authentication
|
46
|
+
end
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
-
|
2
1
|
class Card
|
3
2
|
class Cache
|
4
3
|
# class methods for Card::Cache
|
5
4
|
module ClassMethods
|
6
5
|
include Populate
|
7
6
|
|
8
|
-
attr_accessor :no_renewal
|
9
|
-
attr_accessor :counter
|
7
|
+
attr_accessor :no_renewal, :counter
|
10
8
|
|
11
9
|
# create a new cache for the ruby class provided
|
12
10
|
# @param klass [Class]
|
@@ -109,7 +107,7 @@ class Card
|
|
109
107
|
end
|
110
108
|
|
111
109
|
def tallies
|
112
|
-
"#{tally_total} Cache calls (
|
110
|
+
"#{tally_total} Cache calls (#{counter.map { |k, v| "#{k}=#{v} " }.join})"
|
113
111
|
end
|
114
112
|
|
115
113
|
private
|
data/lib/card/cache/shared.rb
CHANGED
@@ -82,7 +82,7 @@ class Card
|
|
82
82
|
def read_multi keys
|
83
83
|
map = keys.each_with_object({}) { |k, h| h[full_key k] = k }
|
84
84
|
raw = @store.read_multi(*map.keys)
|
85
|
-
raw.
|
85
|
+
raw.transform_keys { |k| map[k] }
|
86
86
|
end
|
87
87
|
|
88
88
|
# update an attribute of an object already in the cache
|
data/lib/card/cache/temporary.rb
CHANGED
@@ -11,7 +11,7 @@ class Card
|
|
11
11
|
# Unlike the Shared cache, the Temporary cache can handle objects with
|
12
12
|
# singleton classes.
|
13
13
|
class Temporary
|
14
|
-
MAX_KEYS =
|
14
|
+
MAX_KEYS = Cardio.config.max_temporary_cache_keys
|
15
15
|
attr_reader :store
|
16
16
|
|
17
17
|
def initialize klass
|
@@ -80,7 +80,7 @@ class Card
|
|
80
80
|
def within_key_counts
|
81
81
|
if @reps >= MAX_KEYS && (@reps = @store.size) > MAX_KEYS
|
82
82
|
Rails.logger.info "RESETTING temporary #{@klass} cache. " \
|
83
|
-
|
83
|
+
"MAX_KEYS (#{MAX_KEYS}) exceeded"
|
84
84
|
reset
|
85
85
|
end
|
86
86
|
yield
|
data/lib/card/codename.rb
CHANGED
data/lib/card/content/chunk.rb
CHANGED
@@ -9,7 +9,6 @@ class Card
|
|
9
9
|
# +pattern+ that states what sort of text it matches.
|
10
10
|
# Chunks are initalized by passing in the result of a
|
11
11
|
# match by its pattern.
|
12
|
-
#
|
13
12
|
module Chunk
|
14
13
|
mattr_accessor :raw_list, :prefix_regexp_by_list,
|
15
14
|
:prefix_map_by_list, :prefix_map_by_chunkname
|
data/lib/card/content/clean.rb
CHANGED
@@ -13,7 +13,9 @@ class Card
|
|
13
13
|
"a" => %w[href title target],
|
14
14
|
"img" => %w[src alt title],
|
15
15
|
"code" => ["lang"],
|
16
|
-
"blockquote" => ["cite"]
|
16
|
+
"blockquote" => ["cite"],
|
17
|
+
"ol" => ["type"],
|
18
|
+
"ul" => ["type"]
|
17
19
|
)
|
18
20
|
|
19
21
|
if Cardio.config.allow_inline_styles
|
@@ -86,7 +88,7 @@ class Card
|
|
86
88
|
|
87
89
|
rest_value = match[0]
|
88
90
|
if attrib == "class"
|
89
|
-
rest_value.split(/\s+/).
|
91
|
+
rest_value.split(/\s+/).grep(/^w-/i).join " "
|
90
92
|
else
|
91
93
|
rest_value
|
92
94
|
end
|
@@ -51,8 +51,7 @@ class Card
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def check_exclude_and_disjunction_pattern list
|
54
|
-
list.each_with_index.
|
55
|
-
element, index = pair
|
54
|
+
list.each_with_index.with_object([[], []]) do |(element, index), res|
|
56
55
|
if element.match? @disjunction_pattern
|
57
56
|
res[1] << { chunk_index: index, element: element, type: :disjunction }
|
58
57
|
elsif element.match? @exclude_pattern
|
data/lib/card/content/diff.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class Card
|
4
4
|
class Content
|
5
|
+
# handle comparisons of card content
|
5
6
|
class Diff
|
6
7
|
class << self
|
7
8
|
def complete a, b, opts={}
|
@@ -57,7 +58,7 @@ class Card
|
|
57
58
|
when :html
|
58
59
|
opts[:exclude] = /^</
|
59
60
|
when :text
|
60
|
-
opts[:reject] =
|
61
|
+
opts[:reject] = /^</
|
61
62
|
opts[:postprocess] = proc { |word| word.gsub("\n", "<br>") }
|
62
63
|
when :pointer
|
63
64
|
opts[:preprocess] = proc { |word| word.gsub("[[", "").gsub("]]", "<br>") }
|
data/lib/card/content/parser.rb
CHANGED
@@ -38,7 +38,7 @@ class Card
|
|
38
38
|
@chunk_class = Chunk.find_class_by_prefix @prefix, @chunk_list
|
39
39
|
|
40
40
|
# get the chunk class from the prefix
|
41
|
-
content_slice = @content[@position
|
41
|
+
content_slice = @content[@position..]
|
42
42
|
@chunk_class.full_match content_slice, @prefix
|
43
43
|
end
|
44
44
|
|
@@ -59,7 +59,7 @@ class Card
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def match_prefix prefix_regexp
|
62
|
-
prefix_match = @content[@position
|
62
|
+
prefix_match = @content[@position..].match(prefix_regexp)
|
63
63
|
if prefix_match
|
64
64
|
@prefix = prefix_match[0]
|
65
65
|
# prefix of matched chunk
|
@@ -79,10 +79,8 @@ class Card
|
|
79
79
|
def record_chunk
|
80
80
|
@position += (@match.end(0) - @offset.to_i)
|
81
81
|
# move scanning position up to end of chunk
|
82
|
-
|
83
|
-
|
84
|
-
false
|
85
|
-
else
|
82
|
+
|
83
|
+
if @chunk_class.context_ok? @content, @chunk_start
|
86
84
|
@chunks << @interval_string unless @interval_string.empty?
|
87
85
|
@interval_string = ""
|
88
86
|
# add the nonchunk string to the chunk list and
|
@@ -93,13 +91,16 @@ class Card
|
|
93
91
|
# NOTE: that the end of the chunk was the last place where a
|
94
92
|
# chunk was found (so far)
|
95
93
|
true
|
94
|
+
else
|
95
|
+
# make sure there aren't contextual reasons for ignoring this chunk
|
96
|
+
false
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
99
100
|
def handle_remainder
|
100
101
|
if @chunks.any? && @last_position < @content.size
|
101
102
|
# handle any leftover nonchunk string at the end of content
|
102
|
-
@chunks << @content[@last_position
|
103
|
+
@chunks << @content[@last_position..]
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
data/lib/card/content.rb
CHANGED
@@ -73,7 +73,7 @@ class Card
|
|
73
73
|
when String then return # no chunks
|
74
74
|
else
|
75
75
|
Rails.logger.warn "unrecognized type for #each_chunk: " \
|
76
|
-
"
|
76
|
+
"#{self.class} #{__getobj__.class}"
|
77
77
|
return
|
78
78
|
end
|
79
79
|
send(iterator) { |item| yield item if item.is_a?(Chunk::Abstract) }
|
data/lib/card/director.rb
CHANGED
@@ -208,7 +208,7 @@ class Card
|
|
208
208
|
def to_s level=1
|
209
209
|
str = @card.name.to_s.clone
|
210
210
|
if @subdirectors.present?
|
211
|
-
subs = subdirectors.map { |d| " " * level + d.to_s(level + 1) }.join "\n"
|
211
|
+
subs = subdirectors.map { |d| (" " * level) + d.to_s(level + 1) }.join "\n"
|
212
212
|
str << "\n#{subs}"
|
213
213
|
end
|
214
214
|
str
|
data/lib/card/env/location.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
class Card
|
2
2
|
module Env
|
3
|
+
# shared methods for handling paths/urls
|
3
4
|
module Location
|
4
5
|
# card_path makes a relative path site-absolute (if not already)
|
5
|
-
# card_url makes it a full url (if not already)
|
6
|
-
|
7
6
|
def card_path rel_path
|
8
7
|
unless rel_path.is_a? String
|
9
|
-
Rails.logger.warn "Pass only strings to card_path. "\
|
8
|
+
Rails.logger.warn "Pass only strings to card_path. " \
|
10
9
|
"(#{rel_path} = #{rel_path.class})"
|
11
10
|
end
|
12
11
|
if rel_path.match? %r{^(https?:)?/}
|
@@ -16,6 +15,7 @@ class Card
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
18
|
+
# card_url makes it a full url (if not already)
|
19
19
|
def card_url rel
|
20
20
|
rel.match?(/^https?:/) ? rel : "#{Env.origin}#{card_path rel}"
|
21
21
|
end
|
@@ -13,19 +13,11 @@ class Card
|
|
13
13
|
return unless save_location?(card)
|
14
14
|
|
15
15
|
discard_locations_for card
|
16
|
-
|
17
|
-
Env::Location.card_path card.name.url_key
|
18
|
-
location_history.push previous_location
|
19
|
-
end
|
20
|
-
|
21
|
-
def save_location? card
|
22
|
-
!Env.ajax? && Env.html? && card.known? && (card.codename != :signin)
|
16
|
+
location_history.push location_for_history(card)
|
23
17
|
end
|
24
18
|
|
25
19
|
def previous_location
|
26
|
-
|
27
|
-
|
28
|
-
session[:previous_location] ||= location_history.last
|
20
|
+
location_history&.last
|
29
21
|
end
|
30
22
|
|
31
23
|
def discard_locations_for card
|
@@ -35,7 +27,6 @@ class Card
|
|
35
27
|
url_key.to_name.key == card.key
|
36
28
|
end
|
37
29
|
end.compact
|
38
|
-
session[:previous_location] = nil
|
39
30
|
end
|
40
31
|
|
41
32
|
def save_interrupted_action uri
|
@@ -46,9 +37,19 @@ class Card
|
|
46
37
|
session.delete :interrupted_action
|
47
38
|
end
|
48
39
|
|
40
|
+
private
|
41
|
+
|
42
|
+
def location_for_history card
|
43
|
+
Env::Location.card_path card.name.url_key
|
44
|
+
end
|
45
|
+
|
49
46
|
def url_key_for_location location
|
50
47
|
%r{/([^/]*$)} =~ location ? Regexp.last_match[1] : nil
|
51
48
|
end
|
49
|
+
|
50
|
+
def save_location? card
|
51
|
+
!Env.ajax? && Env.html? && card.known? && (card.codename != :signin)
|
52
|
+
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -14,11 +14,11 @@ class Card
|
|
14
14
|
card(name_context) || @target || Card.fetch(name_context)
|
15
15
|
end
|
16
16
|
|
17
|
-
# TODO: refactor to use cardish
|
18
17
|
def mark= value
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
if (id = Card.id value)
|
19
|
+
@id = id
|
20
|
+
elsif value.is_a? Card
|
21
|
+
@card = value
|
22
22
|
else
|
23
23
|
self.target = value
|
24
24
|
end
|
data/lib/card/env/support.rb
CHANGED
@@ -21,10 +21,32 @@ class Card
|
|
21
21
|
def reset_session
|
22
22
|
if session.is_a? Hash
|
23
23
|
@session = {}
|
24
|
-
|
25
|
-
|
24
|
+
elsif request
|
25
|
+
update_cookie_setting false
|
26
|
+
controller.reset_session
|
27
|
+
# destroy_cookie unless Cardio.config.anonymous_cookies
|
26
28
|
end
|
27
29
|
end
|
30
|
+
|
31
|
+
def update_cookie_setting is_anonymous=true
|
32
|
+
return unless request && !Cardio.config.anonymous_cookies
|
33
|
+
|
34
|
+
request.session_options[:drop] = is_anonymous
|
35
|
+
end
|
36
|
+
|
37
|
+
# private
|
38
|
+
|
39
|
+
# FIXME: not working
|
40
|
+
# the response generally works to destroy a cookie, but
|
41
|
+
# the deletion doesn't appear to work in a redirect. Since signing out
|
42
|
+
# has a redirect response, we're still left with a cookie
|
43
|
+
# def destroy_cookie
|
44
|
+
# app = Cardio.application
|
45
|
+
# app_name = app.class.name ? app.railtie_name.chomp("_application") : ""
|
46
|
+
# expire_in_past = "expires=Thu, 01 Jan 1970 00:00:00 GMT;"
|
47
|
+
# controller.response.set_header "SET-COOKIE",
|
48
|
+
# "_#{app_name}_session=deleted; #{expire_in_past}"
|
49
|
+
# end
|
28
50
|
end
|
29
51
|
end
|
30
52
|
end
|
data/lib/card/error.rb
CHANGED
data/lib/card/fetch/store.rb
CHANGED
data/lib/card/format/error.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
class Card
|
2
2
|
class Format
|
3
|
+
# missing methods may be render calls or action view methods
|
4
|
+
# these methods sort that out
|
3
5
|
module MethodDelegation
|
4
6
|
RENDER_METHOD_RE =
|
5
7
|
/^
|
@@ -40,7 +42,7 @@ class Card
|
|
40
42
|
if (match = api_render? method)
|
41
43
|
api_render match, opts
|
42
44
|
else
|
43
|
-
delegate_to_action_view
|
45
|
+
delegate_to_action_view method, opts, &proc
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
@@ -66,9 +68,9 @@ class Card
|
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
|
-
def delegate_to_action_view method, opts,
|
70
|
-
|
71
|
-
response = action_view.send method, *opts, &
|
71
|
+
def delegate_to_action_view method, opts, &old_proc
|
72
|
+
new_proc = proc { |*a| raw yield(*a) } if old_proc
|
73
|
+
response = action_view.send method, *opts, &new_proc
|
72
74
|
response.is_a?(String) ? action_view.raw(response) : response
|
73
75
|
end
|
74
76
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class Card
|
2
2
|
class Format
|
3
|
+
# handles format registry, tracking which formats (html, css, json, etc) are
|
4
|
+
# available
|
3
5
|
module Registration
|
4
6
|
def register format
|
5
7
|
registered << format.to_s
|
@@ -7,11 +9,11 @@ class Card
|
|
7
9
|
end
|
8
10
|
|
9
11
|
def new card, opts={}
|
10
|
-
if self
|
11
|
-
super
|
12
|
-
else
|
12
|
+
if self == Format
|
13
13
|
klass = format_class opts
|
14
14
|
self == klass ? super : klass.new(card, opts)
|
15
|
+
else
|
16
|
+
super
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|