opengraphplus 0.1.15 → 0.1.16

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: 36436838c92a8e927fccd2f81c56cdaa0c77685b763ae7a942c3ebfdbd3740cf
4
- data.tar.gz: 3bc5a59c5d6f787effcec54b7727761d999ea04786a9dcf6506d1686f99368e0
3
+ metadata.gz: 560d079e7cf4a5ef84766fd42c4b012197d2dc7d6ea10220e56ec8a0a1af99fc
4
+ data.tar.gz: d348f8e8a9e80d83ef76bdf3b71e87bffb2491b77d67e16167532a11872ae270
5
5
  SHA512:
6
- metadata.gz: cb42ce974d15655f9320209a5f8ac669c0cc96624c9dd0b515a739f9de00ff10576e430a0e44f1b9d56b1e340ccc30cefbd9b318a09d9948d1ead093059ebb0c
7
- data.tar.gz: 6fb376cccc4f2d52f5659aee2a5c31d26b840f219ebaa8eb270a3c8f8246cb1f11dc03857943b19729ce00fe377b4eb1af9c5c62fe0f4728b3045a7131f7001e
6
+ metadata.gz: 720d8ddd5464df7581e8e7c30a51265a6cfed6cc5888140e546c8af47e970eab700928f4fd592c2c04477639dfd050f7c126464759cd72c079ed2d9278f0ac9a
7
+ data.tar.gz: b0f00ec27e925aabd42b69e2287c884fc48702b660d3f9059a9d911078be0a52e082ec06643de47f0a2617c96a19c54ea2a5071e63b568743074fdc233acdd0d
@@ -7,4 +7,8 @@ OpenGraphPlus.configure do |config|
7
7
 
8
8
  # Or use ENV:
9
9
  # config.api_key = ENV["OGPLUS__API_KEY"]
10
+
11
+ # Set base_url for static site generators (e.g., Sitepress) where
12
+ # request.url is not available at compile time:
13
+ # config.base_url = "https://example.com"
10
14
  end
@@ -1,14 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "uri"
4
+
3
5
  module OpenGraphPlus
4
6
  class Configuration
5
7
  DEFAULT_URL = "https://opengraphplus.com"
6
8
 
7
- attr_accessor :url
9
+ attr_accessor :api_url, :base_url
8
10
 
9
11
  def initialize
10
12
  @api_key = nil
11
- @url = DEFAULT_URL
13
+ @api_url = DEFAULT_URL
14
+ @base_url = nil
15
+ end
16
+
17
+ def resolve_url(request)
18
+ if @base_url
19
+ URI.join(@base_url, request.path).to_s
20
+ elsif request.respond_to?(:host) && request.host.present?
21
+ request.url
22
+ else
23
+ warn "[OpenGraphPlus] Cannot determine site URL. Set OpenGraphPlus.configuration.base_url for static site generation."
24
+ nil
25
+ end
12
26
  end
13
27
 
14
28
  def api_key
@@ -8,7 +8,6 @@ module OpenGraphPlus
8
8
 
9
9
  included do
10
10
  helper_method :open_graph, :open_graph_tags, :open_graph_meta_tags, :open_graph_plus_image_url
11
- before_action :set_default_open_graph
12
11
  append_before_action :set_default_open_graph_image
13
12
  end
14
13
 
@@ -18,17 +17,12 @@ module OpenGraphPlus
18
17
  end
19
18
  end
20
19
 
21
- def open_graph_plus_image_url(source_url = request.url)
20
+ def open_graph_plus_image_url(source_url = open_graph.url)
22
21
  OpenGraphPlus.image_url(source_url)
23
22
  end
24
23
 
25
24
  private
26
25
 
27
- def set_default_open_graph
28
- open_graph.type = "website"
29
- open_graph.url = request.url
30
- end
31
-
32
26
  def set_default_open_graph_image
33
27
  open_graph.image.url ||= open_graph_plus_image_url
34
28
  end
@@ -24,7 +24,7 @@ module OpenGraphPlus
24
24
  def default_open_graph
25
25
  Namespace::Root.new.tap do |root|
26
26
  root.type = "website"
27
- root.url = request.url if request
27
+ root.url = OpenGraphPlus.configuration.resolve_url(request) if request
28
28
  end
29
29
  end
30
30
  end
@@ -8,7 +8,7 @@ module OpenGraphPlus
8
8
  attr_reader :base
9
9
  alias :base_url :base
10
10
 
11
- def initialize(url: OpenGraphPlus.configuration.url)
11
+ def initialize(url: OpenGraphPlus.configuration.api_url)
12
12
  @base = URI.parse(url)
13
13
  end
14
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenGraphPlus
4
- VERSION = "0.1.15"
4
+ VERSION = "0.1.16"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opengraphplus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-01-23 00:00:00.000000000 Z
10
+ date: 2026-02-13 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport