better_seo 0.7.0 → 0.8.0
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/CHANGELOG.md +27 -0
- data/README.md +178 -7
- data/lib/better_seo/version.rb +1 -1
- data/lib/better_seo.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e54a1f72d1782db6366637bd76336b7af2bf1d51dd3241dc7ba4be9f0deb75b
|
|
4
|
+
data.tar.gz: a2bc94c2c62edc86b3bf50db8f56424b11649d7aa4d3b53867b55d3561a69a5d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b53dd20aa929536a0de6f293bf2e1efe35437cb9431db5f86f0865bf4bdc8ec3575fd95dbc9843fdb4ebb3c259da65bf9f39ee636c199ec4818141019f71dcbb
|
|
7
|
+
data.tar.gz: 79f5dd0ae283b0a05af28c3f5372db36e9d618fffc4596a5c716b3c67ae4ea5751b2e697dc637837dcb6619d94801be79519364621b339b0df40a3701ed552c5
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.0] - 2025-01-23
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Rails Structured Data View Helpers for easy integration
|
|
14
|
+
- `structured_data_tag(type, **properties, &block)` - Generic helper with type symbol or object
|
|
15
|
+
- `organization_sd(**properties, &block)` - Organization structured data helper
|
|
16
|
+
- `article_sd(**properties, &block)` - Article structured data helper
|
|
17
|
+
- `person_sd(**properties, &block)` - Person structured data helper
|
|
18
|
+
- `product_sd(**properties, &block)` - Product structured data helper
|
|
19
|
+
- `breadcrumb_list_sd(items:, &block)` - Breadcrumb list structured data helper
|
|
20
|
+
- `structured_data_tags(array)` - Multiple structured data tags generation
|
|
21
|
+
- Helper features
|
|
22
|
+
- Support for both hash configuration and block-based DSL
|
|
23
|
+
- Type mapping with symbol-based factory methods
|
|
24
|
+
- Automatic HTML safety with `raw` method
|
|
25
|
+
- Pass existing structured data objects or create on-the-fly
|
|
26
|
+
- Seamless integration with Rails views and layouts
|
|
27
|
+
- Complete Rails integration examples
|
|
28
|
+
- Product page with breadcrumbs and structured data
|
|
29
|
+
- Helper method reference table
|
|
30
|
+
- Type-specific helper examples
|
|
31
|
+
|
|
32
|
+
### Test Coverage
|
|
33
|
+
- 552 tests passing (+22 from v0.7.0)
|
|
34
|
+
- 98.83% code coverage (931/942 lines)
|
|
35
|
+
- 22 new tests for StructuredDataHelper
|
|
36
|
+
|
|
10
37
|
## [0.7.0] - 2025-01-23
|
|
11
38
|
|
|
12
39
|
### Added
|
data/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
A comprehensive SEO gem for Ruby and Rails applications. BetterSeo provides a clean, fluent DSL for managing meta tags, Open Graph, Twitter Cards, structured data, sitemaps, and more.
|
|
4
4
|
|
|
5
|
-
[](https://github.com/yourusername/better_seo)
|
|
6
|
+
[](https://github.com/yourusername/better_seo)
|
|
7
7
|
[](https://www.ruby-lang.org)
|
|
8
8
|
[](https://rubyonrails.org)
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
### ✅ Implemented (v0.
|
|
12
|
+
### ✅ Implemented (v0.8.0)
|
|
13
13
|
|
|
14
14
|
- **Core Configuration System**
|
|
15
15
|
- Singleton configuration with block-style setup
|
|
@@ -33,7 +33,8 @@ A comprehensive SEO gem for Ruby and Rails applications. BetterSeo provides a cl
|
|
|
33
33
|
- Integration with DSL builders
|
|
34
34
|
|
|
35
35
|
- **Rails Integration**
|
|
36
|
-
- **View Helpers**: `seo_meta_tags`, `seo_open_graph_tags`, `seo_twitter_tags`, `seo_tags`
|
|
36
|
+
- **SEO View Helpers**: `seo_meta_tags`, `seo_open_graph_tags`, `seo_twitter_tags`, `seo_tags`
|
|
37
|
+
- **Structured Data Helpers**: `structured_data_tag`, `organization_sd`, `article_sd`, `person_sd`, `product_sd`, `breadcrumb_list_sd`
|
|
37
38
|
- Support for hash configuration and DSL blocks
|
|
38
39
|
- Automatic HTML safety with `raw` helper
|
|
39
40
|
- Integration with global configuration defaults
|
|
@@ -1312,6 +1313,174 @@ And in article views:
|
|
|
1312
1313
|
<%= article_structured_data(@article) %>
|
|
1313
1314
|
```
|
|
1314
1315
|
|
|
1316
|
+
#### Rails View Helpers (v0.8.0)
|
|
1317
|
+
|
|
1318
|
+
BetterSeo includes built-in Rails view helpers for easy structured data integration:
|
|
1319
|
+
|
|
1320
|
+
**Generic Helper - `structured_data_tag`**
|
|
1321
|
+
|
|
1322
|
+
```erb
|
|
1323
|
+
<%# Create from type symbol with hash %>
|
|
1324
|
+
<%= structured_data_tag(:organization,
|
|
1325
|
+
name: "Acme Corp",
|
|
1326
|
+
url: "https://acme.com",
|
|
1327
|
+
logo: "https://acme.com/logo.png"
|
|
1328
|
+
) %>
|
|
1329
|
+
|
|
1330
|
+
<%# Create from type symbol with block %>
|
|
1331
|
+
<%= structured_data_tag(:article) do |article|
|
|
1332
|
+
article.headline("My Article")
|
|
1333
|
+
article.author("John Doe")
|
|
1334
|
+
article.date_published("2024-01-15")
|
|
1335
|
+
end %>
|
|
1336
|
+
|
|
1337
|
+
<%# Pass an existing object %>
|
|
1338
|
+
<% org = BetterSeo::StructuredData::Organization.new(name: "Acme") %>
|
|
1339
|
+
<%= structured_data_tag(org) %>
|
|
1340
|
+
```
|
|
1341
|
+
|
|
1342
|
+
**Type-Specific Helpers**
|
|
1343
|
+
|
|
1344
|
+
Convenience methods for each structured data type:
|
|
1345
|
+
|
|
1346
|
+
```erb
|
|
1347
|
+
<%# Organization %>
|
|
1348
|
+
<%= organization_sd(
|
|
1349
|
+
name: "Acme Corp",
|
|
1350
|
+
url: "https://acme.com"
|
|
1351
|
+
) %>
|
|
1352
|
+
|
|
1353
|
+
<%# Or with block %>
|
|
1354
|
+
<%= organization_sd do |org|
|
|
1355
|
+
org.name("Acme Corp")
|
|
1356
|
+
org.url("https://acme.com")
|
|
1357
|
+
org.logo("https://acme.com/logo.png")
|
|
1358
|
+
end %>
|
|
1359
|
+
|
|
1360
|
+
<%# Article %>
|
|
1361
|
+
<%= article_sd(
|
|
1362
|
+
headline: @article.title,
|
|
1363
|
+
author: @article.author.name,
|
|
1364
|
+
date_published: @article.published_at.iso8601
|
|
1365
|
+
) %>
|
|
1366
|
+
|
|
1367
|
+
<%# Person %>
|
|
1368
|
+
<%= person_sd do |person|
|
|
1369
|
+
person.name("John Doe")
|
|
1370
|
+
person.email("john@example.com")
|
|
1371
|
+
person.job_title("Software Engineer")
|
|
1372
|
+
end %>
|
|
1373
|
+
|
|
1374
|
+
<%# Product %>
|
|
1375
|
+
<%= product_sd do |product|
|
|
1376
|
+
product.name(@product.name)
|
|
1377
|
+
product.brand(@product.brand)
|
|
1378
|
+
product.offers(
|
|
1379
|
+
price: @product.price,
|
|
1380
|
+
price_currency: "USD",
|
|
1381
|
+
availability: "InStock"
|
|
1382
|
+
)
|
|
1383
|
+
product.aggregate_rating(
|
|
1384
|
+
rating_value: @product.average_rating,
|
|
1385
|
+
review_count: @product.reviews_count
|
|
1386
|
+
)
|
|
1387
|
+
end %>
|
|
1388
|
+
|
|
1389
|
+
<%# Breadcrumb List %>
|
|
1390
|
+
<%= breadcrumb_list_sd do |breadcrumb|
|
|
1391
|
+
breadcrumb.add_item(name: "Home", url: root_url)
|
|
1392
|
+
breadcrumb.add_item(name: "Products", url: products_url)
|
|
1393
|
+
breadcrumb.add_item(name: @product.name, url: product_url(@product))
|
|
1394
|
+
end %>
|
|
1395
|
+
|
|
1396
|
+
<%# Or from array %>
|
|
1397
|
+
<% items = [
|
|
1398
|
+
{ name: "Home", url: root_url },
|
|
1399
|
+
{ name: "Products", url: products_url }
|
|
1400
|
+
] %>
|
|
1401
|
+
<%= breadcrumb_list_sd(items: items) %>
|
|
1402
|
+
```
|
|
1403
|
+
|
|
1404
|
+
**Multiple Tags Helper - `structured_data_tags`**
|
|
1405
|
+
|
|
1406
|
+
Generate multiple script tags at once:
|
|
1407
|
+
|
|
1408
|
+
```erb
|
|
1409
|
+
<% org = BetterSeo::StructuredData::Organization.new(name: "Acme") %>
|
|
1410
|
+
<% person = BetterSeo::StructuredData::Person.new(name: "John") %>
|
|
1411
|
+
<% article = BetterSeo::StructuredData::Article.new(headline: "Title") %>
|
|
1412
|
+
|
|
1413
|
+
<%= structured_data_tags([org, person, article]) %>
|
|
1414
|
+
```
|
|
1415
|
+
|
|
1416
|
+
**Complete Rails Example**
|
|
1417
|
+
|
|
1418
|
+
```erb
|
|
1419
|
+
<%# app/views/products/show.html.erb %>
|
|
1420
|
+
<head>
|
|
1421
|
+
<%# Page SEO tags %>
|
|
1422
|
+
<%= seo_tags do |seo|
|
|
1423
|
+
seo.meta do |meta|
|
|
1424
|
+
meta.title @product.name
|
|
1425
|
+
meta.description @product.description
|
|
1426
|
+
end
|
|
1427
|
+
seo.og do |og|
|
|
1428
|
+
og.type "product"
|
|
1429
|
+
og.title @product.name
|
|
1430
|
+
og.image @product.image_url
|
|
1431
|
+
end
|
|
1432
|
+
end %>
|
|
1433
|
+
|
|
1434
|
+
<%# Structured data %>
|
|
1435
|
+
<%= organization_sd do |org|
|
|
1436
|
+
org.name("My Shop")
|
|
1437
|
+
org.url(root_url)
|
|
1438
|
+
end %>
|
|
1439
|
+
|
|
1440
|
+
<%= breadcrumb_list_sd do |bc|
|
|
1441
|
+
bc.add_item(name: "Home", url: root_url)
|
|
1442
|
+
bc.add_item(name: "Products", url: products_url)
|
|
1443
|
+
bc.add_item(name: @product.category, url: category_url(@product.category))
|
|
1444
|
+
bc.add_item(name: @product.name, url: product_url(@product))
|
|
1445
|
+
end %>
|
|
1446
|
+
|
|
1447
|
+
<%= product_sd do |product|
|
|
1448
|
+
product.name(@product.name)
|
|
1449
|
+
product.description(@product.description)
|
|
1450
|
+
product.image(@product.image_url)
|
|
1451
|
+
product.brand(@product.brand)
|
|
1452
|
+
product.sku(@product.sku)
|
|
1453
|
+
product.offers(
|
|
1454
|
+
price: @product.price,
|
|
1455
|
+
price_currency: "USD",
|
|
1456
|
+
availability: @product.in_stock? ? "InStock" : "OutOfStock",
|
|
1457
|
+
url: product_url(@product)
|
|
1458
|
+
)
|
|
1459
|
+
if @product.reviews.any?
|
|
1460
|
+
product.aggregate_rating(
|
|
1461
|
+
rating_value: @product.average_rating,
|
|
1462
|
+
review_count: @product.reviews_count,
|
|
1463
|
+
best_rating: 5
|
|
1464
|
+
)
|
|
1465
|
+
end
|
|
1466
|
+
end %>
|
|
1467
|
+
</head>
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
**Helper Method Reference**
|
|
1471
|
+
|
|
1472
|
+
| Helper | Description |
|
|
1473
|
+
|--------|-------------|
|
|
1474
|
+
| `structured_data_tag(type, **props, &block)` | Generic helper for any type |
|
|
1475
|
+
| `organization_sd(**props, &block)` | Organization structured data |
|
|
1476
|
+
| `article_sd(**props, &block)` | Article structured data |
|
|
1477
|
+
| `person_sd(**props, &block)` | Person structured data |
|
|
1478
|
+
| `product_sd(**props, &block)` | Product structured data |
|
|
1479
|
+
| `breadcrumb_list_sd(items:, &block)` | Breadcrumb list structured data |
|
|
1480
|
+
| `structured_data_tags(array)` | Multiple structured data tags |
|
|
1481
|
+
|
|
1482
|
+
All helpers support both hash configuration and block-based DSL for maximum flexibility.
|
|
1483
|
+
|
|
1315
1484
|
#### Complete Example
|
|
1316
1485
|
|
|
1317
1486
|
```ruby
|
|
@@ -1478,11 +1647,13 @@ bundle exec rspec --format documentation
|
|
|
1478
1647
|
```
|
|
1479
1648
|
|
|
1480
1649
|
Current test statistics:
|
|
1481
|
-
- **
|
|
1482
|
-
- **
|
|
1650
|
+
- **552 tests** passing
|
|
1651
|
+
- **98.83% code coverage** (931/942 lines)
|
|
1483
1652
|
- **3 DSL builders** fully tested
|
|
1484
1653
|
- **3 HTML generators** fully tested
|
|
1485
|
-
- **
|
|
1654
|
+
- **2 Rails view helper modules** fully tested
|
|
1655
|
+
- **5 Structured data types** fully tested
|
|
1656
|
+
- **1 Sitemap generation system** fully tested
|
|
1486
1657
|
- **1 core configuration system** fully tested
|
|
1487
1658
|
|
|
1488
1659
|
## Architecture
|
data/lib/better_seo/version.rb
CHANGED
data/lib/better_seo.rb
CHANGED
|
@@ -13,7 +13,6 @@ require_relative "better_seo/dsl/twitter_cards"
|
|
|
13
13
|
require_relative "better_seo/generators/meta_tags_generator"
|
|
14
14
|
require_relative "better_seo/generators/open_graph_generator"
|
|
15
15
|
require_relative "better_seo/generators/twitter_cards_generator"
|
|
16
|
-
require_relative "better_seo/rails/helpers/seo_helper"
|
|
17
16
|
require_relative "better_seo/sitemap/url_entry"
|
|
18
17
|
require_relative "better_seo/sitemap/builder"
|
|
19
18
|
require_relative "better_seo/sitemap/generator"
|
|
@@ -24,6 +23,8 @@ require_relative "better_seo/structured_data/person"
|
|
|
24
23
|
require_relative "better_seo/structured_data/product"
|
|
25
24
|
require_relative "better_seo/structured_data/breadcrumb_list"
|
|
26
25
|
require_relative "better_seo/structured_data/generator"
|
|
26
|
+
require_relative "better_seo/rails/helpers/seo_helper"
|
|
27
|
+
require_relative "better_seo/rails/helpers/structured_data_helper"
|
|
27
28
|
|
|
28
29
|
module BetterSeo
|
|
29
30
|
class << self
|