simple_sitemap_generator 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -4
- data/lib/simple_sitemap_generator.rb +5 -3
- data/pkg/simple_sitemap_generator-0.1.0.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5323e2b99f39639cd561858feb085f1026c193a5
|
4
|
+
data.tar.gz: e9f6f2bfaeba71a74f3251bb2af8e948975151c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3845bda32bf2528e89047ae93b444562b73f6467bb75f3a787038234b02e0a57a6c73e38dfac8858e29f857df3889d7f51c2afe8879efc89534ca71799e085f6
|
7
|
+
data.tar.gz: d044fd399ee7279b0a4deaded581354529e5cb10f984404f54278139ffcb2bfd5e81f6ad778dc10c1dd36b233235c83377a63d13080da5c4962ef8e965033e78
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# SimpleSitemapGenerator
|
2
2
|
|
3
|
-
|
3
|
+
SimpleSitemapGenerator is a gem for Ruby on Rails to generate sitemap.xml.
|
4
4
|
|
5
|
-
|
5
|
+
## Features
|
6
|
+
|
7
|
+
* Generates `sitemap.xml` **dynamically** by using `config/routes.rb`.
|
8
|
+
* Enable to respond **without static file** (eg. `public/sitemap.xml`).
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
@@ -21,8 +24,55 @@ Or install it yourself as:
|
|
21
24
|
$ gem install simple_sitemap_generator
|
22
25
|
|
23
26
|
## Usage
|
27
|
+
All you have to do is following.
|
28
|
+
|
29
|
+
##### config/routes.rb
|
30
|
+
```ruby
|
31
|
+
get '/sitemap.xml', action: :sitemap, controller: :sitemap
|
32
|
+
```
|
33
|
+
|
34
|
+
##### app/controllers/sitemap_controller.rb
|
35
|
+
```ruby
|
36
|
+
class SitemapController < BaseController
|
37
|
+
def sitemap
|
38
|
+
send_data(SimpleSitemapGenerator::Sitemap.generate_xml, type: 'text/xml')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
##### config/initializers/sitemap.rb
|
44
|
+
```ruby
|
45
|
+
# Set the host name for URL creation
|
46
|
+
SimpleSitemapGenerator::Sitemap.host = 'https://www.example.com'
|
47
|
+
|
48
|
+
# [optional] Set default parameter
|
49
|
+
SimpleSitemapGenerator::Sitemap.default_lastmod = Time.current
|
50
|
+
SimpleSitemapGenerator::Sitemap.default_priority = 0.5
|
51
|
+
SimpleSitemapGenerator::Sitemap.default_changefreq = 'daily'
|
52
|
+
|
53
|
+
# [optional] Set additional_paths
|
54
|
+
# NOTE: Output includes only static url (eg. '/users'), does not include dynamic url (eg. '/users/123').
|
55
|
+
# You should specify url if you want.
|
56
|
+
SimpleSitemapGenerator::Sitemap.additional_paths = [
|
57
|
+
'/users/123',
|
58
|
+
*Article.published.map{ |a| "/articles/#{a.id}"},
|
59
|
+
]
|
60
|
+
|
61
|
+
# [optional] Set inappropriate paths for sitemap.xml by regular expression
|
62
|
+
SimpleSitemapGenerator::Sitemap.inappropriate_paths += [
|
63
|
+
/^\/admin/,
|
64
|
+
/^\/mypage/,
|
65
|
+
]
|
66
|
+
|
67
|
+
# [optional] Set parameter to specific path if you want
|
68
|
+
SimpleSitemapGenerator::Sitemap.options = {
|
69
|
+
'/': {
|
70
|
+
priority: 1.0,
|
71
|
+
changefreq: 'daily',
|
72
|
+
},
|
73
|
+
}
|
74
|
+
```
|
24
75
|
|
25
|
-
TODO: Write usage instructions here
|
26
76
|
|
27
77
|
## Development
|
28
78
|
|
@@ -32,7 +82,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
82
|
|
33
83
|
## Contributing
|
34
84
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
85
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nullnull/simple_sitemap_generator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
86
|
|
37
87
|
## License
|
38
88
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module SimpleSitemapGenerator
|
2
|
-
VERSION = '0.
|
2
|
+
VERSION = '0.2.0'.freeze
|
3
3
|
|
4
4
|
class Generator
|
5
|
-
attr_accessor :host, :default_lastmod, :default_changefreq, :default_priority, :inappropriate_paths, :options
|
5
|
+
attr_accessor :host, :default_lastmod, :default_changefreq, :default_priority, :inappropriate_paths, :options, :additional_paths
|
6
6
|
|
7
7
|
def generate_xml
|
8
8
|
paths.map { |path| {
|
@@ -25,6 +25,7 @@ module SimpleSitemapGenerator
|
|
25
25
|
]
|
26
26
|
@host = ''
|
27
27
|
@options = {}
|
28
|
+
@additional_paths = []
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
@@ -42,11 +43,12 @@ module SimpleSitemapGenerator
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def paths
|
45
|
-
routes.select{ |route| route.verb == 'GET' }
|
46
|
+
paths = routes.select{ |route| route.verb == 'GET' }
|
46
47
|
.reject{ |route| redirect_path?(route) }
|
47
48
|
.map { |route| route.path.spec.to_s.gsub('(.:format)', '') }
|
48
49
|
.reject{ |path| inappropriate_path?(path) }
|
49
50
|
.uniq
|
51
|
+
paths + additional_paths
|
50
52
|
end
|
51
53
|
|
52
54
|
def redirect_path?(route)
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_sitemap_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katsuma Narisawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- bin/console
|
83
83
|
- bin/setup
|
84
84
|
- lib/simple_sitemap_generator.rb
|
85
|
+
- pkg/simple_sitemap_generator-0.1.0.gem
|
85
86
|
- simple_sitemap_generator.gemspec
|
86
87
|
homepage: https://github.com/nullnull/simple_sitemap_generator
|
87
88
|
licenses:
|