-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- bump to Rails 7.1.3.3 - bugfix: uploaded files index page was blank - create cms:image tag, simplifying from cms:file_link - add 'title' attribute to images - update and optimize test suite - update gems
- Loading branch information
1 parent
15027d1
commit 1d96893
Showing
29 changed files
with
216 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
require: | ||
# - rubocop-rails | ||
# - rubocop-minitest | ||
|
||
AllCops: | ||
TargetRubyVersion: 2.7 | ||
NewCops: enable | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# ToDos | ||
|
||
- set up Buildkite CI and add build badge to README | ||
- add duplicate page function in admin UI | ||
- add admin content search to list layouts, pages and snippets - see https://blog.robertsj.com/search/ | ||
- add application console for testing | ||
- add feature to resize file_link'd images | ||
- diagnose and correct failure of ImageMagick params in file_link and image cms tags | ||
- lint for rubocop-rails and rubocop-minitest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'mixins/file_content' | ||
|
||
# This is like the the file_link tag, but specifically for images | ||
# Identify the image by its label {{ cms:image label }} | ||
# | ||
# `class` - any html classes that you want on the image tag. For example "class1 class2" | ||
# | ||
# - variant_attrs are not functional, perhaps due to some change in ImageMagick | ||
# - Simply use a class in your CSS / SASS to style your image display | ||
# `label` - attach label attribute to link or image tag | ||
# `resize` - imagemagick option. For example: "100x50>" | ||
# `gravity` - imagemagick option. For example: "center" | ||
# `crop` - imagemagick option. For example: "100x50+0+0" | ||
|
||
class Occams::Content::Tags::Image < Occams::Content::Tag | ||
include Occams::Content::Tags::Mixins::FileContent | ||
|
||
attr_reader :identifier, :as, :variant_attrs | ||
|
||
def initialize(context:, params: [], source: nil) | ||
super | ||
|
||
options = params.extract_options! | ||
@identifier = params[0] | ||
@as = 'image' | ||
@class = options['class'] | ||
@variant_attrs = options.slice('resize', 'gravity', 'crop') # broken for ImageMagick | ||
|
||
return if @identifier.present? | ||
|
||
raise Error, 'Missing identifier label for image tag' | ||
end | ||
|
||
# @return [Occams::Cms::File] | ||
def file_record | ||
@file_record ||= context.site.files.detect { |f| f.label == identifier } | ||
end | ||
|
||
# @return [ActiveStorage::Blob] | ||
def file | ||
file_record&.attachment | ||
end | ||
|
||
# @return [String] | ||
def label | ||
return '' if file_record.nil? | ||
|
||
file_record.label.presence || file.filename.to_s | ||
end | ||
end | ||
|
||
Occams::Content::Renderer.register_tag( | ||
:image, Occams::Content::Tags::Image | ||
) |
Oops, something went wrong.