Skip to content

Commit

Permalink
site improve update
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Waye committed Jan 7, 2023
1 parent 9704ed4 commit be77dcb
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 55 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"drupal/simple_timeline": "^1.1",
"drupal/simplenews": "^2.0@beta",
"drupal/single_content_sync": "^1.1@RC",
"drupal/siteimprove": "^1.12",
"drupal/siteimprove": "^2.0",
"drupal/social_media_links": "^2.6",
"drupal/superfish": "^1.4",
"drupal/token_filter": "^1.3",
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -9262,30 +9262,30 @@
},
{
"name": "drupal/siteimprove",
"version": "1.12.0",
"version_normalized": "1.12.0.0",
"version": "2.0.0",
"version_normalized": "2.0.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/siteimprove.git",
"reference": "8.x-1.12"
"reference": "2.0.0"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/siteimprove-8.x-1.12.zip",
"reference": "8.x-1.12",
"shasum": "1df830298b36cff3201c1aaf0cc1cdec2741a3e9"
"url": "https://ftp.drupal.org/files/projects/siteimprove-2.0.0.zip",
"reference": "2.0.0",
"shasum": "b79c37852d835d97c502615aded96a9855e9f493"
},
"require": {
"drupal/core": "^8 || ^9"
"drupal/core": "^9.2 || ^10"
},
"require-dev": {
"drupal/domain_access": "*"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.12",
"datestamp": "1646062571",
"version": "2.0.0",
"datestamp": "1671009593",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
Expand All @@ -9298,10 +9298,6 @@
"GPL-2.0+"
],
"authors": [
{
"name": "Siteimprove",
"homepage": "https://www.drupal.org/user/3521441"
},
{
"name": "bartvig",
"homepage": "https://www.drupal.org/user/3107079"
Expand All @@ -9322,6 +9318,10 @@
"name": "rofejo",
"homepage": "https://www.drupal.org/user/3284851"
},
{
"name": "Siteimprove",
"homepage": "https://www.drupal.org/user/3521441"
},
{
"name": "tlyngej",
"homepage": "https://www.drupal.org/user/413139"
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'drupal-composer/drupal-project',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'c72f5ee12fe7a5d1d2bf8f3e001bbea7fa993e99',
'reference' => '9704ed49fa1baf8d7eae974115b27c2cadf134a3',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -289,7 +289,7 @@
'drupal-composer/drupal-project' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'c72f5ee12fe7a5d1d2bf8f3e001bbea7fa993e99',
'reference' => '9704ed49fa1baf8d7eae974115b27c2cadf134a3',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -1373,9 +1373,9 @@
'dev_requirement' => false,
),
'drupal/siteimprove' => array(
'pretty_version' => '1.12.0',
'version' => '1.12.0.0',
'reference' => '8.x-1.12',
'pretty_version' => '2.0.0',
'version' => '2.0.0.0',
'reference' => '2.0.0',
'type' => 'drupal-module',
'install_path' => __DIR__ . '/../../web/modules/contrib/siteimprove',
'aliases' => array(),
Expand Down
9 changes: 7 additions & 2 deletions web/modules/contrib/siteimprove/css/siteimprove.settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
* @file
* Styles for Siteimprove settings page.
*/
.prepublish-is-ready {
fieldset#edit-api .prepublish-is-ready {
background-color: #afa;
padding: 5px 10px;
}
.prepublish-is-not-ready {
fieldset#edit-api .prepublish-is-not-ready {
background-color: #faa;
padding: 5px 10px;
}
fieldset#edit-api .prepublish-is-error {
background-color: #f9c9bf;
padding: 5px 10px;
}

17 changes: 9 additions & 8 deletions web/modules/contrib/siteimprove/js/siteimprove.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Contains the Siteimprove Plugin methods.
*/

(function ($, Drupal, drupalSettings) {
(function (Drupal, $, once, drupalSettings, cookies) {
'use strict';

// Add forEach function to NodeList if it doesn't exist.
Expand Down Expand Up @@ -116,8 +116,7 @@

Drupal.behaviors.siteimprove = {
attach: function (context, settings) {

$('body', context).once('siteimprove').each(function () {
$(once('siteimprove', 'body', context)).each(function () {

// If exist recheck, call recheck Siteimprove method.
if (typeof settings.siteimprove.recheck !== 'undefined') {
Expand Down Expand Up @@ -171,22 +170,24 @@
siteimprove.recrawl();
}
}

});

// We check if the cookie is already set to collapse or open.
// If it's not set, we check if the setting is set to collapsed or open
// and set the cookie accordingly.
var OVERLAY_COLLAPSED = '6';
var OVERLAY_OPEN = '48';
if (!$.cookie('sicmsplugin')) {
var sicmsplugin = cookies.get('sicmsplugin');

if (!sicmsplugin) {
let siOverlaySettings = drupalSettings?.siteimprove?.overlay_default_collapse ?? null;
if (siOverlaySettings) {
$.cookie('sicmsplugin', OVERLAY_COLLAPSED, {
cookies.set('sicmsplugin', OVERLAY_COLLAPSED, {
domain: document.domain,
path: '/'
});
} else {
$.cookie('sicmsplugin', OVERLAY_OPEN, {
cookies.set('sicmsplugin', OVERLAY_OPEN, {
domain: document.domain,
path: '/'
});
Expand All @@ -195,4 +196,4 @@
}
};

})(jQuery, Drupal, drupalSettings);
})(Drupal, jQuery, once, drupalSettings, window.Cookies);
9 changes: 4 additions & 5 deletions web/modules/contrib/siteimprove/siteimprove.info.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Siteimprove Plugin
type: module
description: 'Siteimprove allows users to continuously test, fix and optimize their work through actionable content and analytics insights.'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9.2 || ^10
package: Siteimprove
configure: siteimprove.settings_form

# Information added by Drupal.org packaging script on 2022-02-28
version: '8.x-1.12'
# Information added by Drupal.org packaging script on 2022-12-14
version: '2.0.0'
project: 'siteimprove'
datestamp: 1646062573
datestamp: 1671009595
5 changes: 3 additions & 2 deletions web/modules/contrib/siteimprove/siteimprove.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ siteimprove:
js:
js/siteimprove.js: {}
dependencies:
- core/drupal
- core/jquery
- core/jquery.once
- core/jquery.cookie
- core/once
- core/js-cookie
siteimprove.overlay:
license:
name: GPL-2.0+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: Siteimprove Domain Access
type: module
description: 'Add Domain Access support in the Siteimprove Plugin. Currently support using domains from Domain Access as Siteimprove frontend domains.'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9.2 || ^10
package: Siteimprove
configure: siteimprove.settings_form
dependencies:
- siteimprove:siteimprove
- domain:domain_access

# Information added by Drupal.org packaging script on 2022-02-28
version: '8.x-1.12'
# Information added by Drupal.org packaging script on 2022-12-14
version: '2.0.0'
project: 'siteimprove'
datestamp: 1646062573
datestamp: 1671009595
24 changes: 19 additions & 5 deletions web/modules/contrib/siteimprove/src/Form/SettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use GuzzleHttp\Client;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Messenger\Messenger;
use Drupal\Core\Cache\Cache;
use Drupal\Component\Serialization\Json;
use Drupal\siteimprove\Plugin\SiteimproveDomainManager;
use Drupal\siteimprove\SiteimproveUtils;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Cache\Cache;
use GuzzleHttp\Client;

/**
* Siteimprove settings.
Expand Down Expand Up @@ -227,6 +228,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'http_errors' => FALSE,
]);

$form['#attached']['library'][] = 'siteimprove/siteimprove.settings';
$form['prepublish']['api'] = [
'#type' => 'fieldset',
'#title' => $this->t('Siteimprove API response'),
Expand All @@ -240,7 +242,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
];
// Only treat http status code 200 as successful.
if ($res->getStatusCode() == 200) {
$form['#attached']['library'][] = 'siteimprove/siteimprove.settings';
$result = Json::decode($res->getBody());
if (isset($result['is_ready']) && $result['is_ready']) {
$form['prepublish']['api']['is_ready'] = [
Expand All @@ -257,13 +258,24 @@ public function buildForm(array $form, FormStateInterface $form_state) {
// Enable republish feature in Siteimprove.
$this->setRepublish($config->get('api_username'), $config->get('api_key'));
}
$this->messenger->deleteByType('error');
}
else {
$error_message = new TranslatableMarkup('<p><span class="prepublish-is-error"><strong>@line1</strong></span></p><p>@line2</p><ul><li>@line3</li><li>@line4</li></ul></p>', [
'@line1' => 'Sorry, it looks like there is a problem',
'@line2' => 'It was caused by one of two issues:',
'@line3' => 'You do not have Prepublish as part of your subscription',
'@line4' => 'You do have Prepublish but you need to validate your API key and username in Settings',
]);

// Treat all other http status codes as errors.
// Output general error message.
$form['prepublish']['api']['error'] = [
'#type' => 'markup',
'#markup' => '<p><span>' . $this->t('There were problems contacting the API - see error below. Check your username and API key.') . '</span></p>' . '<p>HTTP status: <strong>' . $res->getStatusCode() . ' ' . $res->getReasonPhrase() . '</strong></p>',
'#markup' => $error_message,
];

$this->messenger->addError($error_message);
}
}

Expand Down Expand Up @@ -362,6 +374,8 @@ protected function setRepublish($username, $key) {
* Token field with value filled.
*/
public function requestToken(array &$form, FormStateInterface &$form_state) {
// Clear existing errors to avoid showing duplicate errors.
$this->messenger->deleteByType('error');

// Request new token.
if ($token = $this->siteimprove->requestToken()) {
Expand Down

0 comments on commit be77dcb

Please sign in to comment.