page_structured_data 1.0.1 → 1.0.3

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: eb34fae60cc0d7ec3b9d686d8a5977d515fd29784d6beee5b7b63af55a902555
4
- data.tar.gz: 8e81d0952b1e139cbd1f74d3a6f6518225e7d9c5da6be62e8c87e7f8a1c57094
3
+ metadata.gz: a7c3d0a5a1b15c977f7fbad8c98b6f65aa60873e4e320b05eeb1ef9ecb103cf2
4
+ data.tar.gz: c9e1370c39548ca404bf508e02da8f80680c7ba9cc43450e541ba688b7fe00f9
5
5
  SHA512:
6
- metadata.gz: 8bddeabf6322a0942c71a0dde014be7a1030d43d16d53fed97fd8fad206681ae3060ed06a7a19885bdcace26a215813e0d190fb5e72edd7ab9d0127fa90b683c
7
- data.tar.gz: d55d272089d34357730ae7c079bb428b53de64c0c7aa9b7745589ca7156b07d4e3d1ef7d96921f44be075d1b7ae2337fc0ae56f95f498ebd6ef13eec6502e740
6
+ metadata.gz: 9a6762f1fac05f0c3fd7fa3d20f0aa1b815834becdff134a6850496c35789852f3b8b59f23541a537409c81e79f1934d16603edf83e558b4a41ab422de197064
7
+ data.tar.gz: 286d821c75af661708819f6cdd36b47f7e49eb4da42e0743bfa0b80270b851674d693dbc9f1a573d36482077ef7e2ec786ebc6ff5df804d4b622564ecfec3a18
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ ## Unreleased
6
+
7
+ ## 1.0.3 - 2026-05-06
8
+
9
+ - Improve RubyGems metadata, documentation links, and public README presentation.
10
+
11
+ ## 1.0.2 - 2026-05-06
12
+
13
+ - Fix dummy app compatibility with Rails 7.0 by replacing `config.autoload_lib`.
14
+ - Fix requiring `page_structured_data` before Rails has already been loaded.
15
+ - Add baseline tests for page title composition and JSON-LD output.
16
+ - Improve README documentation for installation, configuration, usage, and compatibility.
17
+
18
+ ## 1.0.1
19
+
20
+ - Previous public release.
21
+
22
+ ## 1.0.0
23
+
24
+ - Initial public release.
data/README.md CHANGED
@@ -1,103 +1,254 @@
1
1
  # PageStructuredData
2
- Use this gem to churn out meta tags for your rails webpages. This also renders meta tags for the following:
3
- 1. Page `<title>` tag with proper hyphenation when used with breadcrumbs
4
- 2. Basic `<meta>` tags
5
- 2. Twitter meta tags
6
- 3. Open graph meta tags
7
- 4. Google Schema JSON-LD `<script>` tags
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/page_structured_data.svg)](https://rubygems.org/gems/page_structured_data)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](MIT-LICENSE)
5
+
6
+ PageStructuredData is a small Rails engine for rendering page-level SEO and social sharing metadata from one page object.
7
+
8
+ It helps Rails applications render:
9
+
10
+ - A `<title>` tag
11
+ - Basic `title`, `description`, and `image` meta tags
12
+ - Open Graph tags
13
+ - Twitter card tags
14
+ - Google-compatible JSON-LD structured data
15
+ - Breadcrumb structured data
16
+ - Article structured data for `BlogPosting` and `NewsArticle`
17
+
18
+ ## Requirements
19
+
20
+ - Rails 7.0 or newer
21
+ - Slim 4.1 or newer
22
+ - A Ruby version supported by your Rails version
8
23
 
9
24
  ## Installation
10
- Add this line to your application's Gemfile:
25
+
26
+ Add the gem to your application's Gemfile:
11
27
 
12
28
  ```ruby
13
29
  gem "page_structured_data"
14
30
  ```
15
31
 
16
- And then execute:
32
+ Then install it:
33
+
17
34
  ```bash
18
- $ bundle
35
+ bundle install
19
36
  ```
20
37
 
21
- Or install it yourself as:
22
- ```bash
23
- $ gem install page_structured_data
38
+ ## Configuration
39
+
40
+ Configure application-wide defaults in an initializer:
41
+
42
+ ```ruby
43
+ # config/initializers/page_structured_data.rb
44
+ Rails.application.config.after_initialize do
45
+ PageStructuredData.config do |config|
46
+ config.base_app_name = "AwesomestApp"
47
+ end
48
+ end
24
49
  ```
25
50
 
26
- ## Usage
51
+ `base_app_name` is appended to generated page titles.
27
52
 
28
- ### Layouts
53
+ For example:
29
54
 
30
- Add the following in your layout to include the basic meta tags by default
55
+ ```ruby
56
+ PageStructuredData.base_app_name = "AwesomestApp"
57
+
58
+ page = PageStructuredData::Page.new(
59
+ title: "Pricing",
60
+ extra_title: "Plans",
61
+ description: "Simple pricing for AwesomestApp"
62
+ )
31
63
 
32
- ```erbruby
33
- <%= render 'page_structured_data/meta_tags', page: @page_meta,
34
- default_image_url: image_url('<path_to_default_image>') %>
64
+ page.page_title
65
+ # => "Pricing - Plans - AwesomestApp"
35
66
  ```
36
67
 
37
- Note: This doesn't include csrf or any other security or viewport related meta tags.
68
+ ## Rendering Meta Tags
69
+
70
+ Render the bundled partial from your application layout:
71
+
72
+ ```erb
73
+ <%= render "page_structured_data/meta_tags",
74
+ page: @page_meta,
75
+ default_image_url: image_url("social/default.png") %>
76
+ ```
38
77
 
39
- ### Views
78
+ `default_image_url` is optional. It is used when the page object does not provide an image.
40
79
 
41
- In your views, please define the `@page_meta` as follows
80
+ This partial is only responsible for SEO, social sharing, and structured-data tags. Keep your normal Rails layout tags, such as CSRF, CSP, viewport, and favicon tags, in your application layout.
81
+
82
+ ## Basic Page Metadata
83
+
84
+ Set `@page_meta` in the controller or view before the layout renders:
42
85
 
43
86
  ```ruby
44
- <% @page_meta = PageStructuredData::Page.new(title: 'Home', extra_title: "Official Page",
45
- description: 'Welcome to my Page') %>
87
+ @page_meta = PageStructuredData::Page.new(
88
+ title: "Home",
89
+ extra_title: "Official Page",
90
+ description: "Welcome to my page",
91
+ image: image_url("social/home.png")
92
+ )
46
93
  ```
47
94
 
48
- The instance variable will be used in the layout to create proper meta tags. Most attributes are self explanatory. `extra_title` is used to append to the title.
95
+ The generated title is built from:
49
96
 
50
- ### Config
97
+ 1. `title`
98
+ 2. `extra_title`, when present
99
+ 3. breadcrumb titles, when present
100
+ 4. `PageStructuredData.base_app_name`, when present
51
101
 
52
- Configure the application wide settings as follows:
102
+ The parts are joined with `" - "`.
53
103
 
54
- ```erbruby
55
- # config/initializers/page_structured_data.rb
56
- Rails.application.config.after_initialize do
57
- PageStructuredData.config do |config|
58
- config.base_app_name = 'AwesomestApp' # or use any application constant as this is called after_initialize
59
- end
60
- end
104
+ ## Breadcrumbs
105
+
106
+ Create breadcrumbs with a hierarchy of page titles and URLs:
107
+
108
+ ```ruby
109
+ breadcrumbs = PageStructuredData::Breadcrumbs.new(
110
+ hierarchy: [
111
+ { title: "Resources", href: resources_url },
112
+ { title: "Articles", href: resources_articles_url }
113
+ ]
114
+ )
61
115
  ```
62
116
 
63
- ### Breadcrumbs
117
+ Pass the breadcrumbs into the page object:
64
118
 
65
- Create a list of breadcrumbs like this:
119
+ ```ruby
120
+ @page_meta = PageStructuredData::Page.new(
121
+ title: "How to Structure Metadata",
122
+ description: "A guide to page metadata and structured data",
123
+ breadcrumb: breadcrumbs
124
+ )
125
+ ```
66
126
 
67
- ```erbruby
68
- <% breadcrumb = PageStructuredData::Breadcrumbs.new(hierarchy: [{ title: 'Resources', href: resources_url }, { title: 'Articles', href: resources_articles_url }]) %>
127
+ This renders `BreadcrumbList` JSON-LD similar to Google's breadcrumb structured data format.
128
+
129
+ Current compatibility note: when no breadcrumb object is passed, `PageStructuredData::Page` still creates an empty breadcrumb trail for the current page. This is existing behavior and should be considered part of the current public API.
130
+
131
+ ## Article Page Types
132
+
133
+ PageStructuredData includes page types for:
134
+
135
+ - [`BlogPosting`](https://schema.org/BlogPosting)
136
+ - [`NewsArticle`](https://schema.org/NewsArticle)
137
+
138
+ Use a page type when the current page represents an article:
139
+
140
+ ```ruby
141
+ article_page_type = PageStructuredData::PageTypes::BlogPosting.new(
142
+ headline: @article.title,
143
+ published_at: @article.published_at,
144
+ updated_at: @article.updated_at,
145
+ authors: [
146
+ {
147
+ name: @article.authors.first.name,
148
+ url: @article.authors.first.website
149
+ }
150
+ ],
151
+ images: [
152
+ main_app.url_for(@article.cover_image.variant(:standard))
153
+ ]
154
+ )
155
+
156
+ @page_meta = PageStructuredData::Page.new(
157
+ title: @article.title,
158
+ description: @article.summary,
159
+ image: main_app.url_for(@article.cover_image.variant(:standard)),
160
+ breadcrumb: breadcrumbs,
161
+ page_type: article_page_type
162
+ )
69
163
  ```
70
164
 
71
- And include it in the `Page.new` as:
165
+ For news pages, use `PageStructuredData::PageTypes::NewsArticle` with the same arguments.
166
+
167
+ ## API Reference
168
+
169
+ ### `PageStructuredData::Page`
72
170
 
73
- ```erbruby
74
- <% @page_meta = PageStructuredData::Page.new(title: 'Home', extra_title: "Official Page",
75
- description: 'Welcome to my Page', breadcrumb: breadcrumb) %>
171
+ ```ruby
172
+ PageStructuredData::Page.new(
173
+ title:,
174
+ description: nil,
175
+ image: nil,
176
+ extra_title: "",
177
+ breadcrumb: nil,
178
+ page_type: nil
179
+ )
76
180
  ```
77
181
 
78
- This will create a JSON+LD breadcrumbs similar to [Breadcrumbs](https://developers.google.com/search/docs/appearance/structured-data/breadcrumb)
182
+ Important methods:
183
+
184
+ - `page_title`: returns the composed page title.
185
+ - `json_lds`: returns the JSON-LD script tags for breadcrumbs and page type data.
79
186
 
80
- ### PageTypes
187
+ ### `PageStructuredData::Breadcrumbs`
188
+
189
+ ```ruby
190
+ PageStructuredData::Breadcrumbs.new(
191
+ hierarchy: [
192
+ { title: "Resources", href: "https://example.com/resources" }
193
+ ]
194
+ )
195
+ ```
81
196
 
82
- Currently this gem supports the following page types:
197
+ Important methods:
83
198
 
84
- * [BlogPosting](https://schema.org/BlogPosting)
85
- * [NewsArticle](https://schema.org/NewsArticle)
199
+ - `titles`: returns breadcrumb titles.
200
+ - `json_ld(current_page_title:)`: returns a `BreadcrumbList` JSON-LD script tag.
86
201
 
87
- To use these, it is similar to breadcrumbs: include them in `Page.new` and it the json+ld will be automatically included.
202
+ ### Article Page Types
88
203
 
89
- ```erbruby
90
- <% article_page_type = PageStructuredData::PageTypes::BlogPosting.new(headline: @article.title, published_at: @article.published_at,
91
- updated_at: @article.updated_at, authors: [name: @article.authors.first.name, url: @article.authors.first.website],
92
- images: [main_app.url_for(@article.cover_image.variant(:standard))]) %>
93
- <% @page_meta = PageStructuredData::Page.new(title: 'Home', extra_title: "Official Page",
94
- description: 'Welcome to my Page', page_type: article_page_type) %>
204
+ ```ruby
205
+ PageStructuredData::PageTypes::BlogPosting.new(
206
+ headline:,
207
+ published_at:,
208
+ updated_at:,
209
+ images: [],
210
+ authors: []
211
+ )
95
212
  ```
96
213
 
97
- Just replace BlogPosting class with the other type for other page types.
214
+ ```ruby
215
+ PageStructuredData::PageTypes::NewsArticle.new(
216
+ headline:,
217
+ published_at:,
218
+ updated_at:,
219
+ images: [],
220
+ authors: []
221
+ )
222
+ ```
223
+
224
+ `authors` should be an array of hashes with `:name` and `:url` keys.
225
+
226
+ ## Development
227
+
228
+ Run the test suite:
229
+
230
+ ```bash
231
+ bundle exec rake test
232
+ ```
233
+
234
+ Verify the gem can be required:
235
+
236
+ ```bash
237
+ ruby -Ilib -e 'require "page_structured_data"; puts PageStructuredData::VERSION'
238
+ ```
239
+
240
+ ## Compatibility Policy
241
+
242
+ This gem is used in production applications. Changes should preserve existing public APIs and rendered output unless a breaking change is intentionally released in a major version.
243
+
244
+ Prefer additive APIs and tests that document current behavior before refactoring internals.
98
245
 
99
246
  ## Contributing
100
- Please raise a PR to be validated and merged.
247
+
248
+ Bug reports and pull requests are welcome on GitHub.
249
+
250
+ When contributing, please include tests for user-visible behavior and keep changes focused. For compatibility-sensitive behavior, describe the expected impact in the pull request.
101
251
 
102
252
  ## License
253
+
103
254
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,3 +1,6 @@
1
+ require "rails"
2
+ require "action_dispatch/railtie"
3
+
1
4
  module PageStructuredData
2
5
  class Engine < ::Rails::Engine
3
6
  isolate_namespace PageStructuredData
@@ -1,3 +1,3 @@
1
1
  module PageStructuredData
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_structured_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jey Geethan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-30 00:00:00.000000000 Z
11
+ date: 2026-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,15 +38,16 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 4.1.0
41
- description: This gem helps to create structured meta tags and ld+json schema for
42
- rails applications. It is easy to use and can be incorporated into any existing
43
- rails app.
41
+ description: PageStructuredData gives Rails applications a small page object and view
42
+ partial for rendering page titles, basic meta tags, Open Graph tags, Twitter card
43
+ tags, breadcrumb JSON-LD, and article JSON-LD.
44
44
  email:
45
45
  - opensource@rocketapex.com
46
46
  executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
+ - CHANGELOG.md
50
51
  - MIT-LICENSE
51
52
  - README.md
52
53
  - Rakefile
@@ -76,7 +77,10 @@ metadata:
76
77
  allowed_push_host: https://rubygems.org
77
78
  homepage_uri: https://github.com/RocketApex/page_structured_data
78
79
  source_code_uri: https://github.com/RocketApex/page_structured_data
79
- changelog_uri: https://github.com/RocketApex/page_structured_data
80
+ documentation_uri: https://github.com/RocketApex/page_structured_data#readme
81
+ bug_tracker_uri: https://github.com/RocketApex/page_structured_data/issues
82
+ changelog_uri: https://github.com/RocketApex/page_structured_data/blob/main/CHANGELOG.md
83
+ rubygems_mfa_required: 'true'
80
84
  post_install_message:
81
85
  rdoc_options: []
82
86
  require_paths:
@@ -95,5 +99,5 @@ requirements: []
95
99
  rubygems_version: 3.3.7
96
100
  signing_key:
97
101
  specification_version: 4
98
- summary: Easily create meta tags with structured data for webpages
102
+ summary: Render SEO, social, and JSON-LD metadata for Rails pages
99
103
  test_files: []