occams 1.0.8 → 1.1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcc8760162308f5d0ad46ac82f46fa92be816f9e8c6ee291759709ddc472513e
4
- data.tar.gz: f67e7efd920a103c3027e0201e824ee95bea38853893688ca7cbd9b0961d9a6d
3
+ metadata.gz: de6711b997c207a91f021b6f4bfb158f8a4ab7763b533367ca2726edda6c4af4
4
+ data.tar.gz: da3e64509b1689282afcb484d1f6942db43945a39cdfcce2baf566ed4e0ce80f
5
5
  SHA512:
6
- metadata.gz: aa7e678609d40af0dcd82a99a135f398006120c6b867a51a5814a7295f2540ec9771a21a0e972d64299e552b989b267748d35f8fe0c242b4fb2cc731e0086275
7
- data.tar.gz: aaab1c6865ad43badee1f359c76fa3e45157f85ecb16f742c309c2ebd5de5430426745155f97fb619568d1d3280b2bdc21b33a9ba48f7e6eed763dcaa47a0ec9
6
+ metadata.gz: f63e97f7e35f9d722ddc95aeff8cf71b22973f388b773dcab39a5b61a698b8b980e31134ee944731887cacda1be2dca9209c1dc169fe45f7fb8d62eb4cd0fdc7
7
+ data.tar.gz: 38a2af2e7b3f4ad037669ce10e14186a9cb07def0d36130c4331ebf041d34b02c8634d7631b99b67feb77ceddfebd5e8eb98c0c61da4795f21b40ad3694a33f1
@@ -10,9 +10,9 @@ jobs:
10
10
  strategy:
11
11
  matrix:
12
12
  ruby-version:
13
- - "3.2"
13
+ - "3.3"
14
14
  rails-version:
15
- - "7.0"
15
+ - "7.1"
16
16
  continue-on-error: [true]
17
17
  name: ${{ format('Coverage (Ruby {0}, Rails {1})', matrix.ruby-version, matrix.rails-version) }}
18
18
  runs-on: ubuntu-latest
@@ -10,13 +10,13 @@ jobs:
10
10
  strategy:
11
11
  matrix:
12
12
  ruby-version:
13
- - "2.7"
14
13
  - "3.1"
15
14
  - "3.2"
16
15
  - "3.3"
17
16
  rails-version:
18
17
  - "6.1"
19
18
  - "7.0"
19
+ - "7.1"
20
20
  continue-on-error: [true]
21
21
  name: ${{ format('Tests (Ruby {0}, Rails {1})', matrix.ruby-version, matrix.rails-version) }}
22
22
  runs-on: ubuntu-latest
data/.gitignore CHANGED
@@ -12,6 +12,7 @@ coverage/
12
12
  db/*.sqlite3
13
13
  db/cms_fixtures/test-site/
14
14
  db/development_structure.sql
15
+ db/development.sqlite3*
15
16
  db/schema.rb
16
17
  db/test.sqlite3*
17
18
  Gemfile.lock
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ require:
2
+ # - rubocop-rails
3
+ # - rubocop-minitest
4
+
1
5
  AllCops:
2
6
  TargetRubyVersion: 2.7
3
7
  NewCops: enable
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## v.1.1.1 19 May 2024
4
+
5
+ - bump to Rails 7.1.3.3
6
+ - bugfix: uploaded files index page was blank
7
+ - create cms:image tag, simplifying from cms:file_link
8
+ - add 'title' attribute to images
9
+ - update and optimize test suite
10
+ - drop support for ruby < 3.0 - no longer supported
11
+
12
+ ## v.1.1.0 13 May 2024
13
+
14
+ - Rails 7.1 compatibility, all tests passing
15
+ - corrected bug in siblings tag to not display links to unpublished pages
16
+ - children lists and sibling navs are updated after page create, update, delete
17
+ - fixed zeitwerk check failures
18
+ - updated README
19
+
3
20
  ## v1.0.8 - 29 December 2023
4
21
 
5
22
  - Updated configs, et al. in pursuit of Rails 7.1 compatibility
data/Gemfile CHANGED
@@ -5,35 +5,34 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
6
  gemspec
7
7
 
8
- gem 'rails', '~> 7.0.0'
8
+ gem 'rails', '~> 7.1.3'
9
9
 
10
10
  group :development, :test do
11
- gem 'autoprefixer-rails', '~> 8.1.0'
12
- gem 'byebug', '~> 10.0.0', platforms: %i[mri mingw x64_mingw]
13
- gem 'image_processing', '>= 1.2'
11
+ gem 'autoprefixer-rails', '~> 10.4.16.0'
12
+ gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw]
13
+ gem 'image_processing', '>= 1.12.0'
14
14
  gem 'sqlite3', '~> 1.6.7'
15
15
  # gem 'mysql2', '~> 0.5'
16
16
  # gem 'pg', '~> 1.5.4'
17
17
  end
18
18
 
19
19
  group :development do
20
- gem 'listen', '~> 3.8.0'
20
+ gem 'listen', '~> 3.9.0'
21
21
  gem 'web-console', '~> 4.2'
22
22
  end
23
23
 
24
24
  group :test do
25
- gem 'brakeman', '~> 5.4.1'
25
+ gem 'brakeman', '~> 6.1.2'
26
26
  gem 'bundler-audit', '~> 0.9.1'
27
- gem 'capybara', '~> 3.39.0'
28
27
  gem 'coveralls_reborn', '~> 0.28.0', require: false
29
- gem 'cuprite', '~> 0.14.3'
30
- gem 'diffy', '~> 3.4.2'
28
+ gem 'cuprite', '>= 0.15'
31
29
  gem 'equivalent-xml', '~> 0.6.0'
32
- gem 'minitest', '~> 5.20.0'
33
- gem 'minitest-reporters', '~> 1.6.1'
34
- gem 'mocha', '~> 2.1.0', require: false
35
- gem 'puma', '~> 6.4.0'
30
+ gem 'minitest', '>= 5.23.0'
31
+ gem 'minitest-reporters', '>= 1.6.1'
32
+ gem 'mocha', '>= 2.3.0', require: false
36
33
  gem 'rails-controller-testing', '~> 1.0.5'
37
- gem 'rubocop', '~> 1.56.0', require: false
38
- gem 'simplecov', '~> 0.22.0', require: false
34
+ gem 'rubocop', '~> 1.63.0', require: false
35
+ gem 'rubocop-minitest'
36
+ gem 'rubocop-rails'
37
+ gem 'simplecov', '~> 0.22.0', require: false
39
38
  end
data/README.md CHANGED
@@ -47,9 +47,8 @@ ocCaM'S, pronounced "AH-kums" is a nod to [Occam's Razor](https://en.wikipedia.o
47
47
 
48
48
  ## Compatibility
49
49
 
50
- - [Test suite](https://github.com/avonderluft/occams/actions/workflows/rubyonrails.yml) on Ruby >= 2.7 with Rails >= 6.1
51
- - On Ruby 3.2, Rails 7.x + is recommended, since performance is noticably better than on 6.x
52
- - Sites do run on Rails 7.1, e.g. [GKNT](https://gknt.org/), but some tests fail in [Github Actions](https://github.com/avonderluft/occams/actions). Your mileage may vary.
50
+ - [Test suite](https://github.com/avonderluft/occams/actions/workflows/rubyonrails.yml) on Ruby >= 3.0 with Rails >= 6.1
51
+ - On Ruby 3.x, Rails 7.x + is recommended, since performance is noticably better than on 6.x
53
52
 
54
53
  ## Installation
55
54
 
@@ -98,8 +97,6 @@ Once you have a layout, you may start creating pages and populating content. It'
98
97
 
99
98
  ## Documentation
100
99
 
101
- [Occams](https://github.com/avonderluft/occams)
102
-
103
100
  For more information on how to use this CMS please refer to the [Wiki](https://github.com/avonderluft/occams/wiki). Section that might be of interest is the entry
104
101
  on [Content Tags](https://github.com/comfy/avonderluft/occams/Content-Tags).
105
102
 
@@ -120,5 +117,5 @@ For more detail see [CONTRIBUTING](CONTRIBUTING.md)
120
117
  - Thanks to [Roman Almeida](https://github.com/nasmorn) for contributing OEM License for [Redactor Text Editor](http://imperavi.com/redactor)
121
118
 
122
119
  ---
123
- - [Occams](https://github.com/avonderluft/occams) Copyright 2023 Andrew vonderLuft, following Comfy, released under the [MIT license](LICENSE)
120
+ - [Occams](https://github.com/avonderluft/occams) Copyright 2023-2024 Andrew vonderLuft, following Comfy, released under the [MIT license](LICENSE)
124
121
  - [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) Copyright 2010-2019 Oleg Khabarov. Released under the [MIT license](LICENSE)
data/TODOS.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # ToDos
2
2
 
3
- - set up Buildkite CI and add build badge to README
4
3
  - add duplicate page function in admin UI
5
4
  - add admin content search to list layouts, pages and snippets - see https://blog.robertsj.com/search/
6
- - add application console for testing
7
- - add feature to resize file_link'd images
5
+ - diagnose and correct failure of ImageMagick params in file_link and image cms tags
6
+ - lint for rubocop-rails and rubocop-minitest
@@ -2,8 +2,10 @@
2
2
 
3
3
  module Occams::Paginate
4
4
  def occams_paginate(scope, per_page: 50)
5
- return unless defined?(Kaminari)
6
-
7
- scope.page(params[:page]).per(per_page)
5
+ if defined?(Kaminari)
6
+ scope.page(params[:page]).per(per_page)
7
+ else
8
+ scope
9
+ end
8
10
  end
9
11
  end
@@ -12,6 +12,9 @@ module Occams::ReorderAction
12
12
  (params.permit(order: [])[:order] || []).each_with_index do |id, index|
13
13
  resource_class.where(id: id).update_all(position: index)
14
14
  end
15
+ if resource_class == ::Occams::Cms::Page
16
+ Occams::Cms::Page.all.each(&:save!)
17
+ end
15
18
  head :ok
16
19
  end
17
20
  end
@@ -35,8 +35,14 @@ class Occams::Admin::Cms::PagesController < Occams::Admin::Cms::BaseController
35
35
  render
36
36
  end
37
37
 
38
+ def update_family
39
+ @page.siblings.each(&:save!) if @page.siblings
40
+ @page.parent.save! if @page.parent
41
+ end
42
+
38
43
  def create
39
44
  @page.save!
45
+ update_family
40
46
  flash[:success] = I18n.t('occams.admin.cms.pages.created')
41
47
  redirect_to action: :edit, id: @page
42
48
  rescue ActiveRecord::RecordInvalid
@@ -46,6 +52,7 @@ class Occams::Admin::Cms::PagesController < Occams::Admin::Cms::BaseController
46
52
 
47
53
  def update
48
54
  @page.save!
55
+ update_family
49
56
  flash[:success] = I18n.t('occams.admin.cms.pages.updated')
50
57
  redirect_to action: :edit, id: @page
51
58
  rescue ActiveRecord::RecordInvalid
@@ -55,6 +62,7 @@ class Occams::Admin::Cms::PagesController < Occams::Admin::Cms::BaseController
55
62
 
56
63
  def destroy
57
64
  @page.destroy
65
+ update_family
58
66
  flash[:success] = I18n.t('occams.admin.cms.pages.deleted')
59
67
  redirect_to action: :index
60
68
  end
@@ -119,8 +127,8 @@ protected
119
127
 
120
128
  def build_page
121
129
  @page = @site.pages.new(page_params)
122
- @page.parent ||= (@site.pages.find_by_id(params[:parent_id]) || @site.pages.root)
123
- @page.layout ||= (@page.parent&.layout || @site.layouts.first)
130
+ @page.parent ||= @site.pages.find_by_id(params[:parent_id]) || @site.pages.root
131
+ @page.layout ||= @page.parent&.layout || @site.layouts.first
124
132
  end
125
133
 
126
134
  def load_page
@@ -39,8 +39,11 @@ module Occams
39
39
  # @param [Occams::Cms::File] file
40
40
  # @return [String] {{ cms:file_link #{file.id}, ... }}
41
41
  def cms_file_link_tag(file)
42
- as = ', as: image' if file.attachment.image?
43
- "{{ cms:file_link #{file.id}#{as} }}"
42
+ if file.attachment.image?
43
+ "{{ cms:image #{file.label} }}"
44
+ else
45
+ "{{ cms:file_link #{file.id} }}"
46
+ end
44
47
  end
45
48
  end
46
49
  end
@@ -65,9 +65,7 @@ module Occams
65
65
  def occams_paginate(collection)
66
66
  return unless collection
67
67
 
68
- return unless defined?(Kaminari)
69
-
70
- paginate collection, theme: 'occams'
68
+ paginate collection, theme: 'occams' if defined?(Kaminari)
71
69
  end
72
70
  end
73
71
  end
@@ -14,8 +14,6 @@ module Occams
14
14
  config.load_defaults Rails.version.scan(%r{^\d+\.\d+}).first.to_f
15
15
 
16
16
  # Rails 7.1 compatibility - See config/initializers/new_framework_defaults_7_1.rb
17
- config.add_autoload_paths_to_load_path = true
18
-
19
17
  if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0')
20
18
  config.active_record.default_column_serializer = YAML
21
19
  config.active_record.before_committed_on_all_records = false
@@ -30,6 +28,7 @@ module Occams
30
28
  # Please, add to the `ignore` list any other `lib` subdirectories that do
31
29
  # not contain `.rb` files, or that should not be reloaded or eager loaded.
32
30
  # Common ones are `templates`, `generators`, or `middleware`, for example.
31
+ config.add_autoload_paths_to_load_path = false
33
32
  config.autoload_lib(ignore: %w[generators])
34
33
  end
35
34
 
@@ -10,6 +10,8 @@ require 'active_support/core_ext/integer/time'
10
10
  defined?(Occams::Application) && Occams::Application.configure do
11
11
  # Settings specified here will take precedence over those in config/application.rb.
12
12
 
13
+ config.active_job.queue_adapter = :test # added for Rails 7.1
14
+
13
15
  # While tests run files are not watched, reloading is not necessary.
14
16
  config.enable_reloading = false
15
17
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Be sure to restart your server when you modify this file.
3
4
 
4
5
  # Define an application-wide content security policy.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Be sure to restart your server when you modify this file.
3
4
 
4
5
  # Add new inflection rules using the following format. Inflections
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Be sure to restart your server when you modify this file.
3
4
  #
4
5
  # This file eases your Rails 7.1 framework defaults upgrade.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Be sure to restart your server when you modify this file.
3
4
 
4
5
  # Define an application-wide HTTP permissions policy. For further
@@ -116,11 +116,11 @@ en:
116
116
  update: Update Layout
117
117
 
118
118
  pages:
119
- created: Page created
119
+ created: Page created, siblings, and parent updated
120
120
  creation_failure: Failed to create page
121
- updated: Page updated
121
+ updated: Page, siblings, and parent updated
122
122
  update_failure: Failed to update page
123
- deleted: Page deleted
123
+ deleted: Page deleted, siblings, and parent updated
124
124
  not_found: Page not found
125
125
  layout_not_found: No Layouts found. Please create one.
126
126
 
data/gemfiles/6.1.gemfile CHANGED
@@ -8,31 +8,24 @@ gemspec path: '../'
8
8
  gem 'rails', '~> 6.1.0'
9
9
 
10
10
  group :development, :test do
11
- gem 'autoprefixer-rails', '~> 8.1.0'
12
- gem 'byebug', '~> 10.0.0', platforms: %i[mri mingw x64_mingw]
13
- gem 'image_processing', '>= 1.2'
11
+ gem 'autoprefixer-rails', '~> 10.4.16.0'
12
+ gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw]
13
+ gem 'image_processing', '>= 1.12.0'
14
14
  gem 'sqlite3', '~> 1.6.7'
15
15
  end
16
16
 
17
- group :development do
18
- gem 'listen', '~> 3.8.0'
19
- gem 'web-console', '~> 4.2'
20
- end
21
-
22
17
  group :test do
23
- gem 'brakeman', '~> 5.4.1'
18
+ gem 'brakeman', '~> 6.1.2'
24
19
  gem 'bundler-audit', '~> 0.9.1'
25
- gem 'capybara', '~> 3.39.0'
26
20
  gem 'coveralls_reborn', '~> 0.28.0', require: false
27
- gem 'cuprite', '~> 0.14.3'
28
- gem 'diffy', '~> 3.4.2'
21
+ gem 'cuprite', '>= 0.15'
29
22
  gem 'equivalent-xml', '~> 0.6.0'
30
- gem 'minitest', '~> 5.20.0'
31
- gem 'minitest-reporters', '~> 1.6.1'
32
- gem 'mocha', '~> 2.1.0', require: false
33
- gem 'puma', '~> 6.4.0'
23
+ gem 'minitest', '>= 5.23.0'
24
+ gem 'minitest-reporters', '>= 1.6.1'
25
+ gem 'mocha', '>= 2.3.0', require: false
34
26
  gem 'rails-controller-testing', '~> 1.0.5'
35
- gem 'rubocop', '~> 1.56.0', require: false
36
- gem 'selenium-webdriver', '~> 4.9.0'
27
+ gem 'rubocop', '~> 1.63.0', require: false
28
+ gem 'rubocop-minitest'
29
+ gem 'rubocop-rails'
37
30
  gem 'simplecov', '~> 0.22.0', require: false
38
31
  end
data/gemfiles/7.0.gemfile CHANGED
@@ -8,30 +8,24 @@ gemspec path: '../'
8
8
  gem 'rails', '~> 7.0.0'
9
9
 
10
10
  group :development, :test do
11
- gem 'autoprefixer-rails', '~> 8.1.0'
12
- gem 'byebug', '~> 10.0.0', platforms: %i[mri mingw x64_mingw]
13
- gem 'image_processing', '>= 1.2'
11
+ gem 'autoprefixer-rails', '~> 10.4.16.0'
12
+ gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw]
13
+ gem 'image_processing', '>= 1.12.0'
14
14
  gem 'sqlite3', '~> 1.6.7'
15
15
  end
16
16
 
17
- group :development do
18
- gem 'listen', '~> 3.8.0'
19
- gem 'web-console', '~> 4.2'
20
- end
21
-
22
17
  group :test do
23
- gem 'brakeman', '~> 5.4.1'
18
+ gem 'brakeman', '~> 6.1.2'
24
19
  gem 'bundler-audit', '~> 0.9.1'
25
- gem 'capybara', '~> 3.39.0'
26
20
  gem 'coveralls_reborn', '~> 0.28.0', require: false
27
- gem 'cuprite', '~> 0.14.3'
28
- gem 'diffy', '~> 3.4.2'
21
+ gem 'cuprite', '>= 0.15'
29
22
  gem 'equivalent-xml', '~> 0.6.0'
30
- gem 'minitest', '~> 5.20.0'
31
- gem 'minitest-reporters', '~> 1.6.1'
32
- gem 'mocha', '~> 2.1.0', require: false
33
- gem 'puma', '~> 6.4.0'
23
+ gem 'minitest', '>= 5.23.0'
24
+ gem 'minitest-reporters', '>= 1.6.1'
25
+ gem 'mocha', '>= 2.3.0', require: false
34
26
  gem 'rails-controller-testing', '~> 1.0.5'
35
- gem 'rubocop', '~> 1.56.0', require: false
36
- gem 'simplecov', '~> 0.22.0', require: false
27
+ gem 'rubocop', '~> 1.63.0', require: false
28
+ gem 'rubocop-minitest'
29
+ gem 'rubocop-rails'
30
+ gem 'simplecov', '~> 0.22.0', require: false
37
31
  end
data/gemfiles/7.1.gemfile CHANGED
@@ -8,30 +8,24 @@ gemspec path: '../'
8
8
  gem 'rails', '~> 7.1.0', '>= 7.1.1'
9
9
 
10
10
  group :development, :test do
11
- gem 'autoprefixer-rails', '~> 8.1.0'
12
- gem 'byebug', '~> 10.0.0', platforms: %i[mri mingw x64_mingw]
13
- gem 'image_processing', '>= 1.2'
11
+ gem 'autoprefixer-rails', '~> 10.4.16.0'
12
+ gem 'byebug', '~> 11.1.0', platforms: %i[mri mingw x64_mingw]
13
+ gem 'image_processing', '>= 1.12.0'
14
14
  gem 'sqlite3', '~> 1.6.7'
15
15
  end
16
16
 
17
- group :development do
18
- gem 'listen', '~> 3.8.0'
19
- gem 'web-console', '~> 4.2'
20
- end
21
-
22
17
  group :test do
23
- gem 'brakeman', '~> 5.4.1'
18
+ gem 'brakeman', '~> 6.1.2'
24
19
  gem 'bundler-audit', '~> 0.9.1'
25
- gem 'capybara', '~> 3.39.0'
26
20
  gem 'coveralls_reborn', '~> 0.28.0', require: false
27
- gem 'cuprite', '~> 0.14.3'
28
- gem 'diffy', '~> 3.4.2'
21
+ gem 'cuprite', '>= 0.15'
29
22
  gem 'equivalent-xml', '~> 0.6.0'
30
- gem 'minitest', '~> 5.20.0'
31
- gem 'minitest-reporters', '~> 1.6.1'
32
- gem 'mocha', '~> 2.1.0', require: false
33
- gem 'puma', '~> 6.4.0'
23
+ gem 'minitest', '>= 5.23.0'
24
+ gem 'minitest-reporters', '>= 1.6.1'
25
+ gem 'mocha', '>= 2.3.0', require: false
34
26
  gem 'rails-controller-testing', '~> 1.0.5'
35
- gem 'rubocop', '~> 1.56.0', require: false
36
- gem 'simplecov', '~> 0.22.0', require: false
27
+ gem 'rubocop', '~> 1.63.0', require: false
28
+ gem 'rubocop-minitest'
29
+ gem 'rubocop-rails'
30
+ gem 'simplecov', '~> 0.22.0', require: false
37
31
  end
@@ -7,23 +7,19 @@ require_relative 'mixins/file_content'
7
7
  # {{cms:file_link id, as: image}}
8
8
  #
9
9
  # `as` - url (default) | link | image - how file gets rendered out
10
- # `label` - attach label attribute to link or image tag
11
- # `resize` - imagemagic option. For example: "100x50>"
12
- # `gravity` - imagemagic option. For example: "center"
13
- # `crop` - imagemagic option. For example: "100x50+0+0"
14
10
  # `class` - any html classes that you want on the result link or image tag. For example "class1 class2"
15
11
  #
12
+ # - variant_attrs are not functional, perhaps due to some change in ImageMagick
13
+ # - Simply use a class in your CSS / SASS to style your image display
14
+ # `label` - attach label attribute to link or image tag
15
+ # `resize` - imagemagick option. For example: "100x50>"
16
+ # `gravity` - imagemagick option. For example: "center"
17
+ # `crop` - imagemagick option. For example: "100x50+0+0"
18
+ #
16
19
  class Occams::Content::Tags::FileLink < Occams::Content::Tag
17
20
  include Occams::Content::Tags::Mixins::FileContent
18
21
 
19
- # @return [String] A {Occams::Cms::Site#files} ID.
20
- attr_reader :identifier
21
-
22
- # @type ["url", "link", "image"]
23
- attr_reader :as
24
-
25
- # @type [{String => String}]
26
- attr_reader :variant_attrs
22
+ attr_reader :identifier, :as, :variant_attrs
27
23
 
28
24
  def initialize(context:, params: [], source: nil)
29
25
  super
@@ -32,7 +28,7 @@ class Occams::Content::Tags::FileLink < Occams::Content::Tag
32
28
  @identifier = params[0]
33
29
  @as = options['as'] || 'url'
34
30
  @class = options['class']
35
- @variant_attrs = options.slice('resize', 'gravity', 'crop')
31
+ @variant_attrs = options.slice('resize', 'gravity', 'crop') # broken for ImageMagick
36
32
 
37
33
  return if @identifier.present?
38
34
 
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'mixins/file_content'
4
+
5
+ # This is like the the file_link tag, but specifically for images
6
+ # Identify the image by its label {{ cms:image label }}
7
+ #
8
+ # `class` - any html classes that you want on the image tag. For example "class1 class2"
9
+ #
10
+ # - variant_attrs are not functional, perhaps due to some change in ImageMagick
11
+ # - Simply use a class in your CSS / SASS to style your image display
12
+ # `label` - attach label attribute to link or image tag
13
+ # `resize` - imagemagick option. For example: "100x50>"
14
+ # `gravity` - imagemagick option. For example: "center"
15
+ # `crop` - imagemagick option. For example: "100x50+0+0"
16
+
17
+ class Occams::Content::Tags::Image < Occams::Content::Tag
18
+ include Occams::Content::Tags::Mixins::FileContent
19
+
20
+ attr_reader :identifier, :as, :variant_attrs
21
+
22
+ def initialize(context:, params: [], source: nil)
23
+ super
24
+
25
+ options = params.extract_options!
26
+ @identifier = params[0]
27
+ @as = 'image'
28
+ @class = options['class']
29
+ @variant_attrs = options.slice('resize', 'gravity', 'crop') # broken for ImageMagick
30
+
31
+ return if @identifier.present?
32
+
33
+ raise Error, 'Missing identifier label for image tag'
34
+ end
35
+
36
+ # @return [Occams::Cms::File]
37
+ def file_record
38
+ @file_record ||= context.site.files.detect { |f| f.label == identifier }
39
+ end
40
+
41
+ # @return [ActiveStorage::Blob]
42
+ def file
43
+ file_record&.attachment
44
+ end
45
+
46
+ # @return [String]
47
+ def label
48
+ return '' if file_record.nil?
49
+
50
+ file_record.label.presence || file.filename.to_s
51
+ end
52
+ end
53
+
54
+ Occams::Content::Renderer.register_tag(
55
+ :image, Occams::Content::Tags::Image
56
+ )
@@ -25,7 +25,7 @@ module Occams::Content::Tags::Mixins
25
25
  when 'link'
26
26
  "<a href='#{attachment_url}'#{html_class_attribute} target='_blank'>#{label}</a>"
27
27
  when 'image'
28
- "<img src='#{attachment_url}'#{html_class_attribute} alt='#{label}'/>"
28
+ "<img src='#{attachment_url}'#{html_class_attribute} alt='#{label}' title='#{label}'/>"
29
29
  else
30
30
  attachment_url
31
31
  end
@@ -16,11 +16,14 @@ require_relative 'mixins/file_content'
16
16
  # {{ cms:page_file_link attachments, filename: "cat.jpg" }}
17
17
  #
18
18
  # `as` - url (default) | link | image - how file gets rendered out
19
+ # `class` - any html classes that you want on the result link or image tag. For example "class1 class2"
20
+ #
21
+ # - the following params are deprecated / not functional, perhaps due to some change in ImageMagick
22
+ # - Simply use a class in your CSS / SASS to style your image display
19
23
  # `label` - attach label attribute to link or image tag
20
24
  # `resize` - imagemagick option. For example: "100x50>"
21
25
  # `gravity` - imagemagick option. For example: "center"
22
26
  # `crop` - imagemagick option. For example: "100x50+0+0"
23
- # `class` - any html classes that you want on the result link or image tag. For example "class1 class2"
24
27
  #
25
28
  class Occams::Content::Tags::PageFileLink < Occams::Content::Tag
26
29
  include Occams::Content::Tags::Mixins::FileContent
@@ -31,6 +31,9 @@ class Occams::Content::Tags::Siblings < Occams::Content::Tag
31
31
  @links = ''
32
32
  # ActiveRecord_Associations_CollectionProxy
33
33
  @sibs = context.self_and_siblings.order(:position).to_ary
34
+ unless Rails.env == 'development'
35
+ @sibs.delete_if { |sib| !sib.is_published }
36
+ end
34
37
  @sibs.delete_if { |sib| @exclude.include? sib.slug }
35
38
  end
36
39
 
@@ -18,6 +18,7 @@ require_relative 'tags/files'
18
18
  require_relative 'tags/snippet'
19
19
  require_relative 'tags/asset'
20
20
  require_relative 'tags/file_link'
21
+ require_relative 'tags/image'
21
22
  require_relative 'tags/page_file_link'
22
23
  require_relative 'tags/helper'
23
24
  require_relative 'tags/partial'
data/lib/occams/error.rb CHANGED
@@ -6,19 +6,19 @@ module Occams
6
6
 
7
7
  class MissingSite < Occams::Error
8
8
  def initialize(identifier)
9
- super "Cannot find CMS Site with identifier: #{identifier}"
9
+ super("Cannot find CMS Site with identifier: #{identifier}")
10
10
  end
11
11
  end
12
12
 
13
13
  class MissingLayout < Occams::Error
14
14
  def initialize(identifier)
15
- super "Cannot find CMS Layout with identifier: #{identifier}"
15
+ super("Cannot find CMS Layout with identifier: #{identifier}")
16
16
  end
17
17
  end
18
18
 
19
19
  class MissingPage < Occams::Error
20
20
  def initialize(path)
21
- super "Cannot find CMS Page at #{path}"
21
+ super("Cannot find CMS Page at #{path}")
22
22
  end
23
23
  end
24
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Occams
4
- VERSION = '1.0.8'
4
+ VERSION = '1.1.1.1'
5
5
  end
data/occams.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  f.match(%r{^(test|doc)/})
17
17
  end
18
18
 
19
- spec.required_ruby_version = '>= 2.7.0'
19
+ spec.required_ruby_version = '>= 3.0.0'
20
20
  spec.metadata['rubygems_mfa_required'] = 'true'
21
21
 
22
22
  spec.add_dependency 'active_link_to', '~> 1.0', '>= 1.0.5'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occams
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew vonderLuft
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-29 00:00:00.000000000 Z
11
+ date: 2024-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_link_to
@@ -719,6 +719,7 @@ files:
719
719
  - lib/occams/content/tags/files.rb
720
720
  - lib/occams/content/tags/fragment.rb
721
721
  - lib/occams/content/tags/helper.rb
722
+ - lib/occams/content/tags/image.rb
722
723
  - lib/occams/content/tags/markdown.rb
723
724
  - lib/occams/content/tags/mixins/file_content.rb
724
725
  - lib/occams/content/tags/number.rb
@@ -737,8 +738,6 @@ files:
737
738
  - lib/occams/extensions/has_revisions.rb
738
739
  - lib/occams/form_builder.rb
739
740
  - lib/occams/render_methods.rb
740
- - lib/occams/routes/cms.rb
741
- - lib/occams/routes/cms_admin.rb
742
741
  - lib/occams/routing.rb
743
742
  - lib/occams/seeds.rb
744
743
  - lib/occams/seeds/file/exporter.rb
@@ -767,14 +766,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
767
766
  requirements:
768
767
  - - ">="
769
768
  - !ruby/object:Gem::Version
770
- version: 2.7.0
769
+ version: 3.0.0
771
770
  required_rubygems_version: !ruby/object:Gem::Requirement
772
771
  requirements:
773
772
  - - ">="
774
773
  - !ruby/object:Gem::Version
775
774
  version: '0'
776
775
  requirements: []
777
- rubygems_version: 3.4.13
776
+ rubygems_version: 3.5.9
778
777
  signing_key:
779
778
  specification_version: 4
780
779
  summary: Rails 6.1-7.1+ CMS Engine
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ActionDispatch::Routing::Mapper
4
- def occams_route_cms(options = {})
5
- Occams.configuration.public_cms_path = options[:path]
6
-
7
- scope module: :occams, as: :occams do
8
- namespace :cms, path: options[:path] do
9
- get 'cms-css/:site_id/:identifier(/:cache_buster)' => 'assets#render_css', as: 'render_css'
10
- get 'cms-js/:site_id/:identifier(/:cache_buster)' => 'assets#render_js', as: 'render_js'
11
-
12
- get '(*cms_path)' => 'content#show', as: 'render_page', action: '/:format'
13
- end
14
- end
15
- end
16
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ActionDispatch::Routing::Mapper
4
- def occams_route_cms_admin(path: 'admin')
5
- scope module: :occams, as: :occams do
6
- scope module: :admin do
7
- namespace :cms, as: :admin_cms, path: path, except: :show do
8
- get '/', to: 'base#jump'
9
-
10
- concern :with_revisions do |options|
11
- resources :revisions, options.merge(only: %i[index show]) do
12
- patch :revert, on: :member
13
- end
14
- end
15
-
16
- concern :with_reorder do
17
- put :reorder, on: :collection
18
- end
19
-
20
- concern :with_form_fragments do
21
- get :form_fragments, on: :member
22
- end
23
-
24
- resources :sites do
25
- resources :pages do
26
- concerns :with_reorder
27
- concerns :with_form_fragments
28
- concerns :with_revisions, controller: 'revisions/page'
29
-
30
- get :toggle_branch, on: :member
31
-
32
- resources :translations, except: [:index] do
33
- concerns :with_form_fragments
34
- concerns :with_revisions, controller: 'revisions/translation'
35
- end
36
- end
37
-
38
- resources :files, concerns: [:with_reorder]
39
-
40
- resources :layouts do
41
- concerns :with_reorder
42
- concerns :with_revisions, controller: 'revisions/layout'
43
- end
44
-
45
- resources :snippets do
46
- concerns :with_reorder
47
- concerns :with_revisions, controller: 'revisions/snippet'
48
- end
49
-
50
- resources :categories
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end