card 1.99.2 → 1.99.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b41a6b143142f0b5adb047f9a9363d06e6d686ec47ebf97a22dc12f59c1a2ff1
4
- data.tar.gz: 71f0a7d1e94054844efb5002c8e1d1667845d72e15db26d86653de51b26620eb
3
+ metadata.gz: 105d1d50c75e755f5fe1de82ab785a8cf386e31d4c7da52d1147239852dfdaf3
4
+ data.tar.gz: 3be62099be33d1a2eb38bd534e6bdb43a60b5845402a6b01f4df81ad2e6cb119
5
5
  SHA512:
6
- metadata.gz: 0e82764e8ce1120475086fc0baa9177dbe9f5c1402b259d6193b5dc5eb0fb40cf5d8e6d662846fe034e49b2f6eb6dd90c3ffbfdc14d6030870dc6651e8ae243d
7
- data.tar.gz: f1a56d7e98595cbeb01b40f5aa3db3e4eba2932245c28247175199fe04586837703ce2c9585331bd063163b005d9b0da782bc9914c131a306091432ef223f44f
6
+ metadata.gz: c49d546abd8cabfa8bc9bbb7b70eb0d9e78d85e0c02f6d22932d099b2ff08054cf0499f353e1d46bb0ff5bc784fee8c4b0b3a066966435e045aa730e4e4007d5
7
+ data.tar.gz: 697da3c3241d60ac22fa6bd68accda4efd7bd49392649537b2dd1cdbf077da06654d4698e66b74bec9c90fcca505bd3a30f0979fdfdbe1f096c8e79dedd13688
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
@@ -96,7 +96,7 @@ class Card < ApplicationRecord
96
96
  extend ::Card::Dirty::MethodFactory
97
97
  include ::Card::Dirty
98
98
 
99
- Card::Cache
99
+ Card::Cache # trigger autoload
100
100
 
101
101
  has_many :references_in, class_name: :Reference, foreign_key: :referee_id
102
102
  has_many :references_out, class_name: :Reference, foreign_key: :referer_id
@@ -2,11 +2,6 @@ class Card
2
2
  module Auth
3
3
  # singleton permission methods
4
4
  module Permissions
5
- RECAPTCHA_DEFAULTS = {
6
- recaptcha_site_key: "6LdoqpgUAAAAAEdhJ4heI1h3XLlpXcDf0YubriCG",
7
- recaptcha_secret_key: "6LdoqpgUAAAAAP4Sz1L5PY6VKum_RFxq4-awj4BH"
8
- }.freeze
9
-
10
5
  # user has "root" permissions
11
6
  # @return [true/false]
12
7
  def always_ok?
@@ -10,7 +10,7 @@ class Card
10
10
  extend Clean
11
11
  extend Truncate
12
12
 
13
- Chunk
13
+ Chunk # trigger autoload
14
14
 
15
15
  attr_reader :revision, :format, :chunks, :opts
16
16
 
@@ -99,13 +99,13 @@ class Card
99
99
  end
100
100
 
101
101
  def without_nests
102
- without_chunks Card::Content::Chunk::Nest do |content|
102
+ without_chunks Chunk::Nest do |content|
103
103
  yield content
104
104
  end
105
105
  end
106
106
 
107
107
  def without_references
108
- without_chunks Card::Content::Chunk::Nest, Card::Content::Chunk::Link do |content|
108
+ without_chunks Chunk::Nest, Chunk::Link do |content|
109
109
  yield content
110
110
  end
111
111
  end
@@ -31,7 +31,8 @@ event :approve_without_verification, :validate, on: :update, trigger: :required
31
31
  end
32
32
 
33
33
  event :act_as_current_for_integrate_stage, :integrate, on: :create do
34
- Auth.signin id
34
+ # needs justification!
35
+ Auth.current_id = id
35
36
  end
36
37
 
37
38
  def account_subfield
@@ -1,36 +1,38 @@
1
+ basket :warnings
2
+
3
+ # For each warning in the basket (eg :my_warning), the core view
4
+ # will run a test by appending a question mark (eg #my_warning?).
5
+ # If it fails it will generate a message by appending message
6
+ # (eg #my_warning_message).
7
+
8
+ add_to_basket :warnings, :no_email_delivery
9
+
10
+ def no_email_delivery?
11
+ Card.config.action_mailer.perform_deliveries == false
12
+ end
13
+
1
14
  def clean_html?
2
15
  false
3
16
  end
4
17
 
5
18
  format :html do
6
19
  view :core do
7
- warnings = []
8
- warnings << email_warning if Card.config.action_mailer.perform_deliveries == false
9
- if Card.config.recaptcha_site_key ==
10
- Card::Auth::Permissions::RECAPTCHA_DEFAULTS[:recaptcha_site_key] &&
11
- card.rule(:captcha) == "1"
12
- warnings << recaptcha_warning
13
- end
14
- return "" if warnings.empty?
15
-
16
- alert :warning, true do
17
- warning_list warnings
20
+ warnings = card.warnings.map do |warning|
21
+ card.send("#{warning}?") ? send("#{warning}_message") : nil
18
22
  end
23
+ warnings.compact!
24
+ warnings.empty? ? "" : warning_alert(warnings)
19
25
  end
20
26
 
21
- def warning_list warnings
22
- # 'ADMINISTRATOR WARNING'
27
+ def warning_alert warnings
23
28
  admin_warn = I18n.t(:admin_warn, scope: "mod.admin.set.self.admin_info")
24
- "<h5>#{admin_warn}</h5>" + list_tag(warnings)
25
- end
26
-
27
- def warning_list_with_auto_scope warnings
28
29
  # 'ADMINISTRATOR WARNING'
29
- admin_warn = tr(:admin_warn)
30
- "<h5>#{admin_warn}</h5>" + warnings.join("\n")
30
+ alert :warning, true do
31
+ "<h5>#{admin_warn}</h5>" + list_tag(warnings)
32
+ end
31
33
  end
32
34
 
33
- def email_warning
35
+ def no_email_delivery_message
34
36
  # "Email delivery is turned off."
35
37
  # "Change settings in config/application.rb to send sign up notifications."
36
38
  I18n.t(:email_off,
@@ -38,29 +40,9 @@ format :html do
38
40
  path: "config/application.rb")
39
41
  end
40
42
 
41
- def recaptcha_warning
42
- warning =
43
- if Card::Env.localhost?
44
- # %(Your captcha is currently working with temporary settings.
45
- # This is fine for a local installation, but you will need new
46
- # recaptcha keys if you want to make this site public.)
47
- I18n.t(:captcha_temp, scope: "mod.admin.set.self.admin_info",
48
- recaptcha_link: add_recaptcha_keys_link)
49
- else
50
- # %(You are configured to use [[*captcha]], but for that to work
51
- # you need new recaptcha keys.)
52
- I18n.t(:captcha_keys, scope: "mod.admin.set.self.admin_info",
53
- recaptcha_link: add_recaptcha_keys_link,
54
- captcha_link: link_to_card(:captcha))
55
- end
56
- <<-HTML
57
- <p>#{warning}</p>
58
- HTML
59
- end
60
-
61
- def add_recaptcha_keys_link
62
- nest :recaptcha_settings,
63
- view: :edit_link, title: I18n.t(:recaptcha_keys,
64
- scope: "mod.admin.set.self.admin_info")
43
+ def warning_list_with_auto_scope warnings
44
+ # 'ADMINISTRATOR WARNING'
45
+ admin_warn = tr(:admin_warn)
46
+ "<h5>#{admin_warn}</h5>" + warnings.join("\n")
65
47
  end
66
48
  end
@@ -22,7 +22,6 @@ format do
22
22
  view(:linkname, compact: true, perms: :none) { card.name.url_key }
23
23
  view(:url, compact: true, perms: :none) { card_url _render_linkname }
24
24
 
25
-
26
25
  view :url_link, compact: true, perms: :none do
27
26
  link_to_resource card_url(_render_linkname)
28
27
  end
@@ -13,7 +13,7 @@ format :html do
13
13
  end
14
14
 
15
15
  view :input do
16
- "Content is can't be edited."
16
+ "Content can't be edited."
17
17
  end
18
18
 
19
19
  def escape_in_main
@@ -10,6 +10,10 @@ def content
10
10
  end
11
11
 
12
12
  format :html do
13
+ view :input do
14
+ "Content is managed by code and cannot be edited"
15
+ end
16
+
13
17
  def haml_locals
14
18
  {}
15
19
  end
@@ -14,7 +14,7 @@ def last_change_on field, opts={}
14
14
  if no_last_change? action_id, opts[:before]
15
15
  nil
16
16
  elsif create_action_last_change? action_id
17
- create_action.change field
17
+ create_action&.change field
18
18
  else
19
19
  last_change_from_action_id action_id, field, opts
20
20
  end
@@ -25,7 +25,7 @@ def no_last_change? action_id, before
25
25
  end
26
26
 
27
27
  def create_action_last_change? action_id
28
- action_id == create_action.id || (!action_id && create_action.sole?)
28
+ action_id == create_action&.id || (!action_id && create_action&.sole?)
29
29
  end
30
30
 
31
31
  def last_change_from_action_id action_id, field, opts
@@ -0,0 +1,54 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ # This initializer module is mostly here to avoid adding methods/vars to the Object
4
+ # namespace
5
+ module RecaptchaCard
6
+ @deprecated = {
7
+ recaptcha_site_key: :recaptcha_public_key,
8
+ recaptcha_secret_key: :recaptcha_private_key
9
+ }
10
+ @defaults = {
11
+ recaptcha_site_key: "6LdoqpgUAAAAAEdhJ4heI1h3XLlpXcDf0YubriCG",
12
+ recaptcha_secret_key: "6LdoqpgUAAAAAP4Sz1L5PY6VKrum_RFxq4-awj4BH"
13
+ }
14
+
15
+ mattr_accessor :using_card_defaults
16
+
17
+ class << self
18
+ def load_recaptcha_config setting
19
+ setting = "recaptcha_#{setting}".to_sym
20
+ Cardio.config.send "#{setting}=", recaptcha_setting_value(setting)
21
+ end
22
+
23
+ def using_defaults?
24
+ Cardio.config.recaptcha_site_key == @defaults[:recaptcha_site_key]
25
+ end
26
+
27
+ # card config overrides application.rb config overrides default
28
+ def recaptcha_setting_value setting
29
+ card_value(setting) || # card content
30
+ config_value(setting) || # application.rb (current setting)
31
+ config_value(@deprecated[setting]) || # application.rb (deprecated setting)
32
+ @defaults[setting]
33
+ end
34
+
35
+ def config_value setting
36
+ Cardio.config.send setting
37
+ end
38
+
39
+ def card_value setting
40
+ return unless Card::Codename.exist? setting # prevents breakage in migrations
41
+ value = Card[setting]&.content
42
+ value if value.present?
43
+ end
44
+ end
45
+ end
46
+
47
+ ActiveSupport.on_load :after_card do
48
+ Recaptcha.configure do |config|
49
+ %i[site_key secret_key].each do |setting|
50
+ config.send "#{setting}=", RecaptchaCard.load_recaptcha_config(setting)
51
+ end
52
+ config.verify_url = "https://www.google.com/recaptcha/api/siteverify"
53
+ end
54
+ end
@@ -0,0 +1,33 @@
1
+ add_to_basket :warnings, :recaptcha_config_issues
2
+
3
+ def recaptcha_config_issues?
4
+ RecaptchaCard.using_defaults?
5
+ end
6
+
7
+ format :html do
8
+ def recaptcha_config_issues_message
9
+ warning =
10
+ if Card::Env.localhost?
11
+ # %(Your captcha is currently working with temporary settings.
12
+ # This is fine for a local installation, but you will need new
13
+ # recaptcha keys if you want to make this site public.)
14
+ I18n.t(:captcha_temp, scope: "mod.admin.set.self.admin_info",
15
+ recaptcha_link: add_recaptcha_keys_link)
16
+ else
17
+ # %(You are configured to use [[*captcha]], but for that to work
18
+ # you need new recaptcha keys.)
19
+ I18n.t(:captcha_keys, scope: "mod.admin.set.self.admin_info",
20
+ recaptcha_link: add_recaptcha_keys_link,
21
+ captcha_link: link_to_card(:captcha))
22
+ end
23
+ <<-HTML
24
+ <p>#{warning}</p>
25
+ HTML
26
+ end
27
+
28
+ def add_recaptcha_keys_link
29
+ nest :recaptcha_settings,
30
+ view: :edit_link, title: I18n.t(:recaptcha_keys,
31
+ scope: "mod.admin.set.self.admin_info")
32
+ end
33
+ 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.99.2
4
+ version: 1.99.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-02-12 00:00:00.000000000 Z
14
+ date: 2020-02-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: cardname
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.9.2
22
+ version: 0.9.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.9.2
29
+ version: 0.9.3
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: haml
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -371,7 +371,6 @@ files:
371
371
  - config/initializers/mime_types.rb
372
372
  - config/initializers/notification.rb
373
373
  - config/initializers/patches.rb
374
- - config/initializers/recaptcha.rb
375
374
  - config/initializers/uuid_state_file.rb
376
375
  - config/initializers/zeitwerk.rb
377
376
  - config/locales/de.yml
@@ -1202,10 +1201,6 @@ files:
1202
1201
  - mod/admin/set/self/admin.rb
1203
1202
  - mod/admin/set/self/admin_info.rb
1204
1203
  - mod/admin/set/self/debugger.rb
1205
- - mod/admin/set/self/recaptcha_proxy.rb
1206
- - mod/admin/set/self/recaptcha_secret_key.rb
1207
- - mod/admin/set/self/recaptcha_settings.rb
1208
- - mod/admin/set/self/recaptcha_site_key.rb
1209
1204
  - mod/admin/set/self/trash.rb
1210
1205
  - mod/admin/set/self/version.rb
1211
1206
  - mod/admin/spec/set/self/admin_info_spec.rb
@@ -5301,7 +5296,13 @@ files:
5301
5296
  - mod/prosemirror_editor/set/self/script_prosemirror.rb
5302
5297
  - mod/prosemirror_editor/set/self/script_prosemirror_config.rb
5303
5298
  - mod/prosemirror_editor/set/self/style_prosemirror.rb
5299
+ - mod/recaptcha/config/initializers/recaptcha.rb
5304
5300
  - mod/recaptcha/set/all/recaptcha.rb
5301
+ - mod/recaptcha/set/self/admin_info.rb
5302
+ - mod/recaptcha/set/self/recaptcha_proxy.rb
5303
+ - mod/recaptcha/set/self/recaptcha_secret_key.rb
5304
+ - mod/recaptcha/set/self/recaptcha_settings.rb
5305
+ - mod/recaptcha/set/self/recaptcha_site_key.rb
5305
5306
  - mod/rules/lib/javascript/script_rules.js.coffee
5306
5307
  - mod/rules/set/right/self.rb
5307
5308
  - mod/rules/set/rstar/rule_user.rb
@@ -1,46 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- DEPRECATED = { site_key: :public_key, secret_key: :private_key }
4
-
5
- # card config overrides application.rb config overrides default
6
- def load_recaptcha_config setting
7
- setting = "recaptcha_#{setting}".to_sym
8
- Cardio.config.send(
9
- "#{setting}=", load_recaptcha_card_config(setting) || # card content
10
- Cardio.config.send(setting) || # application.rb
11
- (DEPRECATED[setting] && Cardio.config.send(DEPRECATED[setting])) ||
12
- default_setting(setting)
13
- )
14
- end
15
-
16
- def default_setting setting
17
- # when creating the database (with `decko seed`) this is called
18
- # but fails because Card::Auth doesn't exist
19
- return unless Card.const_defined? "Auth"
20
- Card::Auth::Permissions::RECAPTCHA_DEFAULTS[setting]
21
- end
22
-
23
- def card_table_ready?
24
- # FIXME: this test should be more generally usable
25
- ActiveRecord::Base.connection.table_exists?("cards") &&
26
- Card.ancestors.include?(ActiveRecord::Base)
27
- end
28
-
29
- # use if card with value is present
30
- def load_recaptcha_card_config setting
31
- card = Card.find_by_codename setting
32
- card&.db_content.present? && card.db_content
33
- end
34
-
35
- ActiveSupport.on_load :after_card do
36
- Recaptcha.configure do |config|
37
- # the seed task runs initializers so we have to check
38
- # if the cards table is ready before we use it here
39
- if card_table_ready?
40
- %i[site_key secret_key].each do |setting|
41
- config.send "#{setting}=", load_recaptcha_config(setting)
42
- end
43
- end
44
- config.verify_url = "https://www.google.com/recaptcha/api/siteverify"
45
- end
46
- end