better_seo 0.14.0 → 1.0.0.2

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +30 -0
  3. data/.rubocop_todo.yml +360 -0
  4. data/CHANGELOG.md +105 -0
  5. data/README.md +280 -180
  6. data/docs/00_OVERVIEW.md +472 -0
  7. data/docs/01_CORE_AND_CONFIGURATION.md +913 -0
  8. data/docs/02_META_TAGS_AND_OPEN_GRAPH.md +251 -0
  9. data/docs/03_STRUCTURED_DATA.md +140 -0
  10. data/docs/04_SITEMAP_AND_ROBOTS.md +131 -0
  11. data/docs/05_RAILS_INTEGRATION.md +175 -0
  12. data/docs/06_I18N_PAGE_GENERATOR.md +233 -0
  13. data/docs/07_IMAGE_OPTIMIZATION.md +260 -0
  14. data/docs/DEPENDENCIES.md +383 -0
  15. data/docs/README.md +180 -0
  16. data/docs/TESTING_STRATEGY.md +663 -0
  17. data/lib/better_seo/analytics/google_analytics.rb +83 -0
  18. data/lib/better_seo/analytics/google_tag_manager.rb +74 -0
  19. data/lib/better_seo/configuration.rb +322 -0
  20. data/lib/better_seo/dsl/base.rb +86 -0
  21. data/lib/better_seo/dsl/meta_tags.rb +55 -0
  22. data/lib/better_seo/dsl/open_graph.rb +105 -0
  23. data/lib/better_seo/dsl/twitter_cards.rb +129 -0
  24. data/lib/better_seo/errors.rb +31 -0
  25. data/lib/better_seo/generators/amp_generator.rb +77 -0
  26. data/lib/better_seo/generators/breadcrumbs_generator.rb +127 -0
  27. data/lib/better_seo/generators/canonical_url_manager.rb +100 -0
  28. data/lib/better_seo/generators/meta_tags_generator.rb +101 -0
  29. data/lib/better_seo/generators/open_graph_generator.rb +110 -0
  30. data/lib/better_seo/generators/robots_txt_generator.rb +96 -0
  31. data/lib/better_seo/generators/twitter_cards_generator.rb +102 -0
  32. data/lib/better_seo/image/optimizer.rb +145 -0
  33. data/lib/better_seo/rails/helpers/controller_helpers.rb +120 -0
  34. data/lib/better_seo/rails/helpers/seo_helper.rb +172 -0
  35. data/lib/better_seo/rails/helpers/structured_data_helper.rb +123 -0
  36. data/lib/better_seo/rails/model_helpers.rb +62 -0
  37. data/lib/better_seo/rails/railtie.rb +22 -0
  38. data/lib/better_seo/sitemap/builder.rb +65 -0
  39. data/lib/better_seo/sitemap/generator.rb +57 -0
  40. data/lib/better_seo/sitemap/sitemap_index.rb +73 -0
  41. data/lib/better_seo/sitemap/url_entry.rb +155 -0
  42. data/lib/better_seo/structured_data/article.rb +55 -0
  43. data/lib/better_seo/structured_data/base.rb +74 -0
  44. data/lib/better_seo/structured_data/breadcrumb_list.rb +49 -0
  45. data/lib/better_seo/structured_data/event.rb +205 -0
  46. data/lib/better_seo/structured_data/faq_page.rb +55 -0
  47. data/lib/better_seo/structured_data/generator.rb +75 -0
  48. data/lib/better_seo/structured_data/how_to.rb +96 -0
  49. data/lib/better_seo/structured_data/local_business.rb +94 -0
  50. data/lib/better_seo/structured_data/organization.rb +67 -0
  51. data/lib/better_seo/structured_data/person.rb +51 -0
  52. data/lib/better_seo/structured_data/product.rb +123 -0
  53. data/lib/better_seo/structured_data/recipe.rb +134 -0
  54. data/lib/better_seo/validators/seo_recommendations.rb +165 -0
  55. data/lib/better_seo/validators/seo_validator.rb +205 -0
  56. data/lib/better_seo/version.rb +1 -1
  57. data/lib/better_seo.rb +1 -0
  58. data/lib/generators/better_seo/install_generator.rb +21 -0
  59. data/lib/generators/better_seo/templates/README +29 -0
  60. data/lib/generators/better_seo/templates/better_seo.rb +40 -0
  61. metadata +57 -2
@@ -0,0 +1,472 @@
1
+ # BetterSeo - Piano di Implementazione
2
+
3
+ ## Visione Generale del Progetto
4
+
5
+ **BetterSeo** è una gemma Ruby completa per la gestione SEO in applicazioni Rails, progettata per fornire:
6
+
7
+ - ✅ Meta tags e Open Graph ottimizzati
8
+ - ✅ Structured data (JSON-LD) per rich snippets
9
+ - ✅ Sitemap XML dinamica
10
+ - ✅ Robots.txt configurabile
11
+ - ✅ Ottimizzazione immagini con WebP
12
+ - ✅ Supporto multilingua (i18n)
13
+ - ✅ DSL dichiarativo stile Rails
14
+ - ✅ Integrazione Rails seamless
15
+
16
+ ---
17
+
18
+ ## Architettura del Sistema
19
+
20
+ ### Struttura Modulare
21
+
22
+ ```
23
+ better_seo/
24
+ ├── lib/
25
+ │ ├── better_seo.rb # Entry point
26
+ │ ├── better_seo/
27
+ │ │ ├── version.rb # Versione gem
28
+ │ │ ├── configuration.rb # Sistema configurazione YAML/JSON
29
+ │ │ ├── errors.rb # Custom errors
30
+ │ │ │
31
+ │ │ ├── dsl/ # DSL dichiarativo
32
+ │ │ │ ├── base.rb
33
+ │ │ │ ├── meta_tags.rb
34
+ │ │ │ ├── open_graph.rb
35
+ │ │ │ ├── twitter_cards.rb
36
+ │ │ │ └── structured_data.rb
37
+ │ │ │
38
+ │ │ ├── generators/ # Generatori HTML/XML
39
+ │ │ │ ├── meta_tags_generator.rb
40
+ │ │ │ ├── open_graph_generator.rb
41
+ │ │ │ ├── twitter_cards_generator.rb
42
+ │ │ │ ├── json_ld_generator.rb
43
+ │ │ │ ├── sitemap_generator.rb
44
+ │ │ │ └── robots_generator.rb
45
+ │ │ │
46
+ │ │ ├── validators/ # Validazione SEO
47
+ │ │ │ ├── meta_validator.rb
48
+ │ │ │ ├── url_validator.rb
49
+ │ │ │ └── content_validator.rb
50
+ │ │ │
51
+ │ │ ├── schema/ # Schema.org types
52
+ │ │ │ ├── base.rb
53
+ │ │ │ ├── article.rb
54
+ │ │ │ ├── product.rb
55
+ │ │ │ ├── organization.rb
56
+ │ │ │ ├── person.rb
57
+ │ │ │ └── breadcrumb.rb
58
+ │ │ │
59
+ │ │ ├── images/ # Ottimizzazione immagini
60
+ │ │ │ ├── optimizer.rb
61
+ │ │ │ ├── converter.rb
62
+ │ │ │ ├── resizer.rb
63
+ │ │ │ ├── compressor.rb
64
+ │ │ │ ├── validator.rb
65
+ │ │ │ └── helpers/
66
+ │ │ │ ├── image_tag_helper.rb
67
+ │ │ │ └── responsive_helper.rb
68
+ │ │ │
69
+ │ │ ├── rails/ # Integrazione Rails
70
+ │ │ │ ├── railtie.rb
71
+ │ │ │ ├── engine.rb
72
+ │ │ │ ├── helpers/
73
+ │ │ │ │ ├── meta_tags_helper.rb
74
+ │ │ │ │ ├── open_graph_helper.rb
75
+ │ │ │ │ └── structured_data_helper.rb
76
+ │ │ │ ├── concerns/
77
+ │ │ │ │ └── seo_aware.rb
78
+ │ │ │ └── generators/
79
+ │ │ │ ├── install_generator.rb
80
+ │ │ │ ├── config_generator.rb
81
+ │ │ │ ├── page_generator.rb
82
+ │ │ │ ├── sitemap_generator.rb
83
+ │ │ │ └── robots_generator.rb
84
+ │ │ │
85
+ │ │ └── tasks/ # Rake tasks
86
+ │ │ ├── sitemap.rake
87
+ │ │ ├── robots.rake
88
+ │ │ ├── images.rake
89
+ │ │ └── i18n.rake
90
+ │ │
91
+ │ └── generators/ # Rails generators templates
92
+ │ └── better_seo/
93
+ │ ├── install/
94
+ │ ├── config/
95
+ │ ├── page/
96
+ │ ├── sitemap/
97
+ │ └── robots/
98
+
99
+ ├── spec/ # Test suite
100
+ │ ├── spec_helper.rb
101
+ │ ├── better_seo_spec.rb
102
+ │ ├── configuration_spec.rb
103
+ │ ├── dsl/
104
+ │ ├── generators/
105
+ │ ├── validators/
106
+ │ ├── schema/
107
+ │ ├── images/
108
+ │ ├── rails/
109
+ │ └── fixtures/
110
+
111
+ └── docs/ # Documentazione implementazione
112
+ ├── 00_OVERVIEW.md # Questo file
113
+ ├── 01_CORE_AND_CONFIGURATION.md
114
+ ├── 02_META_TAGS_AND_OPEN_GRAPH.md
115
+ ├── 03_STRUCTURED_DATA.md
116
+ ├── 04_SITEMAP_AND_ROBOTS.md
117
+ ├── 05_RAILS_INTEGRATION.md
118
+ ├── 06_I18N_PAGE_GENERATOR.md
119
+ ├── 07_IMAGE_OPTIMIZATION.md
120
+ ├── README.md
121
+ ├── DEPENDENCIES.md
122
+ └── TESTING_STRATEGY.md
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Roadmap di Implementazione
128
+
129
+ ### Versione 0.1.0 (Current - Foundation)
130
+ **Status**: ✅ Completata
131
+ - [x] Struttura base gem
132
+ - [x] Setup CI/CD
133
+ - [x] Configurazione RSpec
134
+ - [x] Rubocop
135
+
136
+ ### Versione 0.2.0 (Core & Configuration)
137
+ **Obiettivo**: Sistema di configurazione e DSL base
138
+ **Implementazione**: Step 01
139
+ **Durata stimata**: 1-2 settimane
140
+
141
+ - [ ] Sistema configurazione YAML/JSON
142
+ - [ ] DSL base pattern
143
+ - [ ] Custom errors
144
+ - [ ] Configuration validator
145
+ - [ ] Rails railtie base
146
+ - [ ] Test suite core
147
+
148
+ ### Versione 0.3.0 (Essential SEO)
149
+ **Obiettivo**: Meta tags, Open Graph, Twitter Cards
150
+ **Implementazione**: Step 02
151
+ **Durata stimata**: 2-3 settimane
152
+
153
+ - [ ] DSL meta tags
154
+ - [ ] DSL Open Graph
155
+ - [ ] DSL Twitter Cards
156
+ - [ ] HTML generators
157
+ - [ ] Meta validators
158
+ - [ ] Rails helpers base
159
+ - [ ] Controller concerns
160
+
161
+ ### Versione 0.4.0 (Structured Data)
162
+ **Obiettivo**: JSON-LD e Schema.org
163
+ **Implementazione**: Step 03
164
+ **Durata stimata**: 2-3 settimane
165
+
166
+ - [ ] Schema.org base types (Article, Product, Organization, Person)
167
+ - [ ] JSON-LD generator
168
+ - [ ] Structured data DSL
169
+ - [ ] Schema validators
170
+ - [ ] Breadcrumb support
171
+ - [ ] Multiple structured data per page
172
+
173
+ ### Versione 0.5.0 (Technical SEO)
174
+ **Obiettivo**: Sitemap e Robots.txt
175
+ **Implementazione**: Step 04
176
+ **Durata stimata**: 1-2 settimane
177
+
178
+ - [ ] Sitemap XML generator
179
+ - [ ] Dynamic sitemap da models
180
+ - [ ] Sitemap index (>50k URLs)
181
+ - [ ] Robots.txt generator
182
+ - [ ] Ping search engines
183
+ - [ ] Rake tasks
184
+
185
+ ### Versione 0.6.0 (Rails Integration)
186
+ **Obiettivo**: Integrazione Rails completa
187
+ **Implementazione**: Step 05
188
+ **Durata stimata**: 2 settimane
189
+
190
+ - [ ] View helpers completi
191
+ - [ ] Controller concerns completi
192
+ - [ ] Rails generators (install, config, sitemap, robots)
193
+ - [ ] Engine Rails
194
+ - [ ] Routes integration
195
+ - [ ] Middleware
196
+
197
+ ### Versione 0.7.0 (Internationalization)
198
+ **Obiettivo**: Supporto multilingua completo
199
+ **Implementazione**: Step 06
200
+ **Durata stimata**: 1-2 settimane
201
+
202
+ - [ ] Generatore pagine i18n
203
+ - [ ] File YAML per locale
204
+ - [ ] Helper `set_seo_from_locale`
205
+ - [ ] Interpolazione variabili
206
+ - [ ] Validazione traduzioni
207
+ - [ ] Rake tasks i18n
208
+
209
+ ### Versione 0.8.0 (Image Optimization)
210
+ **Obiettivo**: Ottimizzazione immagini e WebP
211
+ **Implementazione**: Step 07
212
+ **Durata stimata**: 2-3 settimane
213
+
214
+ - [ ] WebP converter
215
+ - [ ] Image resizer (varianti multiple)
216
+ - [ ] Smart compression
217
+ - [ ] Helper `seo_image_tag`
218
+ - [ ] Lazy loading + blur placeholder
219
+ - [ ] Active Storage/CarrierWave/Shrine integration
220
+ - [ ] Image validators
221
+ - [ ] Rake tasks images
222
+
223
+ ### Versione 0.9.0 (Polish & Testing)
224
+ **Obiettivo**: Refinement e test coverage completo
225
+ **Durata stimata**: 1-2 settimane
226
+
227
+ - [ ] Test coverage > 90%
228
+ - [ ] Performance optimization
229
+ - [ ] Documentation completa
230
+ - [ ] Bug fixes
231
+ - [ ] Edge cases
232
+
233
+ ### Versione 1.0.0 (Production Ready)
234
+ **Obiettivo**: Release stabile
235
+ **Durata stimata**: 1 settimana
236
+
237
+ - [ ] Final testing
238
+ - [ ] Security audit
239
+ - [ ] Performance benchmarks
240
+ - [ ] Migration guides
241
+ - [ ] Release notes
242
+ - [ ] RubyGems.org publication
243
+
244
+ ---
245
+
246
+ ## Timeline Complessiva
247
+
248
+ **Tempo totale stimato**: 12-18 settimane (3-4 mesi)
249
+
250
+ ```
251
+ Mese 1: Step 01-02 (Core + Essential SEO)
252
+ Mese 2: Step 03-04 (Structured Data + Technical SEO)
253
+ Mese 3: Step 05-06 (Rails Integration + i18n)
254
+ Mese 4: Step 07 + Polish + Release (Images + Testing + v1.0)
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Priorità di Sviluppo
260
+
261
+ ### 🔴 Alta Priorità (MVP - Versione 0.3.0)
262
+ 1. **Core & Configuration** (Step 01)
263
+ 2. **Meta Tags & Open Graph** (Step 02)
264
+ 3. **Rails Integration Base** (Step 05 - parziale)
265
+
266
+ Questi 3 elementi costituiscono il **Minimum Viable Product** utilizzabile.
267
+
268
+ ### 🟡 Media Priorità (Versione 0.6.0)
269
+ 4. **Structured Data** (Step 03)
270
+ 5. **Sitemap & Robots** (Step 04)
271
+ 6. **Rails Integration Completa** (Step 05)
272
+
273
+ ### 🟢 Bassa Priorità (Versione 1.0.0)
274
+ 7. **i18n Generator** (Step 06)
275
+ 8. **Image Optimization** (Step 07)
276
+
277
+ ---
278
+
279
+ ## Dipendenze tra Step
280
+
281
+ ```
282
+ Step 01 (Core)
283
+
284
+ Step 02 (Meta Tags) ← Dipende da Step 01
285
+
286
+ Step 05 (Rails) ← Dipende da Step 01, 02
287
+
288
+ Step 03 (Structured Data) ← Dipende da Step 01
289
+
290
+ Step 04 (Sitemap) ← Dipende da Step 01
291
+
292
+ Step 06 (i18n) ← Dipende da Step 01, 02, 05
293
+
294
+ Step 07 (Images) ← Dipende da Step 01, 05
295
+ ```
296
+
297
+ **Ordine raccomandato**: 01 → 02 → 05 (parziale) → 03 → 04 → 05 (completo) → 06 → 07
298
+
299
+ ---
300
+
301
+ ## Principi di Design
302
+
303
+ ### 1. **DSL Dichiarativo Rails-like**
304
+ ```ruby
305
+ BetterSeo.configure do |config|
306
+ config.meta_tags do
307
+ title "Il Mio Sito"
308
+ description "Descrizione del sito"
309
+ end
310
+ end
311
+ ```
312
+
313
+ ### 2. **Convention over Configuration**
314
+ - Defaults intelligenti
315
+ - Configurazione opzionale
316
+ - Auto-detection quando possibile
317
+
318
+ ### 3. **Modulare e Estendibile**
319
+ - Ogni componente indipendente
320
+ - Plugin system per estensioni
321
+ - Backward compatibility
322
+
323
+ ### 4. **Performance First**
324
+ - Lazy loading
325
+ - Caching intelligente
326
+ - Minimal overhead
327
+
328
+ ### 5. **Testing Rigoroso**
329
+ - Test coverage > 90%
330
+ - Unit + Integration tests
331
+ - Fixtures realistiche
332
+
333
+ ### 6. **Developer Experience**
334
+ - Error messages chiari
335
+ - Validazione configurazione
336
+ - Debug mode
337
+ - Logging opzionale
338
+
339
+ ---
340
+
341
+ ## Pattern Architetturali Utilizzati
342
+
343
+ ### Builder Pattern (DSL)
344
+ ```ruby
345
+ class MetaTagsBuilder
346
+ def title(value)
347
+ @config[:title] = value
348
+ self
349
+ end
350
+
351
+ def description(value)
352
+ @config[:description] = value
353
+ self
354
+ end
355
+ end
356
+ ```
357
+
358
+ ### Strategy Pattern (Generators)
359
+ ```ruby
360
+ class GeneratorFactory
361
+ def self.create(type)
362
+ case type
363
+ when :meta_tags then MetaTagsGenerator.new
364
+ when :open_graph then OpenGraphGenerator.new
365
+ end
366
+ end
367
+ end
368
+ ```
369
+
370
+ ### Validator Pattern
371
+ ```ruby
372
+ class MetaValidator
373
+ def validate(config)
374
+ Result.new(errors: [], warnings: [])
375
+ end
376
+ end
377
+ ```
378
+
379
+ ### Concern Pattern (Rails)
380
+ ```ruby
381
+ module BetterSeo
382
+ module Concerns
383
+ module SeoAware
384
+ extend ActiveSupport::Concern
385
+
386
+ included do
387
+ helper_method :current_seo_config
388
+ end
389
+ end
390
+ end
391
+ end
392
+ ```
393
+
394
+ ---
395
+
396
+ ## Metriche di Successo
397
+
398
+ ### Code Quality
399
+ - [ ] Test coverage > 90%
400
+ - [ ] Rubocop compliant (0 offenses)
401
+ - [ ] Zero deprecation warnings
402
+ - [ ] No security vulnerabilities
403
+
404
+ ### Performance
405
+ - [ ] Overhead < 5ms per request
406
+ - [ ] Memory footprint < 10MB
407
+ - [ ] Sitemap generation < 1s per 10k URLs
408
+ - [ ] Image optimization: 60-70% size reduction
409
+
410
+ ### Developer Experience
411
+ - [ ] Setup time < 5 minuti
412
+ - [ ] Documentation completa
413
+ - [ ] Esempi per ogni feature
414
+ - [ ] Troubleshooting guide
415
+
416
+ ### Adoption
417
+ - [ ] Published on RubyGems.org
418
+ - [ ] > 100 downloads/week
419
+ - [ ] GitHub stars > 50
420
+ - [ ] Active community support
421
+
422
+ ---
423
+
424
+ ## Risorse Necessarie
425
+
426
+ ### Team
427
+ - **1 Senior Ruby Developer** (lead)
428
+ - **1 Junior/Mid Developer** (support)
429
+ - Optional: **1 Technical Writer** (documentation)
430
+
431
+ ### Tools & Services
432
+ - GitHub (repository + CI/CD)
433
+ - RubyGems.org (distribution)
434
+ - CircleCI / GitHub Actions (CI)
435
+ - CodeClimate (code quality)
436
+ - Dependabot (dependency updates)
437
+
438
+ ### Testing Environment
439
+ - Ruby 3.0, 3.1, 3.2, 3.3
440
+ - Rails 6.1, 7.0, 7.1
441
+ - Multiple OS (Linux, macOS)
442
+
443
+ ---
444
+
445
+ ## Rischi e Mitigazioni
446
+
447
+ ### Rischio 1: Compatibilità Rails Versions
448
+ **Mitigazione**: Test matrix con Rails 6.1+, uso API stabili
449
+
450
+ ### Rischio 2: Dipendenze Esterne (imagemagick, vips)
451
+ **Mitigazione**: Rendere image optimization opzionale, fallback graceful
452
+
453
+ ### Rischio 3: Performance Overhead
454
+ **Mitigazione**: Profiling regolare, caching aggressivo, lazy loading
455
+
456
+ ### Rischio 4: Breaking Changes
457
+ **Mitigazione**: Semantic versioning, deprecation warnings, migration guides
458
+
459
+ ---
460
+
461
+ ## Prossimi Passi
462
+
463
+ 1. **Leggere** `docs/README.md` per indice completo
464
+ 2. **Iniziare** con Step 01: `docs/01_CORE_AND_CONFIGURATION.md`
465
+ 3. **Setup** environment di sviluppo (vedi `docs/DEPENDENCIES.md`)
466
+ 4. **Comprendere** strategia testing (vedi `docs/TESTING_STRATEGY.md`)
467
+
468
+ ---
469
+
470
+ **Data creazione**: 2025-10-22
471
+ **Versione documento**: 1.0
472
+ **Autore**: BetterSeo Team