opengraphplus 0.1.8 → 0.1.9
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 +4 -4
- data/README.md +15 -0
- data/lib/opengraphplus/image_generator.rb +6 -14
- data/lib/opengraphplus/rails/controller.rb +4 -7
- data/lib/opengraphplus/version.rb +1 -1
- data/lib/opengraphplus.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 54b7d84e954c55e6ba849b802b923d7e167ec9190a6c1cc19f6ac76a1251ea45
|
|
4
|
+
data.tar.gz: 912f50347ee1ffd7de4a01ed1e92b2ed63646512b2a4987b8b148f8ad8fdbb45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c0dce1160417409c38262b31da5d92678890c4ac34b94351e7e09ba65c6a56bd5b063923ffffcb60fe2b9d8d70d86a35c0f15aa3f28e24af7f2c9626371e7d0
|
|
7
|
+
data.tar.gz: 87b21217de703b737150ccf352462d018a371c875119151259cdefbaa402db3827b8fb02193290218f47485f8b084c4f3e07a11d31b9233974e7ec8557346f1c
|
data/README.md
CHANGED
|
@@ -68,6 +68,21 @@ OpenGraphPlus.configure do |config|
|
|
|
68
68
|
end
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
## Capturing a Different URL
|
|
72
|
+
|
|
73
|
+
By default, OpenGraphPlus screenshots the current request URL for the `og:image`. To screenshot a different URL (e.g., a public preview page when the main page requires authentication):
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
class ArticlesController < ApplicationController
|
|
77
|
+
open_graph do |og|
|
|
78
|
+
og.title = "My Article"
|
|
79
|
+
og.image.url = open_graph_plus_image_url(url_for(format: :opengraph))
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The `open_graph_plus_image_url` helper is available in both controllers and views. It generates a signed URL that tells OpenGraphPlus to screenshot the provided URL instead of the current request.
|
|
85
|
+
|
|
71
86
|
## Verifying OpenGraph Tags
|
|
72
87
|
|
|
73
88
|
You can verify that your pages have the required OpenGraph tags using the included command:
|
|
@@ -2,24 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module OpenGraphPlus
|
|
4
4
|
class ImageGenerator
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def initialize(request)
|
|
8
|
-
@request = request
|
|
5
|
+
def initialize(api_key)
|
|
6
|
+
@api_key = api_key
|
|
9
7
|
end
|
|
10
8
|
|
|
11
|
-
def url
|
|
12
|
-
return nil unless api_key
|
|
9
|
+
def url(source_url)
|
|
10
|
+
return nil unless @api_key
|
|
13
11
|
|
|
14
12
|
Signature::URL.new
|
|
15
|
-
.signed_path("/api/websites/v1", api_key)
|
|
16
|
-
.build("image", url:
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def api_key
|
|
22
|
-
@api_key ||= OpenGraphPlus.configuration.api_key
|
|
13
|
+
.signed_path("/api/websites/v1", @api_key)
|
|
14
|
+
.build("image", url: source_url)
|
|
23
15
|
end
|
|
24
16
|
end
|
|
25
17
|
end
|
|
@@ -7,7 +7,7 @@ module OpenGraphPlus
|
|
|
7
7
|
include OpenGraphPlus::Rails::Helper
|
|
8
8
|
|
|
9
9
|
included do
|
|
10
|
-
helper_method :open_graph, :open_graph_tags, :open_graph_meta_tags
|
|
10
|
+
helper_method :open_graph, :open_graph_tags, :open_graph_meta_tags, :open_graph_plus_image_url
|
|
11
11
|
before_action :set_default_open_graph
|
|
12
12
|
append_before_action :set_default_open_graph_image
|
|
13
13
|
end
|
|
@@ -18,8 +18,8 @@ module OpenGraphPlus
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def
|
|
22
|
-
|
|
21
|
+
def open_graph_plus_image_url(source_url = request.original_url)
|
|
22
|
+
OpenGraphPlus.image_url(source_url)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
private
|
|
@@ -30,10 +30,7 @@ module OpenGraphPlus
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def set_default_open_graph_image
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
generated_url = open_graph_image_generator.url
|
|
36
|
-
open_graph.image.url = generated_url if generated_url
|
|
33
|
+
open_graph.image.url ||= open_graph_plus_image_url
|
|
37
34
|
end
|
|
38
35
|
end
|
|
39
36
|
end
|
data/lib/opengraphplus.rb
CHANGED
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.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brad Gessler
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-01-
|
|
10
|
+
date: 2026-01-10 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|