card 1.104.1 → 1.104.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae1fc116c9fb870d1d6b8a27a566d7aca5313f249b4bf4784209b677a8589ab7
4
- data.tar.gz: b8ede92d2f96959e197a87fc8a4d3af678a0bfc1426683a8af8c29545444e224
3
+ metadata.gz: c315f9b25036d3cfe0a8689bf7f8bde71a68715a4dbacf742e5d1cffe999e8f5
4
+ data.tar.gz: fb9f8e44f73b7a8236d14a33b04ba653adaac3eadad49db3abb5bfbb11d03eb6
5
5
  SHA512:
6
- metadata.gz: a192861e2d5fec66e431f55a80aaa840a45d77b4ebc10a2c16bca1af4a51a249f3cd655877c82c8ddc51e74c356a8c5da75e02347b1c80b1d6fb01e7c79bb808
7
- data.tar.gz: 7ec8399cc23e2339d03fab541614347aa37110f12dcc0bf73fd13dc93bc98bd63e4a46434dbbcad7c09ecc6efeef2aad93963a8ed62d975965d9e5c2fb483c56
6
+ metadata.gz: 3e72cb6beab5d390e721a574d861cc4de210888fbc2f6b9a1f59f30f7b3c4f578e70871f6418dd31d0ed6264192bbd05d74f91cf877f5938312fc0d1648a3c58
7
+ data.tar.gz: 47d0f5bbefbeabdf939a65074e91f46f3b917c6c4f9508d7bb63ed012f1e6e2ddc71fbe69bed6482139fc11f5c009f10e2be7704d6350091535ce6c688e042fc
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.14.1
1
+ 0.14.2
@@ -38,7 +38,6 @@ class UserDataToCards < Cardio::Migration::Core
38
38
  Card[oldname].update! name: newname
39
39
 
40
40
  puts "importing all user details (for those not in trash) into +*account attributes"
41
- Card::Env[:no_password_encryptions] = true
42
41
  User.all.each do |user|
43
42
  base = Card[user.card_id]
44
43
  next unless base && !base.trash
@@ -12,16 +12,12 @@ class Card
12
12
  if rel_path.match? %r{^(https?:)?/}
13
13
  rel_path
14
14
  else
15
- "#{Card.config.relative_url_root}/#{rel_path}"
15
+ "#{relative_url_root}/#{rel_path}"
16
16
  end
17
17
  end
18
18
 
19
19
  def card_url rel
20
- rel.match?(/^https?:/) ? rel : "#{protocol_and_host}#{card_path rel}"
21
- end
22
-
23
- def protocol_and_host
24
- Card.config.protocol_and_host || "#{Env[:protocol]}#{Env[:host]}"
20
+ rel.match?(/^https?:/) ? rel : "#{Env.origin}#{card_path rel}"
25
21
  end
26
22
 
27
23
  def cardname_from_url url
@@ -31,12 +27,16 @@ class Card
31
27
  m ? Card::Name[m[:mark]] : nil
32
28
  end
33
29
 
30
+ def relative_url_root
31
+ Cardio.config.relative_url_root
32
+ end
33
+
34
34
  private
35
35
 
36
36
  def cardname_from_url_regexp
37
- return unless Env[:host]
37
+ return unless Env.origin
38
38
 
39
- %r{#{Regexp.escape Env[:host]}/(?<mark>[^?]+)}
39
+ %r{#{Regexp.escape Env.origin}/(?<mark>[^?]+)}
40
40
  end
41
41
 
42
42
  extend Location # allows calls on Location constant, eg Location.card_url
@@ -0,0 +1,33 @@
1
+ class Card
2
+ module Env
3
+ # These methods are all handled in serialization and are thus preserved for the
4
+ # integrate_with_delay phase
5
+ module Serializable
6
+ def ip
7
+ request&.remote_ip
8
+ end
9
+
10
+ def protocol
11
+ request&.protocol
12
+ end
13
+
14
+ def host
15
+ request&.host
16
+ end
17
+
18
+ def origin
19
+ Cardio.config.deck_origin || "#{protocol}#{request&.host_with_port}"
20
+ end
21
+
22
+ def ajax
23
+ request&.xhr? || params[:simulate_xhr]
24
+ end
25
+ alias_method :ajax?, :ajax
26
+
27
+ def html
28
+ !controller || params[:format].in?([nil, "html"])
29
+ end
30
+ alias_method :html?, :html
31
+ end
32
+ end
33
+ end
@@ -2,13 +2,15 @@ class Card
2
2
  module Env
3
3
  # serializing environment (eg for delayed jobs)
4
4
  module Serialization
5
- SERIALIZABLE_ATTRIBUTES = ::Set.new %i[
6
- main_name params ip ajax html host protocol salt
7
- ]
5
+ def serialize
6
+ @serialized = Serializable.instance_methods.each_with_object({}) do |attr, hash|
7
+ hash[attr] = send attr
8
+ end
9
+ end
8
10
 
9
11
  # @param serialized_env [Hash]
10
12
  def with serialized_env
11
- tmp_env = serialize if @env
13
+ tmp_env = serialize
12
14
  @env ||= {}
13
15
  @env.update serialized_env
14
16
  yield
@@ -16,8 +18,14 @@ class Card
16
18
  @env.update tmp_env if tmp_env
17
19
  end
18
20
 
19
- def serialize
20
- @env.select { |k, _v| SERIALIZABLE_ATTRIBUTES.include?(k) }
21
+ # supercede serializable methods when serialized values are available
22
+ #
23
+ # note - at present this must be done manually when adding serializable methods
24
+ # in mods.
25
+ Serializable.instance_methods.each do |attrib|
26
+ define_method attrib do
27
+ @serialized&.key?(attrib) ? @serialized[attrib] : super()
28
+ end
21
29
  end
22
30
  end
23
31
  end
@@ -4,7 +4,7 @@ class Card
4
4
  module SlotOptions
5
5
  def slot_opts
6
6
  # FIXME: upgrade to safe parameters
7
- self[:slot_opts] ||= interpret_slot_options
7
+ @slot_opts ||= interpret_slot_options
8
8
  end
9
9
 
10
10
  private
@@ -0,0 +1,30 @@
1
+ class Card
2
+ module Env
3
+ # utility methods for Card::Env
4
+ module Support
5
+ def with_params hash
6
+ old_params = params.clone
7
+ params.merge! hash
8
+ yield
9
+ ensure
10
+ @params = old_params
11
+ end
12
+
13
+ def hash hashish
14
+ case hashish
15
+ when Hash then hashish.clone
16
+ when ActionController::Parameters then hashish.to_unsafe_h
17
+ else {}
18
+ end
19
+ end
20
+
21
+ def reset_session
22
+ if session.is_a? Hash
23
+ @session = {}
24
+ else
25
+ controller&.reset_session
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/card/env.rb CHANGED
@@ -5,90 +5,35 @@ class Card
5
5
  # Env can differ for each request; Card.config should not.
6
6
  module Env
7
7
  extend LocationHistory
8
- extend RequestAssignments
9
8
  extend SlotOptions
9
+ extend Support
10
+ extend Serializable
10
11
  extend Serialization
11
12
 
12
13
  class << self
13
- def reset args={}
14
- @env = { main_name: nil }
15
- return self unless (c = args[:controller])
14
+ attr_accessor :controller, :main_name, :params
15
+ attr_writer :session
16
16
 
17
- self[:controller] = c
18
- self[:session] = c.request.session
19
- self[:params] = c.params
20
- self[:ip] = c.request.remote_ip
21
- self[:ajax] = assign_ajax(c)
22
- self[:html] = assign_html(c)
23
- self[:host] = assign_host(c)
24
- self[:protocol] = assign_protocol(c)
25
- self
26
- end
27
-
28
- def [] key
29
- @env[key.to_sym]
30
- end
31
-
32
- def []= key, value
33
- @env[key.to_sym] = value
34
- end
35
-
36
- def params
37
- self[:params] ||= {} # .with_indifferent_access
38
- end
39
-
40
- def with_params hash
41
- old_params = params.clone
42
- params.merge! hash
43
- yield
44
- ensure
45
- self[:params] = old_params
46
- end
47
-
48
- def hash hashish
49
- case hashish
50
- when Hash then hashish.clone
51
- when ActionController::Parameters then hashish.to_unsafe_h
52
- else {}
53
- end
17
+ def request
18
+ controller&.request
54
19
  end
55
20
 
56
21
  def session
57
- self[:session] ||= {}
22
+ @session ||= request&.session || {}
58
23
  end
59
24
 
60
- def reset_session
61
- if session.is_a? Hash
62
- self[:session] = {}
63
- else
64
- self[:controller]&.reset_session
65
- end
25
+ def reset controller=nil
26
+ @controller = controller
27
+ @params = controller&.params || {}
28
+ @session = @success = @serialized = @slot_opts = nil
66
29
  end
67
30
 
68
31
  def success cardname=nil
69
- self[:success] ||= Env::Success.new(cardname, params[:success])
32
+ @success ||= Env::Success.new(cardname, params[:success])
70
33
  end
71
34
 
72
35
  def localhost?
73
- self[:host]&.match?(/^localhost/)
74
- end
75
-
76
- def ajax?
77
- self[:ajax]
78
- end
79
-
80
- def html?
81
- !self[:controller] || self[:html]
82
- end
83
-
84
- private
85
-
86
- def method_missing method_id, *args
87
- case args.length
88
- when 0 then self[method_id]
89
- when 1 then self[method_id] = args[0]
90
- else super
91
- end
36
+ host&.match?(/^localhost/)
92
37
  end
93
38
  end
94
39
  end
data/lib/card/format.rb CHANGED
@@ -70,7 +70,7 @@ class Card
70
70
  end
71
71
 
72
72
  def controller
73
- @controller || Env[:controller] ||= CardController.new
73
+ @controller || Env.controller ||= CardController.new
74
74
  end
75
75
 
76
76
  def mime_type
@@ -17,9 +17,6 @@ module Cardio
17
17
  config.google_analytics_tracker_key = nil
18
18
  config.google_analytics_four_key = nil
19
19
 
20
- config.override_host = nil
21
- config.override_protocol = nil
22
-
23
20
  config.no_authentication = false
24
21
  config.files_web_path = "files"
25
22
 
@@ -64,7 +61,8 @@ module Cardio
64
61
  config.file_storage = :local
65
62
  config.file_buckets = {}
66
63
  config.file_default_bucket = nil
67
- config.protocol_and_host = nil
64
+
65
+ config.deck_origin = nil
68
66
 
69
67
  config.rich_text_editor = :tinymce
70
68
 
@@ -6,7 +6,7 @@ module Cardio
6
6
  CARD_MINOR = { 0 => 90, 1 => 1000 }.freeze # can remove and hardcode after 1.0
7
7
 
8
8
  def release
9
- @version ||= File.read(File.expand_path("../../../card/VERSION", __dir__)).strip
9
+ @version ||= File.read(File.expand_path("../../VERSION", __dir__)).strip
10
10
  end
11
11
 
12
12
  def card_release
data/lib/cardio.rb CHANGED
@@ -45,5 +45,13 @@ module Cardio
45
45
  def mods
46
46
  Mod.dirs.mods
47
47
  end
48
+
49
+ def with_config tmp
50
+ keep = tmp.keys.each_with_object({}) { |k, h| h[k] = config.send k }
51
+ tmp.each { |k, v| config.send "#{k}=", v }
52
+ yield
53
+ ensure
54
+ keep.each { |k, v| config.send "#{k}=", v }
55
+ end
48
56
  end
49
57
  end
@@ -4,55 +4,75 @@ require "decko/application"
4
4
 
5
5
  module <%= app_const_base %>
6
6
  class Application < Decko::Application
7
- config.performance_logger = nil
8
-
9
7
  # Decko inherits most Ruby-on-Rails configuration options.
10
8
  # See http://guides.rubyonrails.org/configuring.html
11
9
 
12
10
  # EMAIL
13
- # Email is not turned on by default. To turn it on, you need to change the
14
- # following to `true` and then add configuration specific to your site.
15
- # Learn more:
11
+ # Outgoing email, which is used by a lot of account processes (signup,
12
+ # forgot password, notifications, etc) is not turned on by default.
13
+ # To turn it on, you need to change the following to `true` and add
14
+ # configuration specific to your site.
15
+ #
16
+ # Learn more about Rails email configuration:
16
17
  # https://guides.rubyonrails.org/configuring.html#configuring-action-mailer
17
-
18
+ #
18
19
  config.action_mailer.perform_deliveries = false
19
20
  # config.action_mailer.delivery_method = ...
20
21
  # config.action_mailer.smtp_settings = ...
21
-
22
- # Example configuration for mailcatcher, a simple smtp server.
23
- # See http://mailcatcher.me for more information
22
+ #
23
+ # Example configuration for mailcatcher, a simple development-friendly
24
+ # smtp server (but not an option for production sites):
25
+ #
24
26
  # config.action_mailer.delivery_method = :smtp
25
27
  # config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
26
-
27
-
28
- # BACKGROUND
29
- # Decko lets you run some card events (like follower notifications) in the
30
- # background. This is off by default but can be turned on by changing the
31
- # `delaying` setting to `true`
32
- config.active_job.queue_adapter = :delayed_job
33
- config.delaying = false
34
-
28
+ #
29
+ # Learn more about mailcatcher:
30
+ # http://mailcatcher.me for more information
35
31
 
36
32
  # CACHING
33
+ # Cards make heavy use of caching to improve performance. Caching storage
34
+ # options include: file_store (default), memory_store, mem_cache_store...
35
+ #
37
36
  # config.cache_store = :file_store, "tmp/cache"
38
- # determines caching mechanism. options include: file_store, memory_store,
39
- # mem_cache_store...
40
37
  #
41
38
  # for production, we highly recommend memcache
42
- # here's a sample configuration for use with the dalli gem
39
+ # here's a sample configuration for use with the "dalli" gem
40
+ # (which you can install by adding `gem "dalli"` to your Gemfile and then
41
+ # running `bundle install`.
42
+ #
43
43
  # config.cache_store = :mem_cache_store, []
44
-
44
+ #
45
+ # Learn more about Rails caching configuration:
46
+ # https://guides.rubyonrails.org/caching_with_rails.html#cache-stores
45
47
 
46
48
  # FILES
47
- # config.paths["files"] = "files"
48
- # directory in which uploaded files are actually stored. (eg Image and File cards)
49
-
49
+ # Some card content (eg for Image and File cards) is stored in files
50
+ # rather than in the database.
51
+ #
52
+ # Most will want to set file_storage to use either :local or :cloud.
53
+ #
54
+ # By default storage is set to :local, and files are stored in the "files"
55
+ # directory in the deck root.
56
+ #
50
57
  # config.file_storage = :local
51
- # File storage options (see http://decko.org/file_storage_options)
52
- # options include: local, cloud, web, coded
53
- # defaults to local
54
- # For cloud storage use the following config options and add the corresponding fog gem
55
- # for your cloud service. For example for AWS add "fog-aws" to your Gemfile.
58
+ # config.paths["files"] = "files"
59
+ #
60
+ <% if platypus? %>
61
+ config.file_buckets = {
62
+ test_bucket: {
63
+ provider: "AWS",
64
+ aws_access_key_id: ENV["TEST_BUCKET_AWS_ACCESS_KEY_ID"],
65
+ aws_secret_access_key: ENV["TEST_BUCKET_AWS_SECRET_ACCESS_KEY"],
66
+ region: "us-east-1"
67
+ }
68
+ }
69
+ <% else %>
70
+ # For cloud storage use the following config options and add the
71
+ # corresponding fog gem for your cloud service. For example for AWS add
72
+ # `gem "fog-aws"` to your Gemfile. IMPORTANT: also see protocol and host
73
+ # below.
74
+ #
75
+ # config.file_storage = :cloud
56
76
  # config.file_default_bucket = :my_bucket
57
77
  # config.file_buckets = {
58
78
  # my_bucket: {
@@ -63,7 +83,7 @@ module <%= app_const_base %>
63
83
  # aws_access_key_id: "key", # required
64
84
  # aws_secret_access_key: "secret-key", # required
65
85
  # use_iam_profile: true, # optional, defaults to false
66
- # region: "eu-central-1", # optional, defaults to "us-east-1"
86
+ # region: "eu-central-1", # optional, defaults to "us-east-1"
67
87
  # host: "s3.example.com", # optional, defaults to nil
68
88
  # endpoint: "https://s3.example.com:8080" # optional, defaults to nil
69
89
  # },
@@ -76,32 +96,31 @@ module <%= app_const_base %>
76
96
  # # option is needed
77
97
  # }
78
98
  # }
99
+ #
100
+ # Learn more about file storage options:
101
+ # http://decko.org/file_storage_options)
102
+ <% end %>
103
+
104
+ # ORIGIN AND RELATIVE_ROOT
105
+ # The following option is used when generating absolute links and
106
+ # are necessary when using cloud file storage, especially when using
107
+ # commands (like `decko update`) in a non-web context.
108
+ #
109
+ # Without it your generated CSS (which is stored on the cloud) will not
110
+ # be able to find permanent resources (which are stored with the deck).
111
+ # This usually shows up as broken icons.
112
+ #
113
+ # config.deck_origin = "https://mysite.com"
114
+ #
115
+ # If your deck is not at the url's root but in a subdirectory, such as
116
+ # mysite.com/mydeck, then you must configure the relative_url_root:
117
+ #
118
+ # config.relative_url_root = "/mydeck"
79
119
 
80
120
  # MISCELLANEOUS
121
+ # You can use the following to disallow creating, updating, and deleting
122
+ # cards:
123
+ #
81
124
  # config.read_only = true
82
- # defaults to false
83
- # disallows creating, updating, and deleting cards.
84
-
85
- # config.paths["mod"] << "my-mod-dir"
86
- # add a new directory for code customizations, or "mods"
87
-
88
- # config.allow_inline_styles = false
89
- # don't strip style attributes (not recommended)
90
-
91
- # config.override_host = "example.com"
92
- # overrides host auto-detected from web requests
93
-
94
- # config.override_protocol = "https"
95
- # overrides protocol auto-detected from web requests
96
- <% if platypus? %>
97
- config.file_buckets = {
98
- test_bucket: {
99
- provider: "AWS",
100
- aws_access_key_id: ENV["TEST_BUCKET_AWS_ACCESS_KEY_ID"],
101
- aws_secret_access_key: ENV["TEST_BUCKET_AWS_SECRET_ACCESS_KEY"],
102
- region: "us-east-1"
103
- }
104
- }
105
- <% end %>
106
125
  end
107
126
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.104.1
4
+ version: 1.104.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-01-04 00:00:00.000000000 Z
13
+ date: 2022-01-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cardname
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.14.1
21
+ version: 0.14.2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 0.14.1
28
+ version: 0.14.2
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -662,11 +662,12 @@ files:
662
662
  - lib/card/env.rb
663
663
  - lib/card/env/location.rb
664
664
  - lib/card/env/location_history.rb
665
- - lib/card/env/request_assignments.rb
665
+ - lib/card/env/serializable.rb
666
666
  - lib/card/env/serialization.rb
667
667
  - lib/card/env/slot_options.rb
668
668
  - lib/card/env/success.rb
669
669
  - lib/card/env/success/target.rb
670
+ - lib/card/env/support.rb
670
671
  - lib/card/error.rb
671
672
  - lib/card/fetch.rb
672
673
  - lib/card/fetch/all.rb
@@ -1,24 +0,0 @@
1
- class Card
2
- module Env
3
- # environmental variables assigned based on request
4
- module RequestAssignments
5
- private
6
-
7
- def assign_ajax c
8
- c.request.xhr? || c.request.params[:simulate_xhr]
9
- end
10
-
11
- def assign_html c
12
- [nil, "html"].member?(c.params[:format])
13
- end
14
-
15
- def assign_host c
16
- Card.config.override_host || c.request.env["HTTP_HOST"]
17
- end
18
-
19
- def assign_protocol c
20
- Card.config.override_protocol || c.request.protocol
21
- end
22
- end
23
- end
24
- end