Skip to content

Commit

Permalink
8.2.2
Browse files Browse the repository at this point in the history
- Deprecate module
  • Loading branch information
pookmish authored Apr 18, 2023
2 parents 351102c + 7f90bd7 commit 78db923
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 111 deletions.
40 changes: 40 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: 2
# CircleCI integration with Drupal 8.

## Defines images and working directory.
defaults: &defaults
docker:
- image: pookmish/drupal8ci:pcov
- image: selenium/standalone-chrome:latest
- image: mariadb:10.3
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
working_directory: /var/www/html

back_to_dev: &back_to_dev
<<: *defaults
steps:
- checkout
- run:
name: Back to dev
command: |
composer global require SU-SWS/stanford-caravan:dev-8.x-2.x
~/.composer/vendor/bin/sws-caravan back-to-dev ${CIRCLE_TAG} ${CIRCLE_WORKING_DIRECTORY}
# Declare all of the jobs we should run.
jobs:
run-back-to-dev:
<<: *back_to_dev

# Declare a workflow that runs all of our jobs in parallel.
workflows:
version: 2
after_release:
jobs:
- run-back-to-dev:
filters:
tags:
only:
- /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*).*?$/
branches:
ignore:
- /.*/
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PHPUnit and Acceptance Tests
on: [push]
jobs:
phpunit:
name: PHPUnit Coverage Tests
runs-on: ubuntu-latest
container:
image: pookmish/drupal8ci:php8
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_ROOT_PASSWORD: drupal
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
with:
path: project
- name: Build project
run: |
composer global require fzaninotto/faker:'dev-master as 1.9.2'
composer global require SU-SWS/stanford-caravan:dev-8.x-2.x
~/.composer/vendor/bin/sws-caravan phpunit /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --with-coverage
7 changes: 7 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Nobots

8.x-2.2
--------------------------------------------------------------------------------
_Release Date: 2022-04-18_

- Deprecate module


8.x-2.1
--------------------------------------------------------------------------------
_Release Date: 2021-06-11_
Expand Down
93 changes: 49 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
# [No Bots](https://github.com/SU-SWS/nobots)
##### Version: 8.x

Maintainers: [jbickar](https://github.com/jbickar), [sherakama](https://github.com/sherakama), [pookmish](https://github.com/pookmish)
[Changelog.txt](CHANGELOG.txt)


This module blocks (well-behaved) search engine robots from
crawling, indexing, or archiving your site by setting a
"X-Robots-Tag: noindex,nofollow,noarchive" HTTP header.

Enable the module to block search engine robots.
Disable the module to let them crawl your site.

Installation
---

Install this module like any other module. [See Drupal Documentation](https://drupal.org/documentation/install/modules-themes/modules-7)

Configuration
---

Enable the module to block search engine robots.
Disable the module to let them crawl your site.

Advanced Configuration
---
You can set the `nobots` variable to **FALSE** to leave the module enabled, yet still allow robots to crawl your site.

An example use-case would be to set `$settings['nobots'] = FALSE;` in settings.php for the production environment, and `TRUE` for all other environments.

You can also set the state `nobots` to **FALSE**. `drush state:set nobots 0` would set this state to false.

Troubleshooting
---

If you are experiencing issues with this module try reverting the feature first. If you are still experiencing issues try posting an issue on the GitHub issues page.

Contribution / Collaboration
---

You are welcome to contribute functionality, bug fixes, or documentation to this module. If you would like to suggest a fix or new functionality you may add a new issue to the GitHub issue queue or you may fork this repository and submit a pull request. For more help please see [GitHub's article on fork, branch, and pull requests](https://help.github.com/articles/using-pull-requests)


# [No Bots](https://github.com/SU-SWS/nobots)
##### Version: 8.x

Maintainers: [jbickar](https://github.com/jbickar), [sherakama](https://github.com/sherakama), [pookmish](https://github.com/pookmish)
[Changelog.txt](CHANGELOG.txt)


This module blocks (well-behaved) search engine robots from
crawling, indexing, or archiving your site by setting a
"X-Robots-Tag: noindex,nofollow,noarchive" HTTP header.

Enable the module to block search engine robots.
Disable the module to let them crawl your site.

Installation
---

Install this module like any other module. [See Drupal Documentation](https://drupal.org/documentation/install/modules-themes/modules-7)

Configuration
---

Enable the module to block search engine robots.
Disable the module to let them crawl your site.

Advanced Configuration
---
You can set the `nobots` variable to **FALSE** to leave the module enabled, yet still allow robots to crawl your site.

An example use-case would be to set `$settings['nobots'] = FALSE;` in settings.php for the production environment, and `TRUE` for all other environments.

To set the state `nobots` to **TRUE**. `drush @[alias] state:set nobots 1` would block robots.
You can also set the state `nobots` to **FALSE**. `drush state:set nobots 0` would set this state to false.

Troubleshooting
---

If you are experiencing issues with this module try reverting the feature first. If you are still experiencing issues try posting an issue on the GitHub issues page.

Contribution / Collaboration
---

You are welcome to contribute functionality, bug fixes, or documentation to this module. If you would like to suggest a fix or new functionality you may add a new issue to the GitHub issue queue or you may fork this repository and submit a pull request. For more help please see [GitHub's article on fork, branch, and pull requests](https://help.github.com/articles/using-pull-requests)


Releases
---

Expand All @@ -56,3 +57,7 @@ Steps to build a new release:
- Give the PR a semver-compliant label, e.g., (`patch`, `minor`, `major`). This may happen automatically via Github actions (if a labeler action is configured).
- When the PR is merged to `master`, a new tag will be created automatically, bumping the version by the semver label.
- The github action is built from: [semver-release-action](https://github.com/K-Phoen/semver-release-action), and further documentation is available there.

Deprecated
---
This repo and su-sws/nobots is replaced by [drupal/nobots](https://www.drupal.org/project/nobots).
4 changes: 3 additions & 1 deletion nobots.info.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: 'No Bots'
type: module
description: 'Blocks (well-behaved) search engine robots from crawling, indexing, or archiving your site.'
version: 8.x-2.1
version: 8.x-2.2
core_version_requirement: ^8.8 || ^9
package: Stanford
lifecycle: deprecated
lifecycle_link: https://github.com/SU-SWS/nobots/blob/8.x-2.x/README.md#deprecated
8 changes: 4 additions & 4 deletions src/EventSubscriber/FinishResponseSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Drupal\Core\State\StateInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Drupal\Core\Site\Settings;

Expand Down Expand Up @@ -41,11 +41,11 @@ public static function getSubscribedEvents() {
/**
* Sets extra headers on successful responses.
*
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
* @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event
* The event to process.
*/
public function onRespond(FilterResponseEvent $event) {
if (Settings::get('nobots', TRUE) && $this->state->get('nobots', TRUE)) {
public function onRespond(ResponseEvent $event) {
if (Settings::get('nobots', FALSE) || $this->state->get('nobots', FALSE)) {
$response = $event->getResponse();
$response->headers->set('X-Robots-Tag', 'noindex,nofollow,noarchive', FALSE);
}
Expand Down
31 changes: 0 additions & 31 deletions tests/src/Functional/NobotsDisabledTest.php

This file was deleted.

31 changes: 0 additions & 31 deletions tests/src/Functional/NobotsEnabledTest.php

This file was deleted.

49 changes: 49 additions & 0 deletions tests/src/Kernel/NobotsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Drupal\Tests\nobots\Kernel;

use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;

/**
* Nobots tests.
*
* @coversDefaultClass \Drupal\nobots\EventSubscriber\FinishResponseSubscriber
*/
class NobotsTest extends KernelTestBase {

/**
* {@inheritdoc}
*/
protected static $modules = ['system', 'nobots'];

/**
* Test kernel event subscriber.
*/
public function testKernelEvent() {
$request = new Request();
$response = new Response();

$event = new ResponseEvent(
$this->createMock(HttpKernelInterface::class),
$request,
HttpKernelInterface::MASTER_REQUEST,
$response
);

/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */
$event_dispatcher = \Drupal::service('event_dispatcher');
$event_dispatcher->dispatch($event, KernelEvents::RESPONSE);

$this->assertEmpty($event->getResponse()->headers->get('X-Robots-Tag'));
\Drupal::state()->set('nobots',true);

$event_dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertNotEmpty($event->getResponse()->headers->get('X-Robots-Tag'));
}

}

0 comments on commit 78db923

Please sign in to comment.