page_structured_data 1.0.6 → 1.0.8

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: 3158329319534cff0f6011223d8ae6d16f6979742ded26e443633f45f2a9aaaf
4
- data.tar.gz: 9dc54a0d21f0e8567b1957e69fc86220771c4e0eeee04bdcb21238fb56c579b0
3
+ metadata.gz: de6dfe0bcc4ddffd85f8b77498c1f4a34fcbdcd839cb362118033531ec1e7d48
4
+ data.tar.gz: 9152005a24c5e16562c3d38e285c9dc4a56803563c0387cad15beca54f646fda
5
5
  SHA512:
6
- metadata.gz: 6f7dd3da1c510fea597608fc15473d9f79970f827de8a53576ae9574a3bd0f6aef8c6e015b03406aa0b7d48ac1c9fc65f1de6288fe520e8a673fc2bc357cf1f8
7
- data.tar.gz: bfaa6dc28249dcf07cebeb8c8faf4c42af521f181030fd2712c0520abf922092eda33c0cccd598c8a00bd15485bee9247d321d9f10855768ecc8d8bcc4d7325f
6
+ metadata.gz: 41ca7bfed324d9e746c2e60cf092af955f11b1136ba4db2a4ef965babcd22870b4bfb5c1808d4fde1b2e53cfefe6dd664adfe2a41cc4ae44e6ecf809bf42b4dc
7
+ data.tar.gz: d53a5eb7986394deeaff433d74022b1d830bca59b9b9aaa2161e773e6010a6f7ba9802bd1662417c3be8729dfb0139239047766cca15bef39bf8569e8edf468a
data/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project are documented here.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 1.0.8 - 2026-05-06
8
+
9
+ - Add `PageStructuredData::PageTypes::Organization` for schema.org Organization JSON-LD.
10
+
11
+ ## 1.0.7 - 2026-05-06
12
+
13
+ - Remove unused generated Rails engine boilerplate files.
14
+
7
15
  ## 1.0.6 - 2026-05-06
8
16
 
9
17
  - Add tests for HTML escaping in rendered meta tags.
data/README.md CHANGED
@@ -14,6 +14,7 @@ It helps Rails applications render:
14
14
  - Google-compatible JSON-LD structured data
15
15
  - Breadcrumb structured data
16
16
  - Article structured data for `BlogPosting` and `NewsArticle`
17
+ - Organization structured data
17
18
 
18
19
  ## Requirements
19
20
 
@@ -138,6 +139,7 @@ PageStructuredData includes page types for:
138
139
 
139
140
  - [`BlogPosting`](https://schema.org/BlogPosting)
140
141
  - [`NewsArticle`](https://schema.org/NewsArticle)
142
+ - [`Organization`](https://schema.org/Organization)
141
143
 
142
144
  Use a page type when the current page represents an article:
143
145
 
@@ -168,6 +170,27 @@ article_page_type = PageStructuredData::PageTypes::BlogPosting.new(
168
170
 
169
171
  For news pages, use `PageStructuredData::PageTypes::NewsArticle` with the same arguments.
170
172
 
173
+ Use `Organization` when the current page represents an organization:
174
+
175
+ ```ruby
176
+ organization_page_type = PageStructuredData::PageTypes::Organization.new(
177
+ name: "RocketApex",
178
+ url: "https://rocketapex.com",
179
+ logo: "https://rocketapex.com/logo.png",
180
+ same_as: ["https://github.com/RocketApex"],
181
+ parent_organization: {
182
+ name: "Parent Org",
183
+ url: "https://parent.example"
184
+ }
185
+ )
186
+
187
+ @page_meta = PageStructuredData::Page.new(
188
+ title: "About RocketApex",
189
+ description: "Open source projects from RocketApex",
190
+ page_type: organization_page_type
191
+ )
192
+ ```
193
+
171
194
  ## API Reference
172
195
 
173
196
  ### `PageStructuredData::Page`
@@ -233,6 +256,24 @@ Important methods:
233
256
  - `to_h`: returns a structured hash for article JSON-LD.
234
257
  - `json_ld`: returns an article JSON-LD script tag.
235
258
 
259
+ ### Organization Page Type
260
+
261
+ ```ruby
262
+ PageStructuredData::PageTypes::Organization.new(
263
+ name:,
264
+ url:,
265
+ logo: nil,
266
+ same_as: [],
267
+ parent_organization: nil
268
+ )
269
+ ```
270
+
271
+ `parent_organization` should be a hash with `:name` and `:url` keys.
272
+
273
+ Important methods:
274
+
275
+ - `json_ld`: returns an organization JSON-LD script tag.
276
+
236
277
  ## Development
237
278
 
238
279
  Run the test suite:
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PageStructuredData
4
+ module PageTypes
5
+ # Organization structured data for a page
6
+ class Organization
7
+ attr_reader :name, :url, :logo, :same_as, :parent_organization
8
+
9
+ def initialize(name:, url:, logo: nil, same_as: [], parent_organization: nil)
10
+ @name = name
11
+ @url = url
12
+ @logo = logo
13
+ @same_as = same_as
14
+ @parent_organization = parent_organization
15
+ end
16
+
17
+ def json_ld # rubocop:disable Metrics/MethodLength
18
+ node = {
19
+ '@context': 'https://schema.org',
20
+ '@type': 'Organization',
21
+ }
22
+
23
+ node[:name] = name
24
+ node[:url] = url
25
+ node[:logo] = logo if logo.present?
26
+ node[:sameAs] = same_as if same_as.present?
27
+
28
+ if parent_organization.present?
29
+ node[:parentOrganization] = {
30
+ '@type': 'Organization',
31
+ name: parent_organization[:name],
32
+ url: parent_organization[:url],
33
+ }
34
+ end
35
+
36
+ %(
37
+ <script type="application/ld+json">
38
+ #{node.to_json}
39
+ </script>
40
+ )
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module PageStructuredData
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -1,5 +1,12 @@
1
1
  require "page_structured_data/version"
2
2
  require "page_structured_data/engine"
3
+ require_relative "../app/src/page_structured_data/anchors"
4
+ require_relative "../app/src/page_structured_data/breadcrumbs"
5
+ require_relative "../app/src/page_structured_data/page_types/article"
6
+ require_relative "../app/src/page_structured_data/page_types/blog_posting"
7
+ require_relative "../app/src/page_structured_data/page_types/news_article"
8
+ require_relative "../app/src/page_structured_data/page_types/organization"
9
+ require_relative "../app/src/page_structured_data/page"
3
10
 
4
11
  module PageStructuredData
5
12
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_structured_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jey Geethan
@@ -43,20 +43,13 @@ files:
43
43
  - MIT-LICENSE
44
44
  - README.md
45
45
  - Rakefile
46
- - app/assets/config/page_structured_data_manifest.js
47
- - app/assets/stylesheets/page_structured_data/application.css
48
- - app/controllers/page_structured_data/application_controller.rb
49
- - app/helpers/page_structured_data/application_helper.rb
50
- - app/jobs/page_structured_data/application_job.rb
51
- - app/mailers/page_structured_data/application_mailer.rb
52
- - app/models/page_structured_data/application_record.rb
53
46
  - app/src/page_structured_data/anchors.rb
54
47
  - app/src/page_structured_data/breadcrumbs.rb
55
48
  - app/src/page_structured_data/page.rb
56
49
  - app/src/page_structured_data/page_types/article.rb
57
50
  - app/src/page_structured_data/page_types/blog_posting.rb
58
51
  - app/src/page_structured_data/page_types/news_article.rb
59
- - app/views/layouts/page_structured_data/application.html.erb
52
+ - app/src/page_structured_data/page_types/organization.rb
60
53
  - app/views/page_structured_data/_meta_tags.html.erb
61
54
  - config/routes.rb
62
55
  - lib/page_structured_data.rb
@@ -1 +0,0 @@
1
- //= link_directory ../stylesheets/page_structured_data .css
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,4 +0,0 @@
1
- module PageStructuredData
2
- class ApplicationController < ActionController::Base
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module PageStructuredData
2
- module ApplicationHelper
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module PageStructuredData
2
- class ApplicationJob < ActiveJob::Base
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module PageStructuredData
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: "from@example.com"
4
- layout "mailer"
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- module PageStructuredData
2
- class ApplicationRecord < ActiveRecord::Base
3
- self.abstract_class = true
4
- end
5
- end
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Page structured data</title>
5
- <%= csrf_meta_tags %>
6
- <%= csp_meta_tag %>
7
-
8
- <%= stylesheet_link_tag "page_structured_data/application", media: "all" %>
9
- </head>
10
- <body>
11
-
12
- <%= yield %>
13
-
14
- </body>
15
- </html>