pages_core 3.12.7 → 3.13.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/controllers/admin/pages_controller.rb +1 -1
  4. data/app/controllers/admin/users_controller.rb +1 -1
  5. data/app/controllers/concerns/pages_core/error_reporting.rb +9 -19
  6. data/app/controllers/concerns/pages_core/static_cache_controller.rb +13 -2
  7. data/app/controllers/pages_core/attachments_controller.rb +1 -1
  8. data/app/controllers/pages_core/frontend/pages_controller.rb +1 -1
  9. data/app/controllers/pages_core/frontend_controller.rb +1 -10
  10. data/app/controllers/sessions_controller.rb +1 -1
  11. data/app/formatters/pages_core/image_embedder.rb +3 -3
  12. data/app/helpers/admin/pages_helper.rb +2 -2
  13. data/app/helpers/pages_core/admin/admin_helper.rb +1 -1
  14. data/app/helpers/pages_core/admin/content_tabs_helper.rb +3 -3
  15. data/app/helpers/pages_core/admin/form_builder.rb +1 -1
  16. data/app/helpers/pages_core/admin/image_uploads_helper.rb +6 -6
  17. data/app/helpers/pages_core/admin/labelled_field_helper.rb +1 -1
  18. data/app/helpers/pages_core/admin/locales_helper.rb +1 -1
  19. data/app/helpers/pages_core/application_helper.rb +3 -3
  20. data/app/helpers/pages_core/head_tags_helper.rb +8 -9
  21. data/app/helpers/pages_core/images_helper.rb +7 -7
  22. data/app/helpers/pages_core/open_graph_tags_helper.rb +2 -2
  23. data/app/helpers/pages_core/page_path_helper.rb +2 -2
  24. data/app/jobs/pages_core/autopublish_job.rb +2 -0
  25. data/app/models/concerns/pages_core/has_roles.rb +2 -2
  26. data/app/models/concerns/pages_core/page_model/dated_page.rb +1 -1
  27. data/app/models/concerns/pages_core/page_model/searchable.rb +1 -1
  28. data/app/models/concerns/pages_core/page_model/templateable.rb +22 -0
  29. data/app/models/concerns/pages_core/searchable_document.rb +3 -3
  30. data/app/models/page.rb +1 -1
  31. data/app/models/page_builder.rb +9 -9
  32. data/app/models/page_exporter.rb +1 -1
  33. data/app/models/page_image.rb +1 -1
  34. data/app/models/page_path.rb +3 -3
  35. data/app/models/search_document.rb +3 -3
  36. data/app/models/tag.rb +1 -1
  37. data/app/services/pages_core/create_user_service.rb +2 -2
  38. data/app/services/pages_core/destroy_invite_service.rb +2 -2
  39. data/app/services/pages_core/invite_service.rb +2 -2
  40. data/app/views/admin/pages/_edit_content.html.erb +1 -1
  41. data/app/views/admin/pages/_form.html.erb +12 -0
  42. data/db/migrate/20111219033112_create_pages_tables.rb +0 -14
  43. data/lib/pages_core/cache_sweeper.rb +3 -3
  44. data/lib/pages_core/extensions/string_extensions.rb +1 -1
  45. data/lib/pages_core/templates/configuration.rb +1 -1
  46. data/lib/pages_core/templates/template_configuration.rb +1 -1
  47. data/lib/pages_core.rb +1 -2
  48. data/lib/rails/generators/pages_core/install/install_generator.rb +0 -15
  49. data/lib/rails/generators/pages_core/rspec/templates/page_templates_spec.rb +1 -1
  50. metadata +4 -49
  51. data/lib/rails/generators/pages_core/install/templates/active_job_initializer.rb +0 -3
  52. data/lib/rails/generators/pages_core/install/templates/delayed_job +0 -7
  53. data/lib/rails/generators/pages_core/install/templates/delayed_job_initializer.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 163cc3bcfb2a7c108347dc717d33142eb24e14feddda441de64faffda748dfeb
4
- data.tar.gz: dfda2479ed024326379ed3776fc4b199ac0d0fffde3d5f98feb9a36911a92e87
3
+ metadata.gz: cd2414153112fe73c09225371f24be7c61cb4cf9ed3d62a633ec6cc47b10411a
4
+ data.tar.gz: 3b94c430720c0d75000065047bbc407b59a24e0931e1a39a901107933603d597
5
5
  SHA512:
6
- metadata.gz: 509ec2e72a86c3b70d4db4d5ebc733b0f744a3919dabc9e45aab0f172226699cf65279fc82dda0ad04caac26146358df816ea0a7b5c9fc2a5e220984f9fd8e0b
7
- data.tar.gz: 33c0d864232bd1196aa9920d42a864acbf384946b83a56609f326cec28a68f5e0e4eb53852f89fd82f448450edec9be60149861359fb1ed5c0b7398cd9ad0309
6
+ metadata.gz: f4648cba128ccec11c3dd5d34485c20d2e33ed02361be1007152e66267166d7b557f87bcd02320120e99e2b3b7510fbd1b242ed32a1b275319cdde6944be62ba
7
+ data.tar.gz: 16090abcbd624dc65a37de898b8f0c6792d52c9a05b4a9cc1b9a06da3ce0b87dd379df7efad3bf67d23f6d61ccd4b450f7f33e6f0f77cb049cbf7f8c5ff044c9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.12.7
1
+ 3.13.0
@@ -64,7 +64,7 @@ module Admin
64
64
 
65
65
  def move
66
66
  parent = params[:parent_id] ? Page.find(params[:parent_id]) : nil
67
- @page.update(parent: parent, position: params[:position])
67
+ @page.update(parent:, position: params[:position])
68
68
  respond_with_page(@page) { redirect_to admin_pages_url(content_locale) }
69
69
  end
70
70
 
@@ -11,7 +11,7 @@ module Admin
11
11
 
12
12
  def index
13
13
  @users = User.activated
14
- @invites = Invite.all.order("created_at DESC")
14
+ @invites = Invite.order("created_at DESC")
15
15
  end
16
16
 
17
17
  def deactivated
@@ -5,34 +5,24 @@ module PagesCore
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- before_action :configure_sentry_context
8
+ before_action :configure_sentry_scope
9
9
  end
10
10
 
11
11
  protected
12
12
 
13
- def configure_sentry_context
14
- return if Rails.env.test?
13
+ def configure_sentry_scope
14
+ return if Rails.env.test? || !Object.const_defined?("Sentry")
15
15
 
16
- if Object.const_defined?("Sentry")
17
- Sentry.set_user(current_user_context)
18
- Sentry.set_tags(locale: params[:locale] || I18n.default_locale.to_s)
19
- Sentry.set_extras(params: params.to_unsafe_h)
20
- elsif Object.const_defined?("Raven")
21
- configure_legacy_sentry_context
22
- end
23
- end
24
-
25
- def configure_legacy_sentry_context
26
- Raven.user_context(current_user_context)
27
- Raven.tags_context(locale: params[:locale] || I18n.default_locale.to_s)
28
- Raven.extra_context(params: params.to_unsafe_h)
16
+ Sentry.set_context("params", params.to_unsafe_h)
17
+ Sentry.set_tags(locale: params[:locale] || I18n.default_locale.to_s)
18
+ Sentry.set_user(current_user_context)
29
19
  end
30
20
 
31
21
  def current_user_context
32
- return { user_id: :guest } unless logged_in?
22
+ return {} unless logged_in?
33
23
 
34
- { user_id: current_user.id,
35
- user_email: current_user.email }
24
+ { id: current_user.id,
25
+ email: current_user.email }
36
26
  end
37
27
  end
38
28
  end
@@ -4,10 +4,13 @@ module PagesCore
4
4
  module StaticCacheController
5
5
  extend ActiveSupport::Concern
6
6
 
7
+ included do
8
+ helper_method :static_cached?
9
+ end
10
+
7
11
  module ClassMethods
8
12
  def static_cache(*actions, permanent: false)
9
- return unless perform_caching
10
-
13
+ before_action :prepare_static_cache
11
14
  if permanent
12
15
  after_action :cache_static_page_permanently, only: actions
13
16
  else
@@ -22,6 +25,10 @@ module PagesCore
22
25
  @static_cache_disabled = true
23
26
  end
24
27
 
28
+ def static_cached?
29
+ !@static_cache_disabled && @static_cached ? true : false
30
+ end
31
+
25
32
  private
26
33
 
27
34
  def cache_static_page
@@ -40,6 +47,10 @@ module PagesCore
40
47
  )
41
48
  end
42
49
 
50
+ def prepare_static_cache
51
+ @static_cached = true
52
+ end
53
+
43
54
  def static_cache_allowed?
44
55
  (request.get? || request.head?) && response.status == 200 &&
45
56
  perform_caching && !@static_cache_disabled
@@ -31,7 +31,7 @@ module PagesCore
31
31
  send_ranged_data(@attachment.data,
32
32
  filename: @attachment.filename,
33
33
  type: @attachment.content_type,
34
- disposition: disposition)
34
+ disposition:)
35
35
  end
36
36
 
37
37
  def verify_signed_params
@@ -121,7 +121,7 @@ module PagesCore
121
121
  def redirect_page(page)
122
122
  return false unless page.redirects?
123
123
 
124
- redirect_to(page.redirect_path(locale: locale), allow_other_host: true)
124
+ redirect_to(page.redirect_path(locale:), allow_other_host: true)
125
125
  end
126
126
 
127
127
  def require_page
@@ -22,21 +22,12 @@ module PagesCore
22
22
 
23
23
  private
24
24
 
25
- def legacy_locales
26
- { "nor" => "nb",
27
- "eng" => "en" }
28
- end
29
-
30
25
  def page_param
31
26
  params[:page].is_a?(String) ? params[:page] : 1
32
27
  end
33
28
 
34
29
  def set_i18n_locale
35
- locale_param = content_locale
36
- if legacy_locales[locale_param]
37
- locale_param = legacy_locales[locale_param]
38
- end
39
- I18n.locale = locale_param
30
+ I18n.locale = content_locale
40
31
  rescue I18n::InvalidLocale
41
32
  raise if Rails.application.config.consider_all_requests_local
42
33
 
@@ -22,6 +22,6 @@ class SessionsController < ApplicationController
22
22
  protected
23
23
 
24
24
  def find_user(email, password)
25
- User.authenticate(email, password: password) if email && password
25
+ User.authenticate(email, password:) if email && password
26
26
  end
27
27
  end
@@ -23,7 +23,7 @@ module PagesCore
23
23
  def embed_image(id, size:, class_name:, link:)
24
24
  image_figure(
25
25
  Image.find(id).localize(I18n.locale),
26
- size: size, class_name: class_name, link: link
26
+ size:, class_name:, link:
27
27
  )
28
28
  rescue ActiveRecord::RecordNotFound
29
29
  nil
@@ -44,8 +44,8 @@ module PagesCore
44
44
  link = (Regexp.last_match(1) if options =~ /link="([^"]+)"/)
45
45
  embed_image(id,
46
46
  size: embed_image_size(options),
47
- class_name: class_name,
48
- link: link)
47
+ class_name:,
48
+ link:)
49
49
  end
50
50
 
51
51
  def parse_images(string)
@@ -39,12 +39,12 @@ module Admin
39
39
  ([page.author] + User.activated).uniq
40
40
  end
41
41
 
42
- def page_list_row(page, &block)
42
+ def page_list_row(page, &)
43
43
  classes = [page.status_label.downcase]
44
44
  classes << "autopublish" if page.autopublish?
45
45
  classes << "pinned" if page.pinned?
46
46
 
47
- tag.tr(capture(&block), class: classes.join(" "))
47
+ tag.tr(capture(&), class: classes.join(" "))
48
48
  end
49
49
 
50
50
  def page_name(page, options = {})
@@ -14,7 +14,7 @@ module PagesCore
14
14
  def rich_text_area_tag(name, content = nil, options = {})
15
15
  react_component("RichTextArea",
16
16
  options.merge(id: sanitize_to_id(name),
17
- name: name,
17
+ name:,
18
18
  value: content))
19
19
  end
20
20
 
@@ -11,14 +11,14 @@ module PagesCore
11
11
  content_tabs.any?
12
12
  end
13
13
 
14
- def content_tab(name, options = {}, &block)
14
+ def content_tab(name, options = {}, &)
15
15
  return unless block_given?
16
16
 
17
17
  tab = {
18
18
  name: name.to_s.humanize,
19
19
  key: options[:key] || name.to_s.underscore.gsub(/\s+/, "_"),
20
- options: options,
21
- content: capture(&block)
20
+ options:,
21
+ content: capture(&)
22
22
  }
23
23
  content_tabs.push(tab)
24
24
  content_tab_tag(tab[:key], tab[:content])
@@ -38,7 +38,7 @@ module PagesCore
38
38
 
39
39
  def foreign_key(attr)
40
40
  object.class.reflections[attr.to_s].options[:foreign_key] ||
41
- "#{attr}_id".to_sym
41
+ :"#{attr}_id"
42
42
  end
43
43
  end
44
44
  end
@@ -9,10 +9,10 @@ module PagesCore
9
9
  react_component("EditableImage",
10
10
  editable_image_options(
11
11
  image,
12
- width: width,
13
- caption: caption,
14
- locale: locale
15
- ).merge(width: width))
12
+ width:,
13
+ caption:,
14
+ locale:
15
+ ).merge(width:))
16
16
  end
17
17
 
18
18
  def image_uploader_tag(name, image, options = {})
@@ -36,8 +36,8 @@ module PagesCore
36
36
 
37
37
  def editable_image_options(image, width: 250, caption: false, locale: nil)
38
38
  editable_image_src_options(image, width).merge(
39
- width: width,
40
- caption: caption,
39
+ width:,
40
+ caption:,
41
41
  locale: locale || I18n.default_locale,
42
42
  locales: locales_with_dir
43
43
  )
@@ -24,7 +24,7 @@ module PagesCore
24
24
  [labelled_field_label(label, options),
25
25
  labelled_field_description(options[:description]),
26
26
  field,
27
- (options[:check_box_description] || "")]
27
+ options[:check_box_description] || ""]
28
28
  )
29
29
  end
30
30
  end
@@ -6,7 +6,7 @@ module PagesCore
6
6
  def locales_with_dir
7
7
  locales = PagesCore.config.locales || {}
8
8
  locales.each_with_object({}) do |(key, name), hash|
9
- hash[key] = { name: name, dir: locale_direction(key) }
9
+ hash[key] = { name:, dir: locale_direction(key) }
10
10
  end
11
11
  end
12
12
 
@@ -21,10 +21,10 @@ module PagesCore
21
21
  end
22
22
  end
23
23
 
24
- def unique_page(page_name, &block)
24
+ def unique_page(page_name, &)
25
25
  page = Page.where(unique_name: page_name).first
26
26
  if page && block_given?
27
- output = capture(page.localize(content_locale), &block)
27
+ output = capture(page.localize(content_locale), &)
28
28
  concat(output)
29
29
  end
30
30
  page&.localize(content_locale)
@@ -44,7 +44,7 @@ module PagesCore
44
44
 
45
45
  def page_link_path(locale, page)
46
46
  if page.redirects?
47
- page.redirect_path(locale: locale)
47
+ page.redirect_path(locale:)
48
48
  else
49
49
  page_path(locale, page)
50
50
  end
@@ -50,9 +50,9 @@ module PagesCore
50
50
  # <%= feed_tags %>
51
51
  # <% end %>
52
52
  #
53
- def head_tag(&block)
53
+ def head_tag(&)
54
54
  # The block output must be captured first
55
- block_output = block_given? ? capture(&block) : nil
55
+ block_output = block_given? ? capture(&) : nil
56
56
 
57
57
  tag.head { safe_join(head_tag_contents(block_output), "\n") }
58
58
  end
@@ -64,34 +64,33 @@ module PagesCore
64
64
  def rss_link_tag(title, href)
65
65
  tag.link(rel: "alternate",
66
66
  type: "application/rss+xml",
67
- title: title,
68
- href: href)
67
+ title:,
68
+ href:)
69
69
  end
70
70
 
71
71
  private
72
72
 
73
73
  def head_tag_contents(block_output)
74
74
  [tag.meta(charset: "utf-8"),
75
- tag.meta("http-equiv" => "X-UA-Compatible", "content" => "IE=edge"),
76
75
  tag.title(document_title),
77
76
  meta_description_tag,
78
77
  meta_keywords_tag,
79
78
  (tag.link(rel: "image_src", href: meta_image) if meta_image?),
80
79
  open_graph_tags,
81
- csrf_meta_tags,
82
- block_output]
80
+ (csrf_meta_tags unless static_cached?),
81
+ block_output].compact_blank
83
82
  end
84
83
 
85
84
  def meta_description_tag
86
85
  return unless meta_description?
87
86
 
88
- tag.meta(name: "description", content: meta_description)
87
+ tag.meta(name: "description", content: meta_description&.strip)
89
88
  end
90
89
 
91
90
  def meta_keywords_tag
92
91
  return unless meta_keywords?
93
92
 
94
- tag.meta(name: "keywords", content: meta_keywords)
93
+ tag.meta(name: "keywords", content: meta_keywords&.strip)
95
94
  end
96
95
  end
97
96
  end
@@ -57,12 +57,12 @@ module PagesCore
57
57
  def picture_tag(image, ratio: nil, sizes: "100vw")
58
58
  tag.picture do
59
59
  safe_join(
60
- [webp_source(image, ratio: ratio, sizes: sizes || "100vw"),
60
+ [webp_source(image, ratio:, sizes: sizes || "100vw"),
61
61
  dynamic_image_tag(image,
62
62
  size: image_size(1050, ratio),
63
63
  crop: (ratio ? true : false),
64
- sizes: sizes,
65
- srcset: srcset(image, ratio: ratio))]
64
+ sizes:,
65
+ srcset: srcset(image, ratio:))]
66
66
  )
67
67
  end
68
68
  end
@@ -106,11 +106,11 @@ module PagesCore
106
106
  size ||= default_image_size
107
107
  size = fit_ratio(size, ratio) if ratio
108
108
 
109
- dynamic_image_tag(image, size: size, crop: ratio && true, upscale: false)
109
+ dynamic_image_tag(image, size:, crop: ratio && true, upscale: false)
110
110
  end
111
111
 
112
112
  def image_link_to(content, href)
113
- tag.a(content, href: href)
113
+ tag.a(content, href:)
114
114
  end
115
115
 
116
116
  def image_size(width, ratio)
@@ -139,8 +139,8 @@ module PagesCore
139
139
  return unless webp_compatible?(image)
140
140
 
141
141
  tag.source(type: "image/webp",
142
- srcset: srcset(image, ratio: ratio, format: :webp),
143
- sizes: sizes)
142
+ srcset: srcset(image, ratio:, format: :webp),
143
+ sizes:)
144
144
  end
145
145
 
146
146
  def webp_compatible?(image)
@@ -13,7 +13,7 @@ module PagesCore
13
13
  properties
14
14
  .compact
15
15
  .map do |name, content|
16
- tag.meta(property: "og:#{name}", content: content)
16
+ tag.meta(property: "og:#{name}", content:)
17
17
  end,
18
18
  "\n"
19
19
  )
@@ -42,7 +42,7 @@ module PagesCore
42
42
  site_name: PagesCore.config(:site_name),
43
43
  title: default_open_graph_title,
44
44
  image: (meta_image if meta_image?),
45
- description: default_open_graph_description,
45
+ description: default_open_graph_description&.strip,
46
46
  url: request.url }
47
47
  end
48
48
  end
@@ -30,7 +30,7 @@ module PagesCore
30
30
  private
31
31
 
32
32
  def page_redirect_url(locale, page)
33
- redirect = page.redirect_path(locale: locale)
33
+ redirect = page.redirect_path(locale:)
34
34
  return redirect if redirect =~ %r{^https?://}
35
35
 
36
36
  base_page_url + redirect
@@ -54,7 +54,7 @@ module PagesCore
54
54
  ActiveSupport::Deprecation.warn(
55
55
  "Calling page_url without locale is deprecated"
56
56
  )
57
- [(opts[:locale] || content_locale), page_or_locale]
57
+ [opts[:locale] || content_locale, page_or_locale]
58
58
  end
59
59
 
60
60
  def paginated_section(opts)
@@ -4,6 +4,8 @@ module PagesCore
4
4
  class AutopublishJob < ApplicationJob
5
5
  queue_as :pages_core
6
6
 
7
+ retry_on StandardError, attempts: 10, wait: :polynomially_longer
8
+
7
9
  def perform
8
10
  Autopublisher.run!
9
11
  end
@@ -16,9 +16,9 @@ module PagesCore
16
16
  def role_names=(names)
17
17
  self.roles = names.map do |name|
18
18
  if role?(name)
19
- roles.find_by(name: name)
19
+ roles.find_by(name:)
20
20
  else
21
- roles.new(name: name)
21
+ roles.new(name:)
22
22
  end
23
23
  end
24
24
  end
@@ -90,7 +90,7 @@ module PagesCore
90
90
  def siblings_by_date
91
91
  siblings.reorder("starts_at ASC, pages.id DESC")
92
92
  .where
93
- .not(id: id)
93
+ .not(id:)
94
94
  end
95
95
  end
96
96
  end
@@ -8,7 +8,7 @@ module PagesCore
8
8
  def search_document_attributes
9
9
  super.merge(
10
10
  published: published?,
11
- name: name,
11
+ name:,
12
12
  description: try(&:meta_description?) ? meta_description : excerpt,
13
13
  # content: "",
14
14
  tags: tag_names.join(" ")
@@ -7,6 +7,8 @@ module PagesCore
7
7
 
8
8
  included do
9
9
  before_validation :ensure_template
10
+
11
+ delegate :enabled_blocks, to: :template_config
10
12
  end
11
13
 
12
14
  def template_config
@@ -27,8 +29,28 @@ module PagesCore
27
29
  template
28
30
  end
29
31
 
32
+ def unconfigured_blocks
33
+ blocks = (localizations.where(locale:).pluck(:name)
34
+ .map(&:to_sym) -
35
+ configured_blocks) &
36
+ PagesCore::Templates::TemplateConfiguration.all_blocks
37
+
38
+ if block_given?
39
+ blocks.each do |block_name|
40
+ yield block_name, template_config.block(block_name)
41
+ end
42
+ end
43
+
44
+ blocks
45
+ end
46
+
30
47
  private
31
48
 
49
+ def configured_blocks
50
+ enabled_blocks + %i[name path_segment meta_title meta_description
51
+ open_graph_title open_graph_description]
52
+ end
53
+
32
54
  def singularized_subtemplate
33
55
  singularized = ActiveSupport::Inflector.singularize(base_template)
34
56
  return if base_template == singularized
@@ -18,7 +18,7 @@ module PagesCore
18
18
 
19
19
  class << self
20
20
  def index_all!(scope)
21
- scope.all.find_each { |r| new(r).index! }
21
+ scope.find_each { |r| new(r).index! }
22
22
  end
23
23
  end
24
24
 
@@ -53,7 +53,7 @@ module PagesCore
53
53
  end
54
54
 
55
55
  def update_index(locale, attrs)
56
- record.search_documents.create_or_find_by!(locale: locale).update(attrs)
56
+ record.search_documents.create_or_find_by!(locale:).update(attrs)
57
57
  end
58
58
  end
59
59
 
@@ -61,7 +61,7 @@ module PagesCore
61
61
  return {} unless respond_to?(:localized_attributes)
62
62
 
63
63
  content = localized_attributes.keys.map { |a| localizer.get(a) }.join(" ")
64
- { content: content }
64
+ { content: }
65
65
  end
66
66
 
67
67
  def update_search_documents!
data/app/models/page.rb CHANGED
@@ -78,7 +78,7 @@ class Page < ApplicationRecord
78
78
 
79
79
  def move(parent:, position:)
80
80
  Page.transaction do
81
- update(parent: parent) unless self.parent == parent
81
+ update(parent:) unless self.parent == parent
82
82
  insert_at(position)
83
83
  end
84
84
  end
@@ -19,7 +19,7 @@ class PageBuilder
19
19
 
20
20
  class << self
21
21
  def build(user, locale: nil, parent: nil, &block)
22
- new(user, locale: locale, parent: parent)
22
+ new(user, locale:, parent:)
23
23
  .run(&block)
24
24
  end
25
25
  end
@@ -30,20 +30,20 @@ class PageBuilder
30
30
  @parent = parent
31
31
  end
32
32
 
33
- def page(name, options = {}, &block)
33
+ def page(name, options = {}, &)
34
34
  page = Page.create(
35
- { name: name }.merge(default_options).merge(options)
35
+ { name: }.merge(default_options).merge(options)
36
36
  )
37
37
  if block_given?
38
38
  self.class
39
- .new(user, locale: locale, parent: page)
40
- .run(&block)
39
+ .new(user, locale:, parent: page)
40
+ .run(&)
41
41
  end
42
42
  page
43
43
  end
44
44
 
45
- def run(&block)
46
- instance_eval(&block)
45
+ def run(&)
46
+ instance_eval(&)
47
47
  end
48
48
 
49
49
  private
@@ -51,9 +51,9 @@ class PageBuilder
51
51
  def default_options
52
52
  {
53
53
  author: user,
54
- parent: parent,
54
+ parent:,
55
55
  status: 2,
56
- locale: locale
56
+ locale:
57
57
  }
58
58
  end
59
59
  end
@@ -88,7 +88,7 @@ class PageExporter
88
88
  def text_page(page)
89
89
  PagesCore::Templates::TemplateConfiguration
90
90
  .all_blocks
91
- .select { |attr| page.send("#{attr}?".to_sym) }
91
+ .select { |attr| page.send(:"#{attr}?") }
92
92
  .map { |attr| ["-- #{attr}: --", page.send(attr).strip].join("\n\n") }
93
93
  .join("\n\n\n")
94
94
  end
@@ -15,7 +15,7 @@ class PageImage < ApplicationRecord
15
15
 
16
16
  class << self
17
17
  def cleanup!
18
- all.find_each do |page_image|
18
+ find_each do |page_image|
19
19
  page_image.destroy unless page_image.image
20
20
  end
21
21
  end
@@ -28,7 +28,7 @@ class PagePath < ApplicationRecord
28
28
  end
29
29
 
30
30
  def get(locale, path)
31
- find_by(locale: locale, path: path)
31
+ find_by(locale:, path:)
32
32
  end
33
33
 
34
34
  def associate(page, locale: nil, path: nil)
@@ -39,14 +39,14 @@ class PagePath < ApplicationRecord
39
39
  raise NoPathError unless path
40
40
 
41
41
  page_path = get_or_create(locale, path, page)
42
- page_path.update(page: page) unless page_path.page_id == page.id
42
+ page_path.update(page:) unless page_path.page_id == page.id
43
43
  page_path
44
44
  end
45
45
 
46
46
  private
47
47
 
48
48
  def get_or_create(locale, path, page)
49
- get(locale, path) || create(locale: locale, path: path, page: page)
49
+ get(locale, path) || create(locale:, path:, page:)
50
50
  end
51
51
  end
52
52
  end
@@ -15,12 +15,12 @@ class SearchDocument < ApplicationRecord
15
15
  pg_search_scope :full_text_search_scope, lambda { |query, dictionary|
16
16
  { against: %i[name description content tags],
17
17
  using: { tsearch: { prefix: true,
18
- dictionary: dictionary,
18
+ dictionary:,
19
19
  tsvector_column: "tsv" },
20
20
  trigram: { only: %i[name] } },
21
21
  ignoring: :accents,
22
22
  order_within_rank: "search_documents.record_updated_at DESC",
23
- query: query }
23
+ query: }
24
24
  }
25
25
 
26
26
  class << self
@@ -31,7 +31,7 @@ class SearchDocument < ApplicationRecord
31
31
 
32
32
  def search(query, locale: nil)
33
33
  locale ||= I18n.locale
34
- where(locale: locale)
34
+ where(locale:)
35
35
  .includes(:searchable)
36
36
  .full_text_search_scope(query, search_configuration(locale))
37
37
  end
data/app/models/tag.rb CHANGED
@@ -57,7 +57,7 @@ class Tag < ApplicationRecord
57
57
  end
58
58
 
59
59
  def on(taggable)
60
- taggings.create(taggable: taggable)
60
+ taggings.create(taggable:)
61
61
  end
62
62
 
63
63
  def ==(other)
@@ -11,7 +11,7 @@ module PagesCore
11
11
 
12
12
  class << self
13
13
  def call(attrs, invite: nil)
14
- new(attrs, invite: invite).call
14
+ new(attrs, invite:).call
15
15
  end
16
16
  end
17
17
 
@@ -19,7 +19,7 @@ module PagesCore
19
19
  User.transaction do
20
20
  user = User.create(attributes.merge(invite_attributes))
21
21
  if user.valid?
22
- PagesCore::PubSub.publish(:create_user, user: user, invite: invite)
22
+ PagesCore::PubSub.publish(:create_user, user:, invite:)
23
23
  invite&.destroy
24
24
  end
25
25
  user
@@ -10,14 +10,14 @@ module PagesCore
10
10
 
11
11
  class << self
12
12
  def call(invite:)
13
- new(invite: invite).call
13
+ new(invite:).call
14
14
  end
15
15
  end
16
16
 
17
17
  def call
18
18
  Invite.transaction do
19
19
  invite.destroy
20
- PagesCore::PubSub.publish(:destroy_invite, invite: invite)
20
+ PagesCore::PubSub.publish(:destroy_invite, invite:)
21
21
  invite
22
22
  end
23
23
  end
@@ -15,7 +15,7 @@ module PagesCore
15
15
 
16
16
  class << self
17
17
  def call(attrs, user:, host:, protocol: "http")
18
- new(attrs, user: user, host: host, protocol: protocol).call
18
+ new(attrs, user:, host:, protocol:).call
19
19
  end
20
20
  end
21
21
 
@@ -36,7 +36,7 @@ module PagesCore
36
36
  AdminMailer.invite(
37
37
  invite,
38
38
  admin_invite_with_token_url(invite, invite.token,
39
- host: host, protocol: protocol)
39
+ host:, protocol:)
40
40
  ).deliver_later
41
41
  end
42
42
  end
@@ -1,4 +1,4 @@
1
- <% @page.template_config.enabled_blocks do |block_name, block_options| %>
1
+ <% @page.enabled_blocks do |block_name, block_options| %>
2
2
  <%= page_block_field(f, block_name, block_options) %>
3
3
  <% end %>
4
4
 
@@ -2,6 +2,18 @@
2
2
  <%= render partial: "edit_content", locals: { f: f } %>
3
3
  <% end %>
4
4
 
5
+ <% if @page.unconfigured_blocks.any? %>
6
+ <%= content_tab "Unconfigured content" do %>
7
+ <p>
8
+ This page has additional content fields not enabled by the
9
+ selected template.
10
+ </p>
11
+ <% @page.unconfigured_blocks do |block_name, block_options| %>
12
+ <%= page_block_field(f, block_name, block_options) %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+
5
17
  <% if @page.template_config.value(:images) || @page.template_config.value(:image) %>
6
18
  <%= content_tab "Images" do %>
7
19
  <%= render partial: "edit_images", locals: { f: f } %>
@@ -21,20 +21,6 @@ class CreatePagesTables < ActiveRecord::Migration[5.0]
21
21
  t.index :slug
22
22
  end
23
23
 
24
- create_table :delayed_jobs do |t|
25
- t.integer :priority, default: 0
26
- t.integer :attempts, default: 0
27
- t.text :handler
28
- t.text :last_error
29
- t.datetime :run_at
30
- t.datetime :locked_at
31
- t.datetime :failed_at
32
- t.string :locked_by
33
- t.datetime :created_at, null: false
34
- t.datetime :updated_at, null: false
35
- t.string :queue
36
- end
37
-
38
24
  create_table :images do |t|
39
25
  t.string :filename, null: false
40
26
  t.string :content_type, null: false
@@ -5,15 +5,15 @@ module PagesCore
5
5
  class << self
6
6
  attr_accessor :enabled
7
7
 
8
- def disable(&_block)
8
+ def disable(&)
9
9
  old_value = enabled
10
10
  self.enabled = false
11
11
  yield if block_given?
12
12
  self.enabled = old_value
13
13
  end
14
14
 
15
- def once(&block)
16
- disable(&block)
15
+ def once(&)
16
+ disable(&)
17
17
  PagesCore::StaticCache.handler.sweep!
18
18
  end
19
19
  end
@@ -4,7 +4,7 @@ module PagesCore
4
4
  module Extensions
5
5
  module StringExtensions
6
6
  def to_html_with(append, options = {})
7
- to_html(options.merge(append: append))
7
+ to_html(options.merge(append:))
8
8
  end
9
9
 
10
10
  def to_html(options = {})
@@ -149,7 +149,7 @@ module PagesCore
149
149
  def template_config(setting, value, options)
150
150
  value = true if value == :enabled
151
151
  value = false if value == :disabled
152
- { setting => { value: value, options: options } }
152
+ { setting => { value:, options: } }
153
153
  end
154
154
 
155
155
  def template_path(name)
@@ -106,7 +106,7 @@ module PagesCore
106
106
  end
107
107
 
108
108
  class << self
109
- def configure(options = {}, &_block)
109
+ def configure(options = {}, &)
110
110
  case options[:reset]
111
111
  when :defaults
112
112
  load_default_configuration
data/lib/pages_core.rb CHANGED
@@ -21,7 +21,6 @@ require "acts_as_list"
21
21
  require "alba"
22
22
  require "bcrypt"
23
23
  require "country_select"
24
- require "delayed_job_active_record"
25
24
  require "dis"
26
25
  require "dynamic_image"
27
26
  require "healthcheck"
@@ -71,7 +70,7 @@ module PagesCore
71
70
  Pathname.new(File.dirname(__FILE__)).join("..").expand_path
72
71
  end
73
72
 
74
- def configure(_options = {}, &_block)
73
+ def configure(_options = {}, &)
75
74
  yield configuration if block_given?
76
75
  end
77
76
 
@@ -22,11 +22,6 @@ module PagesCore
22
22
  nil
23
23
  end
24
24
 
25
- def create_active_job_initializer
26
- template("active_job_initializer.rb",
27
- File.join("config/initializers/active_job.rb"))
28
- end
29
-
30
25
  def create_application_controller
31
26
  template("application_controller.rb",
32
27
  File.join("app/controllers/application_controller.rb"))
@@ -57,16 +52,6 @@ module PagesCore
57
52
  File.join("app/views/pages/templates/index.html.erb"))
58
53
  end
59
54
 
60
- def create_delayed_job_script
61
- template "delayed_job", File.join("bin/delayed_job")
62
- File.chmod(0o755, Rails.root.join("bin/delayed_job"))
63
- end
64
-
65
- def create_delayed_job_initializer
66
- template("delayed_job_initializer.rb",
67
- File.join("config/initializers/delayed_job.rb"))
68
- end
69
-
70
55
  def create_initializer_file
71
56
  read_configuration!
72
57
  template("pages_initializer.rb",
@@ -7,7 +7,7 @@ RSpec.describe "Page templates", type: :system do
7
7
 
8
8
  let(:page_model) do
9
9
  create(:page,
10
- template: template,
10
+ template:,
11
11
  headline: "My headline",
12
12
  body: "My body",
13
13
  excerpt: "My excerpt")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pages_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.7
4
+ version: 3.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2024-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -332,48 +332,6 @@ dependencies:
332
332
  - - ">="
333
333
  - !ruby/object:Gem::Version
334
334
  version: 0.5.3
335
- - !ruby/object:Gem::Dependency
336
- name: daemons
337
- requirement: !ruby/object:Gem::Requirement
338
- requirements:
339
- - - "~>"
340
- - !ruby/object:Gem::Version
341
- version: 1.2.0
342
- type: :runtime
343
- prerelease: false
344
- version_requirements: !ruby/object:Gem::Requirement
345
- requirements:
346
- - - "~>"
347
- - !ruby/object:Gem::Version
348
- version: 1.2.0
349
- - !ruby/object:Gem::Dependency
350
- name: delayed_job
351
- requirement: !ruby/object:Gem::Requirement
352
- requirements:
353
- - - "~>"
354
- - !ruby/object:Gem::Version
355
- version: 4.1.2
356
- type: :runtime
357
- prerelease: false
358
- version_requirements: !ruby/object:Gem::Requirement
359
- requirements:
360
- - - "~>"
361
- - !ruby/object:Gem::Version
362
- version: 4.1.2
363
- - !ruby/object:Gem::Dependency
364
- name: delayed_job_active_record
365
- requirement: !ruby/object:Gem::Requirement
366
- requirements:
367
- - - "~>"
368
- - !ruby/object:Gem::Version
369
- version: 4.1.1
370
- type: :runtime
371
- prerelease: false
372
- version_requirements: !ruby/object:Gem::Requirement
373
- requirements:
374
- - - "~>"
375
- - !ruby/object:Gem::Version
376
- version: 4.1.1
377
335
  description: Pages Core
378
336
  email:
379
337
  - inge@anyone.no
@@ -700,12 +658,9 @@ files:
700
658
  - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/grid.css
701
659
  - lib/rails/generators/pages_core/frontend/templates/stylesheets/global/typography.css
702
660
  - lib/rails/generators/pages_core/install/install_generator.rb
703
- - lib/rails/generators/pages_core/install/templates/active_job_initializer.rb
704
661
  - lib/rails/generators/pages_core/install/templates/application_controller.rb
705
662
  - lib/rails/generators/pages_core/install/templates/application_helper.rb
706
663
  - lib/rails/generators/pages_core/install/templates/default_page_template.html.erb
707
- - lib/rails/generators/pages_core/install/templates/delayed_job
708
- - lib/rails/generators/pages_core/install/templates/delayed_job_initializer.rb
709
664
  - lib/rails/generators/pages_core/install/templates/frontend_controller.rb
710
665
  - lib/rails/generators/pages_core/install/templates/frontend_helper.rb
711
666
  - lib/rails/generators/pages_core/install/templates/gitignore.erb
@@ -736,14 +691,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
736
691
  requirements:
737
692
  - - ">="
738
693
  - !ruby/object:Gem::Version
739
- version: 3.0.0
694
+ version: 3.1.0
740
695
  required_rubygems_version: !ruby/object:Gem::Requirement
741
696
  requirements:
742
697
  - - ">="
743
698
  - !ruby/object:Gem::Version
744
699
  version: '0'
745
700
  requirements: []
746
- rubygems_version: 3.4.10
701
+ rubygems_version: 3.5.3
747
702
  signing_key:
748
703
  specification_version: 4
749
704
  summary: Pages Core
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ActiveJob::Base.queue_adapter = :delayed_job
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "config",
5
- "environment"))
6
- require "delayed/command"
7
- Delayed::Command.new(ARGV).daemonize
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Delayed::Worker.backend = :active_record
4
-
5
- if Object.const_defined?("Postmark")
6
- class InvalidRecipientsPlugin < Delayed::Plugin
7
- callbacks do |lifecycle|
8
- lifecycle.around(:invoke_job) do |job, *args, &block|
9
- # Forward the call to the next callback in the callback chain
10
- block.call(job, *args)
11
- rescue Postmark::InactiveRecipientError => e
12
- Rails.logger.error "#{e.class}: #{e.message}"
13
- end
14
- end
15
- end
16
-
17
- Delayed::Worker.plugins << InvalidRecipientsPlugin
18
- end