sitemap_generator 7.0.3 → 7.1.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/CHANGES.md +73 -64
- data/README.md +142 -143
- data/VERSION +1 -1
- data/lib/capistrano/sitemap_generator.rb +2 -0
- data/lib/sitemap_generator/adapters/active_storage_adapter.rb +15 -10
- data/lib/sitemap_generator/adapters/aws_sdk_adapter.rb +13 -12
- data/lib/sitemap_generator/adapters/file_adapter.rb +10 -13
- data/lib/sitemap_generator/adapters/fog_adapter.rb +2 -2
- data/lib/sitemap_generator/adapters/google_storage_adapter.rb +5 -4
- data/lib/sitemap_generator/adapters/s3_adapter.rb +15 -14
- data/lib/sitemap_generator/adapters/wave_adapter.rb +5 -5
- data/lib/sitemap_generator/application.rb +5 -3
- data/lib/sitemap_generator/builder/sitemap_file.rb +17 -14
- data/lib/sitemap_generator/builder/sitemap_index_file.rb +20 -18
- data/lib/sitemap_generator/builder/sitemap_index_url.rb +5 -6
- data/lib/sitemap_generator/builder/sitemap_url.rb +58 -34
- data/lib/sitemap_generator/builder.rb +4 -2
- data/lib/sitemap_generator/core_ext/big_decimal.rb +38 -33
- data/lib/sitemap_generator/core_ext/numeric.rb +50 -46
- data/lib/sitemap_generator/helpers/number_helper.rb +52 -46
- data/lib/sitemap_generator/interpreter.rb +11 -15
- data/lib/sitemap_generator/link_set.rb +63 -65
- data/lib/sitemap_generator/railtie.rb +1 -0
- data/lib/sitemap_generator/simple_namer.rb +3 -4
- data/lib/sitemap_generator/sitemap_location.rb +44 -36
- data/lib/sitemap_generator/tasks.rb +1 -1
- data/lib/sitemap_generator/templates.rb +6 -7
- data/lib/sitemap_generator/utilities.rb +25 -17
- data/lib/sitemap_generator.rb +22 -14
- data/lib/tasks/sitemap_generator_tasks.rake +2 -0
- data/rails/install.rb +2 -0
- data/rails/uninstall.rb +2 -0
- data/templates/sitemap.rb +2 -0
- metadata +2 -2
data/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Sitemaps adhere to the [Sitemap 0.9 protocol][sitemap_protocol] specification.
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
11
|
* Framework agnostic
|
|
12
|
-
* Supports [News sitemaps][sitemap_news], [Video sitemaps][sitemap_video], [Image sitemaps][sitemap_images],
|
|
12
|
+
* Supports [News sitemaps][sitemap_news], [Video sitemaps][sitemap_video], [Image sitemaps][sitemap_images], Mobile sitemaps *(deprecated)*, [PageMap sitemaps][sitemap_pagemap] and [Alternate Links][alternate_links]
|
|
13
13
|
* Supports read-only filesystems like Heroku via uploading to a remote host like Amazon S3
|
|
14
14
|
* Adheres to the [Sitemap 0.9 protocol][sitemap_protocol]
|
|
15
15
|
* Handles millions of links
|
|
@@ -27,7 +27,7 @@ This is a simple standalone example. For Rails installation see the [Rails inst
|
|
|
27
27
|
|
|
28
28
|
Install:
|
|
29
29
|
|
|
30
|
-
```
|
|
30
|
+
```sh
|
|
31
31
|
gem install sitemap_generator
|
|
32
32
|
```
|
|
33
33
|
|
|
@@ -46,13 +46,13 @@ end
|
|
|
46
46
|
|
|
47
47
|
Run it:
|
|
48
48
|
|
|
49
|
-
```
|
|
49
|
+
```sh
|
|
50
50
|
ruby sitemap.rb
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
Output:
|
|
54
54
|
|
|
55
|
-
```
|
|
55
|
+
```text
|
|
56
56
|
In /Users/karl/projects/sitemap_generator-test/public/
|
|
57
57
|
+ sitemap.xml.gz 3 links / 364 Bytes
|
|
58
58
|
Sitemap stats: 3 links / 1 sitemaps / 0m00s
|
|
@@ -60,69 +60,69 @@ Sitemap stats: 3 links / 1 sitemaps / 0m00s
|
|
|
60
60
|
|
|
61
61
|
## Contents
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
63
|
+
* [SitemapGenerator](#sitemapgenerator)
|
|
64
|
+
* [Features](#features)
|
|
65
|
+
* [Show Me](#show-me)
|
|
66
|
+
* [Contents](#contents)
|
|
67
|
+
* [Foreword](#foreword)
|
|
68
|
+
* [Installation](#installation)
|
|
69
|
+
* [Ruby](#ruby)
|
|
70
|
+
* [Rails](#rails)
|
|
71
|
+
* [Getting Started](#getting-started)
|
|
72
|
+
* [Preventing Output](#preventing-output)
|
|
73
|
+
* [Rake Tasks](#rake-tasks)
|
|
74
|
+
* [Pinging Search Engines](#pinging-search-engines)
|
|
75
|
+
* [Crontab](#crontab)
|
|
76
|
+
* [Robots.txt](#robotstxt)
|
|
77
|
+
* [Ruby Modules](#ruby-modules)
|
|
78
|
+
* [Deployments \& Capistrano](#deployments--capistrano)
|
|
79
|
+
* [Sitemaps with no Index File](#sitemaps-with-no-index-file)
|
|
80
|
+
* [Upload Sitemaps to a Remote Host using Adapters](#upload-sitemaps-to-a-remote-host-using-adapters)
|
|
81
|
+
* [Supported Adapters](#supported-adapters)
|
|
82
|
+
* [`SitemapGenerator::FileAdapter`](#sitemapgeneratorfileadapter)
|
|
83
|
+
* [`SitemapGenerator::ActiveStorageAdapter`](#sitemapgeneratoractivestorageadapter)
|
|
84
|
+
* [`SitemapGenerator::FogAdapter`](#sitemapgeneratorfogadapter)
|
|
85
|
+
* [`SitemapGenerator::S3Adapter`](#sitemapgenerators3adapter)
|
|
86
|
+
* [`SitemapGenerator::AwsSdkAdapter`](#sitemapgeneratorawssdkadapter)
|
|
87
|
+
* [`SitemapGenerator::WaveAdapter`](#sitemapgeneratorwaveadapter)
|
|
88
|
+
* [`SitemapGenerator::GoogleStorageAdapter`](#sitemapgeneratorgooglestorageadapter)
|
|
89
|
+
* [An Example of Using an Adapter](#an-example-of-using-an-adapter)
|
|
90
|
+
* [Generating Multiple Sitemaps](#generating-multiple-sitemaps)
|
|
91
|
+
* [Sitemap Configuration](#sitemap-configuration)
|
|
92
|
+
* [A Simple Example](#a-simple-example)
|
|
93
|
+
* [Adding Links](#adding-links)
|
|
94
|
+
* [Supported Options to `add`](#supported-options-to-add)
|
|
95
|
+
* [Adding Links to the Sitemap Index](#adding-links-to-the-sitemap-index)
|
|
96
|
+
* [Accessing the LinkSet instance](#accessing-the-linkset-instance)
|
|
97
|
+
* [Using `create` without a block](#using-create-without-a-block)
|
|
98
|
+
* [Speeding Things Up](#speeding-things-up)
|
|
99
|
+
* [Customizing your Sitemaps](#customizing-your-sitemaps)
|
|
100
|
+
* [Sitemap Options](#sitemap-options)
|
|
101
|
+
* [Sitemap Groups](#sitemap-groups)
|
|
102
|
+
* [A Groups Example](#a-groups-example)
|
|
103
|
+
* [Using `group` without a block](#using-group-without-a-block)
|
|
104
|
+
* [Sitemap Extensions](#sitemap-extensions)
|
|
105
|
+
* [News Sitemaps](#news-sitemaps)
|
|
106
|
+
* [Example](#example)
|
|
107
|
+
* [Supported options](#supported-options)
|
|
108
|
+
* [Image Sitemaps](#image-sitemaps)
|
|
109
|
+
* [Example](#example-1)
|
|
110
|
+
* [Supported options](#supported-options-1)
|
|
111
|
+
* [Video Sitemaps](#video-sitemaps)
|
|
112
|
+
* [Example](#example-2)
|
|
113
|
+
* [Supported options](#supported-options-2)
|
|
114
|
+
* [PageMap Sitemaps](#pagemap-sitemaps)
|
|
115
|
+
* [Supported options](#supported-options-3)
|
|
116
|
+
* [Example:](#example-3)
|
|
117
|
+
* [Alternate Links](#alternate-links)
|
|
118
|
+
* [Example](#example-4)
|
|
119
|
+
* [Supported options](#supported-options-4)
|
|
120
|
+
* [Alternates Example](#alternates-example)
|
|
121
|
+
* [Mobile Sitemaps](#mobile-sitemaps)
|
|
122
|
+
* [Example](#example-5)
|
|
123
|
+
* [Supported options](#supported-options-5)
|
|
124
|
+
* [Compatibility](#compatibility)
|
|
125
|
+
* [Licence](#licence)
|
|
126
126
|
|
|
127
127
|
## Foreword
|
|
128
128
|
|
|
@@ -132,12 +132,11 @@ Those who knew him know what an amazing guy he was, and what an excellent Rails
|
|
|
132
132
|
|
|
133
133
|
The canonical repository is: [http://github.com/kjvarga/sitemap_generator][canonical_repo]
|
|
134
134
|
|
|
135
|
-
|
|
136
135
|
## Installation
|
|
137
136
|
|
|
138
137
|
### Ruby
|
|
139
138
|
|
|
140
|
-
```
|
|
139
|
+
```sh
|
|
141
140
|
gem install 'sitemap_generator'
|
|
142
141
|
```
|
|
143
142
|
|
|
@@ -248,7 +247,7 @@ end
|
|
|
248
247
|
|
|
249
248
|
You should add the URL of the sitemap index file to `public/robots.txt` to help search engines find your sitemaps. The URL should be the complete URL to the sitemap index. For example:
|
|
250
249
|
|
|
251
|
-
```
|
|
250
|
+
```text
|
|
252
251
|
Sitemap: http://www.example.com/sitemap.xml.gz
|
|
253
252
|
```
|
|
254
253
|
|
|
@@ -309,6 +308,7 @@ To never create an index:
|
|
|
309
308
|
```ruby
|
|
310
309
|
SitemapGenerator::Sitemap.create_index = false
|
|
311
310
|
```
|
|
311
|
+
|
|
312
312
|
Your sitemaps will still be called `sitemap.xml.gz`, `sitemap1.xml.gz`, `sitemap2.xml.gz`, etc.
|
|
313
313
|
|
|
314
314
|
And the default "intelligent" behaviour:
|
|
@@ -423,6 +423,7 @@ name but capitalized, e.g. `AWS_SESSION_TOKEN`, `FOG_PATH_STYLE`.
|
|
|
423
423
|
project_id: 'google_account_project_id',
|
|
424
424
|
)
|
|
425
425
|
```
|
|
426
|
+
|
|
426
427
|
Also, inline with Google Authentication options, it can also pick credentials from environment variables. All [supported environment variables][google_cloud_storage_authentication] can be used, for example: `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_CREDENTIALS`. An example of using this adapter with the environment variables is:
|
|
427
428
|
|
|
428
429
|
```ruby
|
|
@@ -438,7 +439,7 @@ name but capitalized, e.g. `AWS_SESSION_TOKEN`, `FOG_PATH_STYLE`.
|
|
|
438
439
|
1. Please see [this wiki page][remote_hosts] for more information about setting up SitemapGenerator to upload to a
|
|
439
440
|
remote host.
|
|
440
441
|
|
|
441
|
-
|
|
442
|
+
1. This example uses the CarrierWave adapter. It shows some common settings that are used when the hostname hosting
|
|
442
443
|
the sitemaps differs from the hostname of the sitemap links.
|
|
443
444
|
|
|
444
445
|
```ruby
|
|
@@ -458,9 +459,9 @@ name but capitalized, e.g. `AWS_SESSION_TOKEN`, `FOG_PATH_STYLE`.
|
|
|
458
459
|
SitemapGenerator::Sitemap.adapter = SitemapGenerator::WaveAdapter.new
|
|
459
460
|
```
|
|
460
461
|
|
|
461
|
-
|
|
462
|
+
1. Update your `robots.txt` file to point robots to the remote sitemap index file, e.g:
|
|
462
463
|
|
|
463
|
-
```
|
|
464
|
+
```text
|
|
464
465
|
Sitemap: http://s3.amazonaws.com/sitemap-generator/sitemaps/sitemap.xml.gz
|
|
465
466
|
```
|
|
466
467
|
|
|
@@ -471,7 +472,7 @@ name but capitalized, e.g. `AWS_SESSION_TOKEN`, `FOG_PATH_STYLE`.
|
|
|
471
472
|
that would otherwise be included would point to a different host than the rest of the links
|
|
472
473
|
in the sitemap, something that the sitemap rules forbid.
|
|
473
474
|
|
|
474
|
-
|
|
475
|
+
1. Verify to Google that you own the S3 url
|
|
475
476
|
|
|
476
477
|
In order for Google to use your sitemap, you need to prove you own the S3 bucket through [google webmaster tools](https://www.google.com/webmasters/tools/home?hl=en). In the example above, you would add the site `http://s3.amazonaws.com/sitemap-generator/sitemaps`. Once you have verified you own the directory, then add your
|
|
477
478
|
sitemap index to the list of sitemaps for the site.
|
|
@@ -497,7 +498,7 @@ end
|
|
|
497
498
|
|
|
498
499
|
Outputs:
|
|
499
500
|
|
|
500
|
-
```
|
|
501
|
+
```text
|
|
501
502
|
+ sitemaps/google/sitemap1.xml.gz 2 links / 822 Bytes / 328 Bytes gzipped
|
|
502
503
|
+ sitemaps/google/sitemap.xml.gz 1 sitemaps / 389 Bytes / 217 Bytes gzipped
|
|
503
504
|
Sitemap stats: 2 links / 1 sitemaps / 0m00s
|
|
@@ -536,7 +537,7 @@ end
|
|
|
536
537
|
|
|
537
538
|
To generate each one specify the configuration file to run by passing the `CONFIG_FILE` option to `rake sitemap:refresh`, e.g.:
|
|
538
539
|
|
|
539
|
-
```
|
|
540
|
+
```sh
|
|
540
541
|
rake sitemap:refresh CONFIG_FILE="config/google_sitemap.rb"
|
|
541
542
|
rake sitemap:refresh CONFIG_FILE="config/apple_sitemap.rb"
|
|
542
543
|
rake sitemap:refresh CONFIG_FILE="config/bing_sitemap.rb"
|
|
@@ -548,7 +549,7 @@ A sitemap configuration file contains all the information needed to generate you
|
|
|
548
549
|
|
|
549
550
|
If you want to use a non-standard configuration file, or have multiple configuration files, you can specify which one to run by passing the `CONFIG_FILE` option like so:
|
|
550
551
|
|
|
551
|
-
```
|
|
552
|
+
```sh
|
|
552
553
|
rake sitemap:refresh CONFIG_FILE="config/geo_sitemap.rb"
|
|
553
554
|
```
|
|
554
555
|
|
|
@@ -572,7 +573,7 @@ A few things to note:
|
|
|
572
573
|
|
|
573
574
|
Now let's see what is output when we run this configuration with `rake sitemap:refresh:no_ping`:
|
|
574
575
|
|
|
575
|
-
```
|
|
576
|
+
```text
|
|
576
577
|
In /Users/karl/projects/sitemap_generator-test/public/
|
|
577
578
|
+ sitemap.xml.gz 2 links / 347 Bytes
|
|
578
579
|
Sitemap stats: 2 links / 1 sitemaps / 0m00s
|
|
@@ -582,7 +583,6 @@ Weird! The sitemap has two links, even though we only added one! This is becau
|
|
|
582
583
|
|
|
583
584
|
Now let's take a look at the file that was created. After uncompressing and XML-tidying the contents we have:
|
|
584
585
|
|
|
585
|
-
|
|
586
586
|
* `public/sitemap.xml.gz`
|
|
587
587
|
|
|
588
588
|
```xml
|
|
@@ -617,7 +617,7 @@ end
|
|
|
617
617
|
|
|
618
618
|
And the output:
|
|
619
619
|
|
|
620
|
-
```
|
|
620
|
+
```text
|
|
621
621
|
In /Users/karl/projects/sitemap_generator-test/public/
|
|
622
622
|
+ sitemap1.xml.gz 2 links / 347 Bytes
|
|
623
623
|
+ sitemap.xml.gz 1 sitemaps / 228 Bytes
|
|
@@ -662,7 +662,7 @@ In the example about we pass a `lastmod` (last modified) option with the value o
|
|
|
662
662
|
|
|
663
663
|
Looking at the output from running this sitemap, we see that we have a few more links than before:
|
|
664
664
|
|
|
665
|
-
```
|
|
665
|
+
```text
|
|
666
666
|
+ sitemap.xml.gz 12 links / 2.3 KB / 365 Bytes gzipped
|
|
667
667
|
Sitemap stats: 12 links / 1 sitemaps / 0m00s
|
|
668
668
|
```
|
|
@@ -770,7 +770,7 @@ end
|
|
|
770
770
|
|
|
771
771
|
The output looks something like this:
|
|
772
772
|
|
|
773
|
-
```
|
|
773
|
+
```text
|
|
774
774
|
In /Users/karl/projects/sitemap_generator-test/public/
|
|
775
775
|
+ sitemap4.xml.gz 3 links / 355 Bytes
|
|
776
776
|
+ sitemap.xml.gz 4 sitemaps / 242 Bytes
|
|
@@ -848,8 +848,8 @@ The following options are supported.
|
|
|
848
848
|
* `:public_path` - String. A **full or relative path** to the `public` directory or the directory you want to write sitemaps into. Defaults to `public/` under your application root or relative to the current working directory.
|
|
849
849
|
|
|
850
850
|
* `:sitemaps_host` - String. **Host including protocol** to use when generating a link to a sitemap file i.e. the hostname of the server where the sitemaps are hosted. The value will differ from the hostname in your sitemap links. For example: `'http://amazon.aws.com/'`. Note that `include_index` is
|
|
851
|
-
automatically turned off when the `sitemaps_host` does not match `default_host`.
|
|
852
|
-
Because the link to the sitemap index file that would otherwise be added would point to a different host than the rest of the links in the sitemap. Something that the sitemap rules forbid.
|
|
851
|
+
automatically turned off when the `sitemaps_host` does not match `default_host`.
|
|
852
|
+
Because the link to the sitemap index file that would otherwise be added would point to a different host than the rest of the links in the sitemap. Something that the sitemap rules forbid.
|
|
853
853
|
|
|
854
854
|
* `:namer` - A `SitemapGenerator::SimpleNamer` instance **for generating sitemap names**. You can read about Sitemap Namers by reading the API docs. Allows you to set the name, extension and number sequence for sitemap files, as well as modify the name of the first file in the sequence, which is often the index file. A simple example if we want to generate files like 'newname.xml.gz', 'newname1.xml.gz', etc is `SitemapGenerator::SimpleNamer.new(:newname)`.
|
|
855
855
|
|
|
@@ -860,9 +860,9 @@ Because the link to the sitemap index file that would otherwise be added would p
|
|
|
860
860
|
* `:adapter` - Instance. The default adapter is a `SitemapGenerator::FileAdapter` which simply writes files to the filesystem. You can use a `SitemapGenerator::WaveAdapter` for uploading sitemaps to remote servers - useful for read-only hosts such as Heroku. Or you can provide an instance of your own class to provide custom behavior. Your class must define a write method which takes a `SitemapGenerator::Location` and raw XML data.
|
|
861
861
|
|
|
862
862
|
* `:compress` - Specifies which files to compress with gzip. Default is `true`. Accepted values:
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
863
|
+
* `true` - Boolean; compress all files.
|
|
864
|
+
* `false` - Boolean; Do not compress any files.
|
|
865
|
+
* `:all_but_first` - Symbol; leave the first file uncompressed but compress all remaining files.
|
|
866
866
|
|
|
867
867
|
The compression setting applies to groups too. So `:all_but_first` will have the same effect (the first file in the group will not be compressed, the rest will). So if you require different behaviour for your groups, pass in a `:compress` option e.g. `group(:compress => false) { add('/link') }`
|
|
868
868
|
|
|
@@ -903,7 +903,7 @@ end
|
|
|
903
903
|
|
|
904
904
|
And the output from running the above:
|
|
905
905
|
|
|
906
|
-
```
|
|
906
|
+
```text
|
|
907
907
|
In /Users/karl/projects/sitemap_generator-test/public/
|
|
908
908
|
+ en/english.xml.gz 1 links / 328 Bytes
|
|
909
909
|
+ fr/french.xml.gz 1 links / 329 Bytes
|
|
@@ -952,7 +952,7 @@ end
|
|
|
952
952
|
|
|
953
953
|
And the output from running the above:
|
|
954
954
|
|
|
955
|
-
```
|
|
955
|
+
```text
|
|
956
956
|
In '/Users/kvarga/Projects/sitemap_generator-test/public/':
|
|
957
957
|
+ odds.xml.gz 10 links / 371 Bytes
|
|
958
958
|
+ evens.xml.gz 10 links / 371 Bytes
|
|
@@ -987,14 +987,14 @@ end
|
|
|
987
987
|
#### Supported options
|
|
988
988
|
|
|
989
989
|
* `:news` - Hash
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
990
|
+
* `:publication_name`
|
|
991
|
+
* `:publication_language`
|
|
992
|
+
* `:publication_date`
|
|
993
|
+
* `:genres`
|
|
994
|
+
* `:access`
|
|
995
|
+
* `:title`
|
|
996
|
+
* `:keywords`
|
|
997
|
+
* `:stock_tickers`
|
|
998
998
|
|
|
999
999
|
### Image Sitemaps
|
|
1000
1000
|
|
|
@@ -1014,11 +1014,11 @@ end
|
|
|
1014
1014
|
#### Supported options
|
|
1015
1015
|
|
|
1016
1016
|
* `:images` - Array of hashes
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1017
|
+
* `:loc` Required, location of the image
|
|
1018
|
+
* `:caption`
|
|
1019
|
+
* `:geo_location`
|
|
1020
|
+
* `:title`
|
|
1021
|
+
* `:license`
|
|
1022
1022
|
|
|
1023
1023
|
### Video Sitemaps
|
|
1024
1024
|
|
|
@@ -1045,32 +1045,32 @@ end
|
|
|
1045
1045
|
#### Supported options
|
|
1046
1046
|
|
|
1047
1047
|
* `:video` or `:videos` - Hash or array of hashes, respectively
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1048
|
+
* `:thumbnail_loc` - Required. String, URL of the thumbnail image.
|
|
1049
|
+
* `:title` - Required. String, title of the video.
|
|
1050
|
+
* `:description` - Required. String, description of the video.
|
|
1051
|
+
* `:content_loc` - Depends. String, URL. One of content_loc or player_loc must be present.
|
|
1052
|
+
* `:player_loc` - Depends. String, URL. One of content_loc or player_loc must be present.
|
|
1053
|
+
* `:allow_embed` - Boolean, attribute of player_loc.
|
|
1054
|
+
* `:autoplay` - Boolean, default true. Attribute of player_loc.
|
|
1055
|
+
* `:duration` - Recommended. Integer or string. Duration in seconds.
|
|
1056
|
+
* `:expiration_date` - Recommended when applicable. The date after which the video will no longer be available.
|
|
1057
|
+
* `:rating` - Optional
|
|
1058
|
+
* `:view_count` - Optional. Integer or string.
|
|
1059
|
+
* `:publication_date` - Optional
|
|
1060
|
+
* `:tags` - Optional. Array of string tags.
|
|
1061
|
+
* `:tag` - Optional. String, single tag.
|
|
1062
|
+
* `:category` - Optional
|
|
1063
|
+
* `:family_friendly`- Optional. Boolean
|
|
1064
|
+
* `:gallery_loc` - Optional. String, URL.
|
|
1065
|
+
* `:gallery_title` - Optional. Title attribute of the gallery location element
|
|
1066
|
+
* `:uploader` - Optional.
|
|
1067
|
+
* `:uploader_info` - Optional. Info attribute of uploader element
|
|
1068
|
+
* `:price` - Optional. Only one price supported at this time
|
|
1069
|
+
* `:price_currency` - Required. In [ISO_4217][iso_4217] format.
|
|
1070
|
+
* `:price_type` - Optional. `rent` or `own`
|
|
1071
|
+
* `:price_resolution` - Optional. `HD` or `SD`
|
|
1072
|
+
* `:live` - Optional. Boolean.
|
|
1073
|
+
* `:requires_subscription` - Optional. Boolean.
|
|
1074
1074
|
|
|
1075
1075
|
### PageMap Sitemaps
|
|
1076
1076
|
|
|
@@ -1079,14 +1079,14 @@ Pagemaps can be added by passing a `:pagemap` hash to `add`. The hash must conta
|
|
|
1079
1079
|
#### Supported options
|
|
1080
1080
|
|
|
1081
1081
|
* `:pagemap` - Hash
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1082
|
+
* `:dataobjects` - Required, array of hashes
|
|
1083
|
+
* `:type` - Required, string, type of the object
|
|
1084
|
+
* `:id` - String, ID of the object
|
|
1085
|
+
* `:attributes` - Array of hashes
|
|
1086
|
+
* `:name` - Required, string, name of the attribute.
|
|
1087
|
+
* `:value` - String, value of the attribute.
|
|
1088
1088
|
|
|
1089
|
-
#### Example
|
|
1089
|
+
#### Example
|
|
1090
1090
|
|
|
1091
1091
|
```ruby
|
|
1092
1092
|
SitemapGenerator::Sitemap.default_host = "http://www.example.com"
|
|
@@ -1128,10 +1128,10 @@ end
|
|
|
1128
1128
|
#### Supported options
|
|
1129
1129
|
|
|
1130
1130
|
* `:alternate`/`:alternates` - Hash or array of hashes, respectively
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1131
|
+
* `:href` - Required, string.
|
|
1132
|
+
* `:lang` - Optional, string.
|
|
1133
|
+
* `:nofollow` - Optional, boolean. Used to mark link as "nofollow".
|
|
1134
|
+
* `:media` - Optional, string. Specify [media targets for responsive design pages][media].
|
|
1135
1135
|
|
|
1136
1136
|
#### Alternates Example
|
|
1137
1137
|
|
|
@@ -1157,7 +1157,7 @@ end
|
|
|
1157
1157
|
|
|
1158
1158
|
Mobile sitemaps include a specific `<mobile:mobile/>` tag.
|
|
1159
1159
|
|
|
1160
|
-
|
|
1160
|
+
> **Deprecated**: Google deprecated mobile sitemaps in August 2022. No other major search engines supported this format. Responsive design is the recommended approach for mobile-friendly content.
|
|
1161
1161
|
|
|
1162
1162
|
#### Example
|
|
1163
1163
|
|
|
@@ -1188,10 +1188,9 @@ Copyright (c) Karl Varga
|
|
|
1188
1188
|
[sitemap_images]:http://www.google.com/support/webmasters/bin/answer.py?answer=178636
|
|
1189
1189
|
[sitemap_video]:https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190
|
|
1190
1190
|
[sitemap_news]:https://support.google.com/news/publisher/topic/2527688?hl=en&ref_topic=4359874
|
|
1191
|
-
[sitemap_mobile]:http://support.google.com/webmasters/bin/answer.py?hl=en&answer=34648
|
|
1192
1191
|
[sitemap_pagemap]:https://developers.google.com/custom-search/docs/structured_data#addtositemap
|
|
1193
1192
|
[sitemap_protocol]:http://www.sitemaps.org/protocol.html
|
|
1194
|
-
[video_tags]:
|
|
1193
|
+
[video_tags]:https://developers.google.com/search/docs/crawling-indexing/sitemaps/video-sitemaps
|
|
1195
1194
|
[image_tags]:http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=178636
|
|
1196
1195
|
[news_tags]:http://www.google.com/support/news_pub/bin/answer.py?answer=74288
|
|
1197
1196
|
[remote_hosts]:https://github.com/kjvarga/sitemap_generator/wiki/Generate-Sitemaps-on-read-only-filesystems-like-Heroku
|
|
@@ -1199,7 +1198,7 @@ Copyright (c) Karl Varga
|
|
|
1199
1198
|
[using_pagemaps]:https://developers.google.com/custom-search/docs/structured_data#pagemaps
|
|
1200
1199
|
[iso_4217]:http://en.wikipedia.org/wiki/ISO_4217
|
|
1201
1200
|
[media]:https://developers.google.com/webmasters/smartphone-sites/details
|
|
1202
|
-
[expires]:https://support.google.com/
|
|
1201
|
+
[expires]:https://support.google.com/webmasters/answer/9689846
|
|
1203
1202
|
[google_cloud_storage_gem]:https://rubygems.org/gems/google-cloud-storage
|
|
1204
1203
|
[google_cloud_storage_authentication]:https://googleapis.dev/ruby/google-cloud-storage/latest/file.AUTHENTICATION.html
|
|
1205
1204
|
[google_cloud_storage_initializer]:https://github.com/googleapis/google-cloud-ruby/blob/master/google-cloud-storage/lib/google/cloud/storage.rb
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
7.0
|
|
1
|
+
7.1.0
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SitemapGenerator
|
|
2
4
|
# Class for uploading sitemaps to ActiveStorage.
|
|
3
5
|
class ActiveStorageAdapter
|
|
4
6
|
attr_reader :key, :filename
|
|
5
7
|
|
|
6
|
-
def initialize
|
|
7
|
-
@key
|
|
8
|
+
def initialize(key: :sitemap, filename: 'sitemap.xml.gz')
|
|
9
|
+
@key = key
|
|
10
|
+
@filename = filename
|
|
8
11
|
end
|
|
9
12
|
|
|
10
|
-
def write(location, raw_data)
|
|
13
|
+
def write(location, raw_data) # rubocop:disable Metrics/MethodLength
|
|
11
14
|
SitemapGenerator::FileAdapter.new.write(location, raw_data)
|
|
12
15
|
|
|
13
16
|
ActiveStorage::Blob.transaction do
|
|
14
17
|
ActiveStorage::Blob.where(key: key).destroy_all
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
File.open(location.path, 'rb') do |io|
|
|
20
|
+
ActiveStorage::Blob.create_and_upload!(
|
|
21
|
+
key: key,
|
|
22
|
+
io: io,
|
|
23
|
+
filename: filename,
|
|
24
|
+
content_type: 'application/gzip',
|
|
25
|
+
identify: false
|
|
26
|
+
)
|
|
27
|
+
end
|
|
23
28
|
end
|
|
24
29
|
end
|
|
25
30
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
if !defined?(Aws::S3::Resource)
|
|
3
|
+
if !defined?(Aws::S3::Resource) || !defined?(Aws::Credentials)
|
|
4
4
|
raise LoadError, "Error: `Aws::S3::Resource` and/or `Aws::Credentials` are not defined.\n\n" \
|
|
5
|
-
|
|
5
|
+
"Please `require 'aws-sdk'` - or another library that defines these classes."
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
module SitemapGenerator
|
|
@@ -24,12 +24,14 @@ module SitemapGenerator
|
|
|
24
24
|
# **Deprecated, use :secret_access_key instead** :aws_secret_access_key [String] Your AWS secret access key
|
|
25
25
|
# **Deprecated, use :region instead** :aws_region [String] Your AWS region
|
|
26
26
|
# :acl [String] The ACL to apply to the uploaded files. Defaults to 'public-read'.
|
|
27
|
-
# :cache_control [String] The cache control headder to apply to the uploaded files.
|
|
27
|
+
# :cache_control [String] The cache control headder to apply to the uploaded files.
|
|
28
|
+
# Defaults to 'private, max-age=0, no-cache'.
|
|
28
29
|
#
|
|
29
30
|
# All other options you provide are passed directly to the AWS client.
|
|
30
31
|
# See https://docs.aws.amazon.com/sdk-for-ruby/v2/api/Aws/S3/Client.html#initialize-instance_method
|
|
31
32
|
# for a full list of supported options.
|
|
32
|
-
def initialize(bucket, aws_access_key_id: nil, aws_secret_access_key: nil, aws_session_token: nil, aws_region: nil,
|
|
33
|
+
def initialize(bucket, aws_access_key_id: nil, aws_secret_access_key: nil, aws_session_token: nil, aws_region: nil, # rubocop:disable Metrics/ParameterLists
|
|
34
|
+
aws_endpoint: nil, acl: 'public-read', cache_control: 'private, max-age=0, no-cache', **options)
|
|
33
35
|
@bucket = bucket
|
|
34
36
|
@acl = acl
|
|
35
37
|
@cache_control = cache_control
|
|
@@ -42,25 +44,24 @@ module SitemapGenerator
|
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
# Call with a SitemapLocation and string data
|
|
45
|
-
def write(location, raw_data)
|
|
47
|
+
def write(location, raw_data) # rubocop:disable Metrics/MethodLength
|
|
46
48
|
SitemapGenerator::FileAdapter.new.write(location, raw_data)
|
|
47
49
|
|
|
48
50
|
if defined?(Aws::S3::TransferManager)
|
|
49
51
|
client = Aws::S3::Client.new(@options)
|
|
50
52
|
transfer_manager = Aws::S3::TransferManager.new(client: client)
|
|
51
53
|
transfer_manager.upload_file(location.path,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
)
|
|
54
|
+
bucket: @bucket,
|
|
55
|
+
key: location.path_in_public,
|
|
56
|
+
acl: @acl,
|
|
57
|
+
cache_control: @cache_control,
|
|
58
|
+
content_type: location.content_type)
|
|
58
59
|
else
|
|
59
60
|
s3_object = s3_resource.bucket(@bucket).object(location.path_in_public)
|
|
60
61
|
s3_object.upload_file(location.path, {
|
|
61
62
|
acl: @acl,
|
|
62
63
|
cache_control: @cache_control,
|
|
63
|
-
content_type: location
|
|
64
|
+
content_type: location.content_type
|
|
64
65
|
}.compact)
|
|
65
66
|
end
|
|
66
67
|
end
|