venus_media_library 1.1.0 → 1.1.2

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: 53f9b683221215b76b95f0248dd87938ebba0a7066c36ccc7b02dc23fece50e0
4
- data.tar.gz: acf9d06d3f9a7712568f9f05c9584ccc9fda2772de1bcad6e1b2090c1cf07e8f
3
+ metadata.gz: c419936bf15b299264f23527fa0d74f57860c031e279ada4cb04608a7d55e9d9
4
+ data.tar.gz: a6f877818f76baf0c43ad806109b981ba63e896ab53dcd01c6b855baf708f439
5
5
  SHA512:
6
- metadata.gz: e1d247beff66e7d45750fcfa96813cdcb0bb7ed5a2cb0eb500486602f4b8354001ffc280fe399fbb504ad094b2e97b3715cb578b29e2aabce34d34b82fd4037f
7
- data.tar.gz: e8928ccd013a969ff08cfef454886735297e5a74d84acc9b66a09335be91ede3a1a9f4f3dfbe59ede7a3b16acc4438b461b73b8c43c550e5ce01e989555b2999
6
+ metadata.gz: 4d4cd43c0e4b6945eac1bc77b9009b949e3b42bfcb3e9d241f1dc1fad99e5a623a9c0947525e6216ba5edf1d952fb0560405397b56600dc11748da1c89eb701b
7
+ data.tar.gz: 3c7794fb4b5f9ca228a12c8f78cb526c5e8d5a580beaeb6f7316cdc22fb464b46907dff569bb5b799419a5b1c9ff2e91b79db9040b134de29cb88e1a2f707596
data/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ All notable changes to this project are documented here. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres
5
5
  to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.1.2] - 2026-08-19
8
+
9
+ ### Changed
10
+ - The default admin predicate now recognises both the `admin?` **and**
11
+ `is_admin?` conventions (and returns non-admin for `nil`) instead of assuming
12
+ `admin?`. A host whose user model uses `is_admin?` no longer needs to set
13
+ `config.admin` just to avoid a `NoMethodError` from the role-gated library nav.
14
+ Any other scheme remains fully configurable via `config.admin`.
15
+
16
+ ## [1.1.1] - 2026-08-19
17
+
18
+ ### Fixed
19
+ - The picker now hands host URL fields (via `media_picker_field`, e.g. an
20
+ `og:image`) an **absolute, public** Active Storage URL (honoring
21
+ `config.url_type`) instead of the relative, owner-gated `/…/assets/:id` engine
22
+ route. Since 1.0.0 that route was not fetchable by external crawlers, silently
23
+ breaking og:image, social cards, and image SEO. In-admin grid thumbnails keep
24
+ using the gated route, and owner-scoped access is unchanged.
25
+
7
26
  ## [1.1.0] - 2026-08-18
8
27
 
9
28
  ### Added
@@ -19,16 +19,36 @@ module VenusMediaLibrary
19
19
  }
20
20
  end
21
21
 
22
- # Permanent URL to the original file. Active Storage route helpers live on the
23
- # host app, so they are reached through the `main_app` proxy. With
24
- # url_type = :proxy the URL streams through Rails (works for private buckets
25
- # and external crawlers); the default :redirect 302s to the storage URL.
22
+ # Permanent, PUBLIC URL to the original file this is the value the picker
23
+ # writes into a host URL field (e.g. a page's og:image), so it must be
24
+ # absolute and fetchable by external crawlers (Facebook/Google/Twitter) with
25
+ # no session. It therefore uses Rails' public Active Storage routes, NOT the
26
+ # engine's owner-gated `asset_path` (an anonymous crawler hitting that route
27
+ # is bounced by the host's `authenticate_with` gate, silently breaking
28
+ # og:image / social cards). Owner-scoping still governs WHICH assets a member
29
+ # can SEE in the library (see visible_media_assets); it is orthogonal to the
30
+ # public URL a picked asset resolves to. Active Storage route helpers live on
31
+ # the host app, so they are reached through the `main_app` proxy. With
32
+ # url_type = :proxy the URL streams through Rails (works for private buckets);
33
+ # the default :redirect 302s to the storage URL. Mirrors PickerHelper's
34
+ # attach-mode preview so URL fields and attachment fields agree.
26
35
  def ml_blob_url(asset)
27
- venus_media_library.asset_path(asset)
36
+ if VenusMediaLibrary.configuration.url_type == :proxy
37
+ main_app.rails_storage_proxy_url(asset.blob)
38
+ else
39
+ main_app.rails_blob_url(asset.blob)
40
+ end
41
+ rescue StandardError
42
+ # Last resort only: a relative path keeps the admin grid rendering when a
43
+ # URL host is unavailable. Absolute public URLs above are what host URL
44
+ # fields need; this fallback should not be the stored og:image value.
45
+ main_app.rails_blob_path(asset.blob)
28
46
  end
29
47
 
30
- # Small variant used for the grid thumbnail. Falls back to the original URL
31
- # when the blob can't be variated (e.g. SVG).
48
+ # Small variant used for the in-admin grid thumbnail. This runs behind the
49
+ # engine's auth in the admin library UI, so the owner-scoped engine route is
50
+ # correct here (it also honors the per-tenant visibility rules). Only the
51
+ # picked `url` above needs to be public.
32
52
  def ml_thumb_url(asset)
33
53
  venus_media_library.thumbnail_asset_path(asset)
34
54
  end
@@ -1,3 +1,3 @@
1
1
  module VenusMediaLibrary
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -62,6 +62,18 @@ module VenusMediaLibrary
62
62
  # does not enumerate a cloud bucket or expose storage-provider credentials.
63
63
  attr_accessor :cloud_assets
64
64
 
65
+ # Default admin predicate. A gem shouldn't break just because a host app names
66
+ # its flag differently, so try the two common conventions — `admin?` then
67
+ # `is_admin?` — and fall back to non-admin. Hosts with any other scheme set
68
+ # their own `config.admin = ->(user) { ... }`.
69
+ DEFAULT_ADMIN = lambda do |user|
70
+ return false if user.nil?
71
+ return !!user.admin? if user.respond_to?(:admin?)
72
+ return !!user.is_admin? if user.respond_to?(:is_admin?)
73
+
74
+ false
75
+ end
76
+
65
77
  def initialize
66
78
  @allowed_content_types = %w[image/png image/jpeg image/jpg image/gif image/webp image/svg+xml]
67
79
  @thumbnail_size = [ 300, 300 ]
@@ -71,7 +83,7 @@ module VenusMediaLibrary
71
83
  @url_type = :redirect
72
84
  @authenticate_with = nil
73
85
  @current_user = -> { current_user }
74
- @admin = ->(user) { user.admin? }
86
+ @admin = DEFAULT_ADMIN
75
87
  @asset_scope = ->(scope) { scope }
76
88
  @legacy_blob_scope = ->(scope) { scope.none }
77
89
  @static_assets = -> { [] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: venus_media_library
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Good Works On Earth