Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: silktide/cms-plugin-craft3
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.3
Choose a base ref
...
head repository: silktide/cms-plugin-craft3
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 5 commits
  • 6 files changed
  • 1 contributor

Commits on Feb 8, 2019

  1. Better error handling

    rbairwell committed Feb 8, 2019
    Copy the full SHA
    3e9ccae View commit details
  2. Better error handling

    rbairwell committed Feb 8, 2019
    Copy the full SHA
    c82eb91 View commit details
  3. Copy the full SHA
    db21207 View commit details
  4. Copy the full SHA
    b776fc5 View commit details

Commits on Feb 13, 2019

  1. Updated documentation link

    rbairwell committed Feb 13, 2019
    Copy the full SHA
    5df2cca View commit details
Showing with 58 additions and 26 deletions.
  1. +23 −11 CHANGELOG.md
  2. +2 −1 README.md
  3. +11 −5 composer.json
  4. +19 −6 src/CraftSilktideJob.php
  5. +2 −2 src/templates/_settings.twig
  6. +1 −1 src/translations/en/craft-silktide.php
34 changes: 23 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,18 +4,30 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.3 - 2019.02-08
## Fixed
More logging data.
## [1.0.6] - 2019-02-13
### Changed
- Changed documentation link.

## 1.0.2 - 2019.02-08
## Fixed
Version number in composer.json
## [1.0.5] - 2019-02-08
### Fixed
- Removed version number in composer.json.

## 1.0.1 - 2019-02-08
## Fixed
- Additional logs
## [1.0.4] - 2019-02-08
### Fixed
- Even more logging data and error handling.

## 1.0.0 - 2019-01-24
## [1.0.3] - 2019-02-08
### Changed
- More logging data.

## [1.0.2] - 2019-02-08
### Changed
- Version number in composer.json.

## [1.0.1] - 2019-02-08
### Fixed
- Additional logs.

## [1.0.0] - 2019-01-24
### Added
- Initial release
- Initial release.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ To install the plugin, follow these instructions.

4. Enter the API key as provided by Silktide.

Further documentation is available on the [Silktide Craft3 Plugin installation guide](ttps://support.silktide.com/guides/cms-install-craft3-guide/).
## Silktide Craft Overview

Enables Silktide to be notified of new and updated pages on your Craft CMS 3 powered website and for you to easily edit pages within Craft from Silktide.
@@ -38,4 +39,4 @@ Enables Silktide to be notified of new and updated pages on your Craft CMS 3 pow

3. Provide your Silktide API key. This can be found in the 'Settings -> CMS' section of your Silktide account.

Brought to you by [Silktide](https://www.silktide.com)
Brought to you by [Silktide](https://www.silktide.com).
16 changes: 11 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "silktide/craft-silktide",
"description": "Integrate Silktide with Craft",
"version" : "1.0.3",
"type": "craft-plugin",
"keywords": [
"craft",
@@ -12,14 +11,19 @@
"silktide"
],
"support": {
"docs": "https://github.com/silktide/cms-plugin-craft3/blob/master/README.md",
"issues": "https://github.com/silktide/cms-plugin-craft3/issues"
"docs": "https://support.silktide.com/guides/cms-install-craft3-guide/",
"issues": "https://github.com/silktide/cms-plugin-craft3/issues",
"source": "https://github.com/silktide/cms-plugin-craft3/"
},
"license": "MIT",
"authors": [
{
"name": "silktide",
"name": "Silktide Ltd",
"homepage": "https://www.silktide.com"
},
{
"name": "Richard Bairwell",
"homepage": "https://github.com/rbairwell"
}
],
"require": {
@@ -40,6 +44,8 @@
"hasSettings" : false,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/silktide/cms-plugin-craft3/master/CHANGELOG.md",
"class": "silktide\\craftsilktide\\CraftSilktide"
"class": "silktide\\craftsilktide\\CraftSilktide",
"developer": "Silktide Ltd",
"documentationUrl": "https://support.silktide.com/guides/cms-install-craft3-guide/"
}
}
25 changes: 19 additions & 6 deletions src/CraftSilktideJob.php
Original file line number Diff line number Diff line change
@@ -67,15 +67,14 @@ public function execute($queue)
);
$requestBody = http_build_query([
'apiKey' => $this->apiKey,
'urls' => [
$this->urls,
],
'urls' => $this->urls,
]);
$options = [RequestOptions::BODY => $requestBody];
$client = Craft::createGuzzleClient(
[
'headers' => [
'User-Agent' => $this->userAgent,
'Content-Type' => 'application/x-www-form-urlencoded',
],
]
);
@@ -112,9 +111,18 @@ protected function handleValidResponse(
) {
$responseCode = (int)$response->getStatusCode();
$body = $response->getBody()->getContents();
if ($responseCode >= 200 && $responseCode <= 299) {
$failReason = 'Unknown';
if ($responseCode < 200 && $responseCode > 299) {
$failReason = 'Status code';
} else {
$decoded = json_decode($body, true);
if (is_array($decoded) && isset($decoded['status']) && $decoded['status'] === 'ok') {
if (!is_array($decoded)) {
$failReason = 'Unable to decode';
} elseif (!isset($decoded['status'])) {
$failReason = 'No status field';
} elseif ($decoded['status'] !== 'ok') {
$failReason = 'Status not ok';
} else {
$message = Craft::t(
'craft-silktide',
'Notified Silktide and received a {status} code back with {body} from {request}',
@@ -125,12 +133,17 @@ protected function handleValidResponse(
]
);
Craft::info($message, __METHOD__);
$file = Craft::getAlias('@storage/logs/silktide.log');
$log = date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL;
FileHelper::writeToFile($file, $log, ['append' => true]);
return;
}
}
$message = Craft::t(
'craft-silktide',
'Failed to notify Silktide - HTTP request failed with status {status} and body {body} from {request}',
'Failed to notify Silktide - HTTP request failed: ({reason}) with status {status} and body "{body}" from {request}',
[
'reason' => $failReason,
'status' => $responseCode,
'body' => $body,
'request' => $requestBody,
4 changes: 2 additions & 2 deletions src/templates/_settings.twig
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
{% import "_includes/forms" as forms %}

{# Link for the ? icon at the bottom of the page #}
{% set docsUrl = "https://github.com/silktide/craft-silktide/blob/master/README.md" %}
{% set docsUrl = "https://support.silktide.com/guides/cms-install-craft3-guide/" %}

{# The title of this CP section #}
{% set title = "Silktide" %}
@@ -29,7 +29,7 @@
class: 'required',
id: 'apiKey',
name: 'apiKey',
instructions: 'For guidance, please see the <a href="https://support.silktide.com/glossary/cms-install-craft3-guide/">Silktide Craft CMS installation guide</a>.' | t('craft-silktide'),
instructions: 'For guidance, please see the <a href="https://support.silktide.com/guides/cms-install-craft3-guide/">Silktide Craft CMS installation guide</a>.' | t('craft-silktide'),
errors: settings.getErrors('apiKey'),
size: 32,
maxlength: 32,
2 changes: 1 addition & 1 deletion src/translations/en/craft-silktide.php
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
'Silktide Craft plugin loaded' => 'Silktide Craft plugin loaded',
'Please enter the API key provided by <a href="https://www.silktide.com">Silktide</a>.' => 'Please enter the API key provided by <a href="https://www.silktide.com">Silktide</a>.',
'Sorry, that API key was invalid. It must be a 32 character long code from Silktide.' => 'Sorry, that API key was invalid. It must be a 32 character long code from Silktide.',
'For guidance, please see the <a href="https://support.silktide.com/glossary/cms-install-craft3-guide/">Silktide Craft CMS installation guide</a>.' => 'For guidance, please see the <a href="https://support.silktide.com/glossary/cms-install-craft3-guide/">Silktide Craft CMS installation guide</a>.',
'For guidance, please see the <a href="https://support.silktide.com/guides/cms-install-craft3-guide/">Silktide Craft CMS installation guide</a>.' => 'For guidance, please see the <a href="https://support.silktide.com/guides/cms-install-craft3-guide/">Silktide Craft CMS installation guide</a>.',
'The API key provided by Silktide.' => 'The API key provided by Silktide.',
'Notifying Silktide' => 'Notifying Silktide',
'Notifying Silktide about a change to URLs {urls}' => 'Notifying Silktide about a change to URLs {urls}',