middleman-robots 0.1.0 → 1.0.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/README.jp.md +97 -0
- data/README.md +39 -9
- data/features/robots.feature +25 -7
- data/lib/middleman-robots/extension.rb +5 -2
- data/lib/middleman-robots/version.rb +1 -1
- 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: d4f01f8d0fdf3304844fdb713988704f4f423358
|
4
|
+
data.tar.gz: 001ecdfa3873a65ad43e8efb9e62372622dba93b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0be81551938bbf181122120adb2bb52b3e8c87580fd93bb8b1651809ec838744eac22171aec43ed0962f2d44e518fd325d0899f54ee47f201cbaff0cea5a5d1c
|
7
|
+
data.tar.gz: 029da2753b999fcd612fec08d7ab68386a5541a63cc5f5d0ec057fdf471dea09d3f0712016932ce722604bb044c26d55613448c4a7e8e71a1924b6bc3c6ebd4d
|
data/README.jp.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# Middleman::Robots
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/middleman-robots)
|
4
|
+
[](https://travis-ci.org/yterajima/middleman-robots)
|
5
|
+
|
6
|
+
`middleman-robots` は [Middleman](http://middlemanapp.com/) の拡張機能です。 build 実行時に `config.rb` に記述されたルールに基いて `robots.txt` を作ります。
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Gemfile に次の行を追加してください:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'middleman-robots'
|
14
|
+
```
|
15
|
+
|
16
|
+
コマンドを実行します:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Gemfile を使わずにインストールする場合は次のコマンドを実行してください:
|
21
|
+
|
22
|
+
$ gem install middleman-robots
|
23
|
+
|
24
|
+
## 使い方
|
25
|
+
|
26
|
+
基本的な使い方です:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# config.rb
|
30
|
+
configure :build do
|
31
|
+
activate :robots, :rules => [
|
32
|
+
{:user_agent => '*', :allow => %w(/)}
|
33
|
+
],
|
34
|
+
:sitemap => "http://example.com/sitemap.xml"
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
作成される `robots.txt`:
|
39
|
+
|
40
|
+
```
|
41
|
+
User-Agent: *
|
42
|
+
Allow: /
|
43
|
+
|
44
|
+
Sitemap: http://example.com/sitemap.xml
|
45
|
+
|
46
|
+
```
|
47
|
+
|
48
|
+
|
49
|
+
オプションには `:rules` {[`:user_agent`(string), `:allow`(array), `:disallow`(array)]} と `:sitemap` を指定できます。すべてのオプションを指定すると次のようになります:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
# config.rb
|
53
|
+
configure :build do
|
54
|
+
activate :robots,
|
55
|
+
:rules => [
|
56
|
+
{
|
57
|
+
:user_agent => 'Googlebot',
|
58
|
+
:disallow => %w(tmp/ /something/dir/file_disallow.html),
|
59
|
+
:allow => %w(allow/ /something/dir/file_allow.html)
|
60
|
+
},
|
61
|
+
{
|
62
|
+
:user_agent => 'Googlebot-Image',
|
63
|
+
:disallow => %w(tmp/ /something/dir/file_disallow.html),
|
64
|
+
:allow => %w(allow/ /something/dir/file_allow.html)
|
65
|
+
}
|
66
|
+
],
|
67
|
+
:sitemap => "http://example.com/sitemap.xml"
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
作成される `robots.txt`:
|
72
|
+
|
73
|
+
```
|
74
|
+
User-Agent: Googlebot
|
75
|
+
Disallow: /tmp/
|
76
|
+
Disallow: /something/dir/file_disallow.html
|
77
|
+
Allow: /allow/
|
78
|
+
Allow: /something/dir/file_allow.html
|
79
|
+
|
80
|
+
User-Agent: Googlebot-Image
|
81
|
+
Disallow: /tmp/
|
82
|
+
Disallow: /something/dir/file_disallow.html
|
83
|
+
Allow: /allow/
|
84
|
+
Allow: /something/dir/file_allow.html
|
85
|
+
|
86
|
+
Sitemap: http://example.com/sitemap.xml
|
87
|
+
|
88
|
+
```
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
1. Fork it ( https://github.com/yterajima/middleman-robots/fork )
|
93
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
94
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
95
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
96
|
+
5. Create a new Pull Request
|
97
|
+
|
data/README.md
CHANGED
@@ -29,13 +29,23 @@ Basic usage:
|
|
29
29
|
# config.rb
|
30
30
|
configure :build do
|
31
31
|
activate :robots, :rules => [
|
32
|
-
{
|
32
|
+
{:user_agent => '*', :allow => %w(/)}
|
33
33
|
],
|
34
34
|
:sitemap => "http://example.com/sitemap.xml"
|
35
35
|
end
|
36
36
|
```
|
37
37
|
|
38
|
-
|
38
|
+
Created `robots.txt`:
|
39
|
+
|
40
|
+
```
|
41
|
+
User-Agent: *
|
42
|
+
Allow: /
|
43
|
+
|
44
|
+
Sitemap: http://example.com/sitemap.xml
|
45
|
+
|
46
|
+
```
|
47
|
+
|
48
|
+
You can use options, `:rules` {[`:user_agent`(string), `:allow`(array), `:disallow`(array)]} and `:sitemap`. Like this:
|
39
49
|
|
40
50
|
```ruby
|
41
51
|
# config.rb
|
@@ -43,24 +53,44 @@ configure :build do
|
|
43
53
|
activate :robots,
|
44
54
|
:rules => [
|
45
55
|
{
|
46
|
-
|
47
|
-
:disallow => %w(tmp
|
48
|
-
:allow => %w(allow
|
56
|
+
:user_agent => 'Googlebot',
|
57
|
+
:disallow => %w(tmp/ /something/dir/file_disallow.html),
|
58
|
+
:allow => %w(allow/ /something/dir/file_allow.html)
|
49
59
|
},
|
50
60
|
{
|
51
|
-
|
52
|
-
:disallow => %w(tmp
|
53
|
-
:allow => %w(allow
|
61
|
+
:user_agent => 'Googlebot-Image',
|
62
|
+
:disallow => %w(tmp/ /something/dir/file_disallow.html),
|
63
|
+
:allow => %w(allow/ /something/dir/file_allow.html)
|
54
64
|
}
|
55
65
|
],
|
56
66
|
:sitemap => "http://example.com/sitemap.xml"
|
57
67
|
end
|
58
68
|
```
|
59
69
|
|
70
|
+
Created `robots.txt`:
|
71
|
+
|
72
|
+
```
|
73
|
+
User-Agent: Googlebot
|
74
|
+
Disallow: /tmp/
|
75
|
+
Disallow: /something/dir/file_disallow.html
|
76
|
+
Allow: /allow/
|
77
|
+
Allow: /something/dir/file_allow.html
|
78
|
+
|
79
|
+
User-Agent: Googlebot-Image
|
80
|
+
Disallow: /tmp/
|
81
|
+
Disallow: /something/dir/file_disallow.html
|
82
|
+
Allow: /allow/
|
83
|
+
Allow: /something/dir/file_allow.html
|
84
|
+
|
85
|
+
Sitemap: http://example.com/sitemap.xml
|
86
|
+
|
87
|
+
```
|
88
|
+
|
60
89
|
## Contributing
|
61
90
|
|
62
|
-
1. Fork it ( https://github.com/
|
91
|
+
1. Fork it ( https://github.com/yterajima/middleman-robots/fork )
|
63
92
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
93
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
94
|
4. Push to the branch (`git push origin my-new-feature`)
|
66
95
|
5. Create a new Pull Request
|
96
|
+
|
data/features/robots.feature
CHANGED
@@ -13,6 +13,24 @@ Feature: Middleman-Robots
|
|
13
13
|
Then a file named "robots.txt" should exist
|
14
14
|
And the output should contain "middleman-robots: robots.txt created"
|
15
15
|
|
16
|
+
Scenario: Rules option with user_agent
|
17
|
+
Given a fixture app "basic-app"
|
18
|
+
And a file named "config.rb" with:
|
19
|
+
"""
|
20
|
+
configure :build do
|
21
|
+
activate :robots, :rules => [
|
22
|
+
{:user_agent => '*'}
|
23
|
+
]
|
24
|
+
end
|
25
|
+
"""
|
26
|
+
And a successfully built app at "basic-app"
|
27
|
+
When I cd to "build"
|
28
|
+
Then the file "robots.txt" should contain exactly:
|
29
|
+
"""
|
30
|
+
User-Agent: *
|
31
|
+
|
32
|
+
"""
|
33
|
+
|
16
34
|
Scenario: Rules option with user-agent
|
17
35
|
Given a fixture app "basic-app"
|
18
36
|
And a file named "config.rb" with:
|
@@ -38,7 +56,7 @@ Feature: Middleman-Robots
|
|
38
56
|
configure :build do
|
39
57
|
activate :robots, :rules => [
|
40
58
|
{
|
41
|
-
|
59
|
+
:user_agent => '*',
|
42
60
|
:disallow => %w(tmp/* /something/dir/file_disallow.html)
|
43
61
|
}
|
44
62
|
]
|
@@ -61,7 +79,7 @@ Feature: Middleman-Robots
|
|
61
79
|
configure :build do
|
62
80
|
activate :robots, :rules => [
|
63
81
|
{
|
64
|
-
|
82
|
+
:user_agent => '*',
|
65
83
|
:allow => %w(allow/* /something/dir/file_allow.html)
|
66
84
|
}
|
67
85
|
]
|
@@ -84,7 +102,7 @@ Feature: Middleman-Robots
|
|
84
102
|
configure :build do
|
85
103
|
activate :robots, :rules => [
|
86
104
|
{
|
87
|
-
|
105
|
+
:user_agent => '*',
|
88
106
|
:disallow => %w(tmp/* /something/dir/file_disallow.html),
|
89
107
|
:allow => %w(allow/* /something/dir/file_allow.html)
|
90
108
|
}
|
@@ -110,12 +128,12 @@ Feature: Middleman-Robots
|
|
110
128
|
configure :build do
|
111
129
|
activate :robots, :rules => [
|
112
130
|
{
|
113
|
-
|
131
|
+
:user_agent => 'Googlebot',
|
114
132
|
:disallow => %w(tmp/* /something/dir/file_disallow.html),
|
115
133
|
:allow => %w(allow/* /something/dir/file_allow.html)
|
116
134
|
},
|
117
135
|
{
|
118
|
-
|
136
|
+
:user_agent => 'Googlebot-Image',
|
119
137
|
:disallow => %w(tmp/* /something/dir/file_disallow.html),
|
120
138
|
:allow => %w(allow/* /something/dir/file_allow.html)
|
121
139
|
}
|
@@ -164,12 +182,12 @@ Feature: Middleman-Robots
|
|
164
182
|
activate :robots,
|
165
183
|
:rules => [
|
166
184
|
{
|
167
|
-
|
185
|
+
:user_agent => 'Googlebot',
|
168
186
|
:disallow => %w(tmp/* /something/dir/file_disallow.html),
|
169
187
|
:allow => %w(allow/* /something/dir/file_allow.html)
|
170
188
|
},
|
171
189
|
{
|
172
|
-
|
190
|
+
:user_agent => 'Googlebot-Image',
|
173
191
|
:disallow => %w(tmp/* /something/dir/file_disallow.html),
|
174
192
|
:allow => %w(allow/* /something/dir/file_allow.html)
|
175
193
|
}
|
@@ -25,8 +25,10 @@ module Middleman
|
|
25
25
|
data = []
|
26
26
|
rules.each do |rule|
|
27
27
|
row = []
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
if (rule["user-agent"] || rule[:user_agent])
|
30
|
+
user_agent = rule[:user_agent] || rule["user-agent"]
|
31
|
+
row << "User-Agent: #{user_agent}"
|
30
32
|
end
|
31
33
|
|
32
34
|
if (rule[:disallow])
|
@@ -55,3 +57,4 @@ module Middleman
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
60
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-robots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yterajima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- ".travis.yml"
|
92
92
|
- Gemfile
|
93
93
|
- LICENSE.txt
|
94
|
+
- README.jp.md
|
94
95
|
- README.md
|
95
96
|
- Rakefile
|
96
97
|
- features/robots.feature
|