opengraphplus 0.1.14 → 0.1.15

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: 10df3058fbeea6414053da76b507503526c50987b49d238ae8f4e7e2900640ec
4
- data.tar.gz: 3f52b177acdc10d01c96ba6cc415612c0b1b961d86643e99ee5493a7a485957c
3
+ metadata.gz: 36436838c92a8e927fccd2f81c56cdaa0c77685b763ae7a942c3ebfdbd3740cf
4
+ data.tar.gz: 3bc5a59c5d6f787effcec54b7727761d999ea04786a9dcf6506d1686f99368e0
5
5
  SHA512:
6
- metadata.gz: c34b5400902ebd04679b1622fba7f775a6ff8edf904b3190f86388c57deb03d86cd02bec7b1848f83303abe5d9c4203733f05e84e3dc1119e8b6cd925febae03
7
- data.tar.gz: 0e8ab569a82361fbdbdbcbca0d911772c2bd5fccfc30643086748c3775990fedf854e759706be5a4e5a5010515e6e51ab98dd5192a5bc68fbf07e6f459b65b14
6
+ metadata.gz: cb42ce974d15655f9320209a5f8ac669c0cc96624c9dd0b515a739f9de00ff10576e430a0e44f1b9d56b1e340ccc30cefbd9b318a09d9948d1ead093059ebb0c
7
+ data.tar.gz: 6fb376cccc4f2d52f5659aee2a5c31d26b840f219ebaa8eb270a3c8f8246cb1f11dc03857943b19729ce00fe377b4eb1af9c5c62fe0f4728b3045a7131f7001e
@@ -17,9 +17,19 @@ module Opengraphplus
17
17
  inject_into_class "app/controllers/application_controller.rb", "ApplicationController", <<-RUBY
18
18
 
19
19
  open_graph do |og|
20
- og.type = "website"
21
- og.url = request.original_url
22
- og.site_name = Rails.application.class.module_parent_name.titleize
20
+ # Change to the name of your website. Required for Open Graph
21
+ # consumers like Twitter.
22
+ og.site_name = "My Website"
23
+
24
+ if Rails.env.production?
25
+ # Most Rails sites don't use cache headers, so we set a default
26
+ # max_age in the meta tags to avoid excessive preview image rendering.
27
+ #
28
+ # If you do manage HTTP cache headers in your Rails application, you
29
+ # can delete this tag and/or set this in controllers that don't have
30
+ # caching set.
31
+ og.plus.cache.max_age = 10.minutes
32
+ end
23
33
  end
24
34
  RUBY
25
35
  end
@@ -53,6 +53,17 @@ module OpenGraphPlus
53
53
  end
54
54
  end
55
55
 
56
+ class Cache < Base
57
+ attr_accessor :max_age, :etag
58
+
59
+ def tags
60
+ [
61
+ tag("og:plus:cache:max_age", max_age),
62
+ tag("og:plus:cache:etag", etag)
63
+ ].compact
64
+ end
65
+ end
66
+
56
67
  class Plus < Base
57
68
  attr_accessor :selector, :style
58
69
 
@@ -69,11 +80,16 @@ module OpenGraphPlus
69
80
  @viewport ||= Viewport.new
70
81
  end
71
82
 
83
+ def cache
84
+ @cache ||= Cache.new
85
+ end
86
+
72
87
  def tags
73
88
  [
74
89
  tag("og:plus:selector", selector),
75
90
  tag("og:plus:style", style),
76
- *viewport.tags
91
+ *viewport.tags,
92
+ *cache.tags
77
93
  ].compact
78
94
  end
79
95
 
@@ -18,7 +18,7 @@ module OpenGraphPlus
18
18
  end
19
19
  end
20
20
 
21
- def open_graph_plus_image_url(source_url = request.original_url)
21
+ def open_graph_plus_image_url(source_url = request.url)
22
22
  OpenGraphPlus.image_url(source_url)
23
23
  end
24
24
 
@@ -26,7 +26,7 @@ module OpenGraphPlus
26
26
 
27
27
  def set_default_open_graph
28
28
  open_graph.type = "website"
29
- open_graph.url = request.original_url
29
+ open_graph.url = request.url
30
30
  end
31
31
 
32
32
  def set_default_open_graph_image
@@ -4,7 +4,7 @@ module OpenGraphPlus
4
4
  module Rails
5
5
  module Helper
6
6
  def open_graph(**)
7
- @open_graph_root ||= Namespace::Root.new
7
+ @open_graph_root ||= default_open_graph
8
8
  @open_graph_root.update(**)
9
9
  yield @open_graph_root if block_given?
10
10
  @open_graph_root
@@ -15,9 +15,17 @@ module OpenGraphPlus
15
15
  end
16
16
 
17
17
  def open_graph_meta_tags
18
- @open_graph_root ||= Namespace::Root.new
19
- yield @open_graph_root if block_given?
20
- @open_graph_root.render_in(self)
18
+ yield open_graph if block_given?
19
+ open_graph.render_in(self)
20
+ end
21
+
22
+ protected
23
+
24
+ def default_open_graph
25
+ Namespace::Root.new.tap do |root|
26
+ root.type = "website"
27
+ root.url = request.url if request
28
+ end
21
29
  end
22
30
  end
23
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenGraphPlus
4
- VERSION = "0.1.14"
4
+ VERSION = "0.1.15"
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.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-01-22 00:00:00.000000000 Z
10
+ date: 2026-01-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport