Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/yeoman/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,18 @@ var WordpressGenerator = yeoman.generators.Base.extend({
}
},

prepareHtaccess: function() {
try {
this.htaccessFile = this.readFileAsString(path.join(this.env.cwd, 'web', '.htaccess'));
this.htaccessFile = this.htaccessFile.replace(/# BEGIN Evolution WordPress(?:.|[\r\n]+)+?# END Evolution WordPress[\r\n]*/i, '');

this.htaccessWpBlock = !!this.htaccessFile.match(/# BEGIN WordPress(?:.|[\r\n]+)+?# END WordPress[\r\n]*/i);
} catch(e) {
this.htaccessFile = '';
this.htaccessWpBlock = false;
}
},

prepareRoles: function() {
this.props.roles = WordpressGenerator.roles.map(function(role) {
role.checked = !!~this.props.roles.indexOf(role.value);
Expand Down
14 changes: 12 additions & 2 deletions lib/yeoman/templates/web/_htaccess
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# BEGIN WordPress
# BEGIN Evolution WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Prevent spidering of non-canonical URLs, such as `[*.]staging.*` and `production.*`.
RewriteCond %{HTTP_HOST} (^local|staging|^production)\.<%= props.domain.replace('.', '\\.') %>$ [NC]
RewriteRule ^robots.txt$ no_robots.txt [L]
</IfModule>
# END Evolution WordPress
<%= htaccessFile %>
<% if (!htaccessWpBlock) { %># BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Expand All @@ -7,4 +17,4 @@ RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# END WordPress<% } %>
5 changes: 5 additions & 0 deletions lib/yeoman/templates/web/no_robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
User-agent: *

Disallow: /

# Block everything...
15 changes: 15 additions & 0 deletions lib/yeoman/templates/web/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
User-agent: *

Disallow: /cgi-bin
Disallow: /feed
Disallow: /wp/feed
Disallow: /wp-admin
Disallow: /wp/wp-admin
Disallow: /wp-content/cache
Disallow: /wp/wp-content/cache
Disallow: /trackback
Disallow: /wp/trackback
Disallow: /wp/xmlrpc.php
Disallow: ?wptheme=

# Sitemap: http://<%= props.domain %>/sitemap.xml
File renamed without changes.
18 changes: 18 additions & 0 deletions test/functional/08-robots.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

var assert = require('assert');
var Browser = require('zombie');

describe.only('robots.txt', function(done) {
it('on local, should disallow all', function(done) {
var browser = new Browser();

browser
.visit('http://local.example.com/robots.txt')
.then(function() {
assert(!!browser.text().match('# Block everything...'));
})
.then(done, done)
;
});
});