Ben Halpern
aab0a19011
Allow configuration to conditionally prefer Cloudflare over Cloudinary ( #20539 )
...
* Allow configuration to conditionally prefer Cloudflare over Cloudinary
* Update app/services/images/optimizer.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Fix some lints
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-01-19 09:45:36 -05:00
Ben Halpern
98c92bcde2
Fix never_imagga for imgproxy ( #19997 )
2023-08-24 19:00:23 -04:00
Ben Halpern
1463d8c98a
Do not crop with imagga if never_imagga is passed ( #19975 )
...
* Do not crop with imagga if never_imagga is passed
* Clean up code styles
2023-08-22 11:52:02 -04:00
Ben Halpern
ec7adf56fe
Allow admins to set cover image height configs ( #19936 )
...
* Initial basic work
* Bulk of related work, including find/replace on the inputs
* Adjust some tests
* Adjust some specs
* Fix a few more tests
* Clean up tests
* Adjust tests
* Test fiddle
* Adjust crop back to be a param
* Update tests
* Set proper defaults
* Fix some styling
* Adjust enrichment logic and tests
* Adjust form JS
* Update test snapshot
* Clean up formatting
* Fix spec name
* Adjust some css and defaults
* Adjust translation for image provider options
* Switch from fill to fill-down
* Proper fallback image
* Fix tests
* Update app/services/images/optimizer.rb
Co-authored-by: Mac Siri <mac@forem.com>
---------
Co-authored-by: Mac Siri <mac@forem.com>
2023-08-21 13:25:16 -04:00
Ben Halpern
0c92bc3f27
Full minimagick social image rollout ( #19949 )
...
* Full minimagick social image rollout
* Fix errant puts
* Remove unnecessary file
2023-08-21 09:11:14 -04:00
Ben Halpern
33b11f1eac
Use direct relative path to access assets in minimagick ( #19933 )
...
* Use direct relative path to access assets in minimagick
* Skip Hairtrigger spec
* Add a test to get more coverage
2023-08-15 09:36:16 -04:00
Ben Halpern
c9af090af0
Prefer Minimagick for social image generation ( #19826 )
...
* Prefer Minimagick for social image generation
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Reformat main file
* Fix user tests
* Finish up tests
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Change asset path syntax
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Refactor magickally file
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Fix style issues
* Remove pure black
* Test color swap
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add more test coverage to service
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Fix doubled spec name
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add upload spec
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/generate_social_image_magickally_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Swap out magickally in social image worker
* Add test stub and rescue
* Update spec/rails_helper.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Fix regex
* Add cache busting and error logging
* Update app/services/images/generate_social_image_magickally.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Fix style issues
* Add more test coverage
* Add feature flag
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-11 08:22:06 -04:00
Duke Greene
9a6f04bd37
api v1 endpoint for creating an organization ( #19778 )
...
* api v1 endpoint for creating an organization
* address failing specs, regenerate swagger docs
* remove old comment in destroy now that woreker call takes third argument
* refactor our services for profile images into images folder
2023-07-21 07:43:56 -04:00
Ben Halpern
f0e99c6279
Add Cloudflare to Images::Optimizer options (proof of concept) ( #19574 )
...
* Add cloudflare image option
* Add tests for cloudflare
* Update app/services/images/optimizer.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Avoid nested prefixes in cloudflare
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/optimizer.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Rebase
* Refactor optimizer and finalize tests
* Skips scheduled posts in featured post count (#19563 )
* Add image title for comment (#19586 )
* Add image title for comment
* Break out boolean logic
* Add organizations to onboarding follow suggestions (#19564 )
* Prepare: relocate user suggestions
* Prepare: relocate users suggestion service -> query
* Organization query for orgs with above-average scores
* Rubocop
* Limit to last 3 weeks
* Tweak recent scope, limit to 5 orgs
* Onboarding routes are also always JSON
* Divide by zero makes NaN means
* Add Orgs suggester into suggestions
* Rubocop
* select distinct orgs
* Fix for weird edge-case with bad local data
* Include type_identifier in JSON payload
* Update follows API to allow org_ids as input
* Update onboarding front-end to distinguish users/orgs
* Fix: i18n issues
* Fix: type_identifier in json output
* Fix: distinct is weird
* Fix: JS linter
* Continue tweaking front-end
* Audit import order
* Cleanup @todo note
* Try renaming controller action
* Move Article average calculation to postgres and fix math
* Refactor decorated type_identifier
* Refactor SuggestProminent, return more orgs, fix spec math
* Use FeatureFlag for organization suggestions
* This might fix the jest
* Sort organization members and tag moderators by badge count (#19582 )
* show tag moderators in descending badge count order
* show organization users in descending badge count order
* specs & docs for find_each_respecting_scope
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/optimizer.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Remove cloudflare typo
* Adjust cloudflare prefix line in tests
* Clean up test logic
* Update spec/services/images/optimizer_spec.rb
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update app/services/images/optimizer.rb
Co-authored-by: Mac Siri <mac@forem.com>
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Joshua Wehner <joshua@forem.com>
Co-authored-by: Dhurba baral <dhurba87@gmail.com>
Co-authored-by: PJ <pj@forem.com>
Co-authored-by: Mac Siri <mac@forem.com>
2023-06-21 09:42:06 -04:00
Jeremy Friesen
5534a8fa18
Addressing rubocop violations ( #16156 )
...
```shell
❯ bundle exec rubocop -A
Inspecting 1856 files
Offenses:
app/controllers/admin/settings/mandatory_settings_controller.rb:17:57: C: [Corrected] Rails/CompactBlank: Use compact_blank instead.
settings_model.public_send("#{key}=", value.reject(&:blank?)) if value.present?
^^^^^^^^^^^^^^^^
app/controllers/users_controller.rb:66:58: C: [Corrected] Rails/CompactBlank: Use compact_blank instead.
Honeycomb.add_field("error", @user.errors.messages.reject { |_, v| v.empty? })
^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/users_controller.rb:280:58: C: [Corrected] Rails/CompactBlank: Use compact_blank instead.
Honeycomb.add_field("error", @user.errors.messages.reject { |_, v| v.empty? })
^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/settings/base.rb:111:54: C: [Corrected] Rails/CompactBlank: Use compact_blank instead.
value.split(separator || SEPARATOR_REGEXP).reject(&:empty?).map(&:strip)
^^^^^^^^^^^^^^^^
app/services/articles/feeds/weighted_query_strategy.rb:269:121: C: Layout/LineLength: Line is too long. [126/120] (https://rubystyle.guide#max-line-length )
def initialize(user: nil, number_of_articles: 50, page: 1, tag: nil, strategy: AbExperiment::ORIGINAL_VARIANT, **config)
^^^^^^
app/services/images/optimizer.rb:27:50: C: [Corrected] Rails/CompactBlank: Use compact_blank instead.
options = DEFAULT_CL_OPTIONS.merge(kwargs).reject { |_, v| v.blank? }
^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/images/optimizer.rb:46:68: C: [Corrected] Rails/CompactBlank: Use compact_blank instead.
options = DEFAULT_IMGPROXY_OPTIONS.merge(translated_options).reject { |_, v| v.blank? }
^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/settings/upsert.rb:30:55: C: [Corrected] Rails/CompactBlank: Use compact_blank instead.
settings_class.public_send("#{key}=", value.reject(&:blank?))
^^^^^^^^^^^^^^^^
1856 files inspected, 8 offenses detected, 7 offenses corrected
```
After this commit:
```shell
❯ bundle exec rubocop
Inspecting 1856 files
1856 files inspected, no offenses detected
```
1856 files inspected, no offenses detected
2022-01-17 17:21:06 -05:00
Jeremy Friesen
a65954107f
Refactoring to add helper method ( #16064 )
...
* Refactoring to add helper method
Prior to this commit, we made view level calls to service modules. This
refactor provides convenience methods on the model.
Furthermore, it addresses a few Rubocop violations that "come along for
the ride."
* Ensuring cached entity squaks like User
* Fixing broken spec
* Fixing typo
2022-01-12 11:21:44 -05:00
Jamie Gaskins
70cf28ca7b
Fix rotation of images uploaded from iPhones ( #15010 )
...
* Fix rotation of images uploaded from iPhones
iPhones[1] take pictures in portrait mode with the orientation set to
90ºCCW. We noticed that uploading one of these images to a Forem
instance caused the image to be rotated when rendered. The current
theory is that Imgproxy is not maintaining the orientation value when
processing, which is solved by setting `auto_rotate: true` (serialized
into the Imgproxy URL as `ar:1`), according to the documentation.
See: 8e6585e28d/docs/generating_the_url_advanced.md (auto-rotate)
[1] This probably happens with other phones, but we discovered the issue
using an iPhone.
* Fix Imgproxy URL expectation for auto_rotate
2021-10-11 15:17:14 -04:00
rhymes
a798bd2f7d
[15 min fix] Fallback to the image URL if Cloudinary/Imgproxy are not configured ( #13767 )
...
* Fallback to the image URL if neither Cloudinary nor Imgproxy are configured
* Fix specs
* Cloudinary api_secret is required
* Update spec/models/message_spec.rb
Co-authored-by: Michael Kohl <citizen428@dev.to>
Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-05-19 15:03:20 +02:00
Mac Siri
009c14653a
Fix app/services' ruby 2.7 kwargs warnings ( #13177 )
2021-04-01 18:40:50 -04:00
Mac Siri
e31da314a2
Nullify fetch_format for Imgproxy ( #12988 )
2021-03-16 10:36:27 -04:00
Mac Siri
bd8e800b39
Bump imgproxy to 2.0 ( #12963 )
2021-03-11 08:24:13 -05:00
Dany Marcoux
4022ea9fc0
Fix deprecation warnings ( #12339 )
...
* Fix deprecation warnings in Images::Optimizer
The deprecation warnings were:
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
warning: The called method `cloudinary' is defined here
and
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
warning: The called method `imgproxy' is defined here
* Fix deprecation warning in Slack::Messengers::ArticlePublished
The deprecation warning was:
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
warning: The called method `initialize' is defined here
2021-01-20 10:01:20 +01:00
Ben Halpern
1a25fb3542
Add max_bytes to imgproxy. ( #12110 )
...
* Add format to image optimizer
* Only use max bytes
* Fix show view spec
2021-01-04 14:41:32 -05:00
Ben Halpern
ad1a59a14c
Fix html variant image prefix logic ( #11917 )
...
* Fix html variant image prefix logic
* Update app/models/html_variant.rb
Co-authored-by: Mac Siri <mac@dev.to>
* Update spec/models/html_variant_spec.rb
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
* Use helper to simplify url code and update spec
* Provide Imgproxy default endpoint
Co-authored-by: Mac Siri <mac@dev.to>
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2020-12-15 14:44:11 -05:00
Michael Kohl
1e9487b69b
Generalize social image path and clean up code ( #11741 )
2020-12-07 11:20:10 +07:00
Michael Kohl
195e228307
Move GeneratedImage to Images::GenerateSocialmage ( #11691 )
2020-12-02 11:03:14 +07:00
Mac Siri
c4fdeeb944
Make Images::Optimizer nil-safe ( #11584 )
2020-11-24 09:39:34 -05:00
Mac Siri
c817737748
Expand cropping options for Imgproxy ( #11044 )
2020-10-26 14:25:21 -04:00
Mac Siri
ef6c3838d4
Ignore relative url in Images::Optimizer ( #10925 )
...
* Ignore relative url in Images::Optimizer
* Add spec
* Create DUS
2020-10-19 16:50:43 -04:00
Mac Siri
30fa3b79a3
Default to Imgproxy on Forem-cloud ( #10819 )
2020-10-14 12:54:59 -04:00
Mac Siri
e7c1b3e993
Move Imgproxy endpoint config to Images::Optimizer ( #10742 )
2020-10-09 10:50:30 -04:00
Mac Siri
8d9db4cce1
Update Imgproxy to use predetermined endpoint ( #10412 )
2020-09-28 18:30:29 -04:00
Mac Siri
9ebd742712
[deploy] Reintroduce sticky_nav changes ( ab81f36 & 7f92855) ( #10263 )
...
* Revert "[deploy] Revert removal of unneeded eager load (if needed) (#10179 )"
This reverts commit 11c7b148da .
* Revert "[deploy] Revert "Migrate ProfileImage to Images::Profile (#10055 )" (#10149 )"
This reverts commit 5657067e55 .
2020-09-09 15:33:13 -04:00
Molly Struve
5657067e55
[deploy] Revert "Migrate ProfileImage to Images::Profile ( #10055 )" ( #10149 )
...
This reverts commit ab81f36a38 .
2020-09-01 18:28:58 -05:00
Mac Siri
ab81f36a38
[deploy] Migrate ProfileImage to Images::Profile ( #10055 )
2020-09-01 17:16:03 -04:00
Mac Siri
b5be5990e4
[deploy] Expand Images::Optimizer to support imgproxy ( #9909 )
...
* Create _comment.html.erb spec
* Add imgproxy.rb
* Setup imgproxy MVP
* Expand Images::Optimizer to support imgproxy
* Enable imgproxy in dashboards/show WIP
* Create view spec
* Fix typo
* Also check for Imgproxy.config.endpoint
* Use ApplicationConfig instead of ENV
* Update Images::Optimizer#call
2020-08-25 16:00:40 -04:00
Mac Siri
a081810946
[deploy] Migrate ImageResizer to Images::Optimizer ( #9720 )
2020-08-14 09:44:30 -04:00