card 1.108.1 → 1.109.1
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/config/locales/es.yml +2 -3
- data/db/seeds.rb +0 -1
- data/lib/card/auth/current.rb +8 -6
- data/lib/card/auth/permissions.rb +1 -1
- data/lib/card/auth/proxy.rb +2 -2
- data/lib/card/auth/setup.rb +2 -2
- data/lib/card/auth.rb +7 -6
- data/lib/card/cache/all.rb +1 -1
- 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 +1 -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 +20 -20
- data/lib/card/env/success/target.rb +4 -4
- data/lib/card/env/support.rb +25 -2
- data/lib/card/error.rb +1 -0
- data/lib/card/fetch/store.rb +1 -1
- data/lib/card/format/error.rb +13 -2
- data/lib/card/format/method_delegation.rb +6 -4
- data/lib/card/format/registration.rb +5 -3
- data/lib/card/format/render.rb +51 -47
- data/lib/card/format/wrapper.rb +1 -0
- data/lib/card/lexicon.rb +5 -2
- data/lib/card/mailer.rb +1 -14
- data/lib/card/name/all/parts.rb +1 -1
- data/lib/card/name/all.rb +5 -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/card_query/relational_attributes.rb +1 -1
- data/lib/card/query/card_query/run.rb +5 -1
- data/lib/card/query/clause.rb +1 -0
- data/lib/card/query/join.rb +3 -3
- data/lib/card/query/sql_statement.rb +7 -1
- data/lib/card/query.rb +1 -1
- 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 +9 -3
- data/lib/card/view/cache.rb +17 -15
- 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 +2 -2
- data/lib/card/view/options.rb +1 -0
- data/lib/card/view.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 +7 -9
- 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 +2 -2
- 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/de.yml +1 -1
- data/mod/core/config/locales/en.yml +2 -1
- data/mod/core/data/fixtures/real/cards.yml +1 -1
- data/mod/core/data/real.yml +1 -1
- data/mod/core/data/recode.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/mod.rake +1 -1
- data/mod/core/lib/tasks/card/seed.rake +2 -1
- data/mod/core/lib/tasks/card.rake +48 -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 -1
- 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 +13 -16
- data/mod/core/set/all/type.rb +3 -1
- 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/admin_spec.rb +1 -1
- data/mod/core/spec/set/all/trash_spec.rb +9 -9
- 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: bbc2d91a4b4e085e2dd391ba227f58cefe096a055354fb5850d5a983db9b389f
|
4
|
+
data.tar.gz: 0c8ced971a5730ae8f4898b967fb3063beb0ba4415957ead6c963619eabd7674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e92113ce1c6777355ba6f4e0d81936c0b2a80ff8718b50acca6782b9f029268e087183fc2a77c179805a4bb7e12a3b54f025acab6acde19df470f2215e51d1d
|
7
|
+
data.tar.gz: abba860d2387151ba48e3690fddb88c552e31c7770aa7a37fc75006db47f667a422a8632950e2e162742428f461144330a4d0e2487637c99889312106a07d18c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.19.1
|
@@ -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/config/locales/es.yml
CHANGED
@@ -133,7 +133,7 @@ es:
|
|
133
133
|
type:
|
134
134
|
error_cant_change_errors: "de %{name} no se puede cambiar; creando nuevos errores %{type_id}: %{error_messages}"
|
135
135
|
error_no_such_type: No hay tal tipo
|
136
|
-
|
136
|
+
error_structured: no se puede cambiar porque %{name} es una plantilla dificil de %{type_name}
|
137
137
|
utils:
|
138
138
|
exception_almost_deleted: Se evitó de forma muy estrecha eliminar el archivo actual
|
139
139
|
set_pattern:
|
@@ -302,8 +302,7 @@ es:
|
|
302
302
|
unsupported_view: vista (%{view}) no soportado para %{cardname}
|
303
303
|
not_found_named: No pudo encontrar %{cardname}.
|
304
304
|
not_found_no_name: la tarjeta solicitada
|
305
|
-
server_error: "\
|
306
|
-
se_hitch: 'Wagn Hitch :('
|
305
|
+
server_error: "\nError del Servidor. Yuck, perdon por eso.\nPara decirnos más y seguir la solución,\nagregue un ticket de soporte en %{ticket_link}\n"
|
307
306
|
se_sorry: Error del Servidor. Yuck, perdón por eso.
|
308
307
|
se_ticket: <a href="%{ticket_link}">Agregue un ticket de soporte</a> para decirnos más y seguir la solución.
|
309
308
|
denial: Permiso denegado
|
data/db/seeds.rb
CHANGED
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_session_options
|
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/proxy.rb
CHANGED
@@ -23,9 +23,9 @@ class Card
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
# operate with the permissions of
|
26
|
+
# operate with the permissions of DeckoBot (administrator)
|
27
27
|
def as_bot &block
|
28
|
-
as Card::
|
28
|
+
as Card::DeckoBotID, &block
|
29
29
|
end
|
30
30
|
|
31
31
|
# id of proxy user
|
data/lib/card/auth/setup.rb
CHANGED
@@ -41,8 +41,8 @@ class Card
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def user_account_cql
|
44
|
-
# every deck starts with two accounts:
|
45
|
-
{ right: :account, creator_id: ["ne", Card::
|
44
|
+
# every deck starts with two accounts: DeckoBot and Anonymous
|
45
|
+
{ right: :account, creator_id: ["ne", Card::DeckoBotID] }
|
46
46
|
end
|
47
47
|
|
48
48
|
def user_account_count
|
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
|
data/lib/card/cache/all.rb
CHANGED
@@ -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
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
# codename retrieval methods for cards
|
4
3
|
class Card
|
5
4
|
# @return [Symbol]
|
6
5
|
def codename
|
@@ -82,6 +81,7 @@ class Card
|
|
82
81
|
def reset_cache
|
83
82
|
@codehash = nil
|
84
83
|
::Card.cache.delete "CODENAMES"
|
84
|
+
generate_id_constants
|
85
85
|
end
|
86
86
|
|
87
87
|
# @param codename [Symbol, String]
|
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
|
@@ -10,32 +10,20 @@ class Card
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def save_location card
|
13
|
-
return unless save_location?
|
13
|
+
return unless save_location? card
|
14
14
|
|
15
|
-
|
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)
|
15
|
+
location = request ? request.original_url : location_for_history(card)
|
16
|
+
location_history.push(location).uniq!
|
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
|
32
|
-
|
33
|
-
|
34
|
-
if (url_key = url_key_for_location(loc))
|
35
|
-
url_key.to_name.key == card.key
|
36
|
-
end
|
24
|
+
session[:history] = location_history.reject do |l|
|
25
|
+
location_cardname(l) == card.name
|
37
26
|
end.compact
|
38
|
-
session[:previous_location] = nil
|
39
27
|
end
|
40
28
|
|
41
29
|
def save_interrupted_action uri
|
@@ -46,8 +34,20 @@ class Card
|
|
46
34
|
session.delete :interrupted_action
|
47
35
|
end
|
48
36
|
|
49
|
-
|
50
|
-
|
37
|
+
private
|
38
|
+
|
39
|
+
def location_for_history card
|
40
|
+
Env::Location.card_path card.name.url_key
|
41
|
+
end
|
42
|
+
|
43
|
+
def location_cardname location
|
44
|
+
URI.parse(location).path.sub(/^\//, "").sub(/\/.*$/, "")&.cardname
|
45
|
+
end
|
46
|
+
|
47
|
+
def save_location? card
|
48
|
+
# return false unless Auth.signed_in? || Cardio.config.allow_anonymous_cookies
|
49
|
+
|
50
|
+
!Env.ajax? && Env.html? && card.known? && (card.codename != :signin)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
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
|