From b4da8c82eac15aa25848a87d6076eea8b02579b5 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 28 Oct 2022 17:35:18 +0200 Subject: [PATCH 1/2] Breaking: Rename credit property to attributionUrl --- docs/creating-content/blog-posts.md | 2 +- .../Features/Blogging/Models/FeaturedImage.php | 13 +++++++------ .../SubSchemas/FeaturedImageSchema.php | 18 +++++++++--------- .../tests/Feature/FeaturedImageModelTest.php | 2 +- .../tests/Unit/SchemaContractsTest.php | 18 +++++++++--------- .../fixtures/_posts/typography-front-matter.md | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/docs/creating-content/blog-posts.md b/docs/creating-content/blog-posts.md index aa77c1a74d2..5a7564c41fe 100644 --- a/docs/creating-content/blog-posts.md +++ b/docs/creating-content/blog-posts.md @@ -195,7 +195,7 @@ image: copyright: "Copyright (c) 2022" license: "CC-BY-SA-4.0" licenseUrl: https://example.com/license/ - credit: https://photographer.example.com/ + attributionUrl: https://photographer.example.com/ author: "John Doe" ``` diff --git a/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php b/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php index 0438c2c6671..55378300ae6 100644 --- a/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php +++ b/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php @@ -26,7 +26,7 @@ * 'license' => '?string', * 'licenseUrl' => '?string', * 'author' => '?string', - * 'credit' => '?string' + * 'attributionUrl' => '?string' * ]; * * @see \Hyde\Framework\Testing\Feature\ImageModelTest @@ -96,9 +96,10 @@ class FeaturedImage implements FeaturedImageSchema, Stringable * Link to the image author/source (for attribution/credit). * When added, the rendered $author's name will link to this URL. * + * @note This was previously called "credit" but was renamed to "attributionUrl" for clarity. * @example "https://unsplash.com/photos/example". */ - public ?string $credit = null; + public ?string $attributionUrl = null; public function __construct(array $data = []) { @@ -225,9 +226,9 @@ public function getLicenseString(): string|null return null; } - protected function getCreditedAuthorLink(): string + protected function getAuthorLink(): string { - return ''; + return ''; } protected function getAuthorSpan(): string @@ -237,8 +238,8 @@ protected function getAuthorSpan(): string protected function getAuthorElement(): string { - return isset($this->credit) - ? $this->getCreditedAuthorLink() + return isset($this->attributionUrl) + ? $this->getAuthorLink() : $this->getAuthorSpan(); } diff --git a/packages/framework/src/Markdown/Contracts/FrontMatter/SubSchemas/FeaturedImageSchema.php b/packages/framework/src/Markdown/Contracts/FrontMatter/SubSchemas/FeaturedImageSchema.php index 3b64a3baef1..4731fa3b66e 100644 --- a/packages/framework/src/Markdown/Contracts/FrontMatter/SubSchemas/FeaturedImageSchema.php +++ b/packages/framework/src/Markdown/Contracts/FrontMatter/SubSchemas/FeaturedImageSchema.php @@ -11,14 +11,14 @@ interface FeaturedImageSchema { public const FEATURED_IMAGE_SCHEMA = [ - 'path' => 'string', - 'url' => 'string', - 'description' => 'string', - 'title' => 'string', - 'copyright' => 'string', - 'license' => 'string', - 'licenseUrl' => 'string', - 'author' => 'string', - 'credit' => 'string', + 'path' => 'string', + 'url' => 'string', + 'description' => 'string', + 'title' => 'string', + 'copyright' => 'string', + 'license' => 'string', + 'licenseUrl' => 'string', + 'author' => 'string', + 'attributionUrl' => 'string', ]; } diff --git a/packages/framework/tests/Feature/FeaturedImageModelTest.php b/packages/framework/tests/Feature/FeaturedImageModelTest.php index 4beb278eb6d..99be8510e9f 100644 --- a/packages/framework/tests/Feature/FeaturedImageModelTest.php +++ b/packages/framework/tests/Feature/FeaturedImageModelTest.php @@ -111,7 +111,7 @@ public function test_get_image_author_attribution_string_method() { $image = new FeaturedImage([ 'author' => 'John Doe', - 'credit' => 'https://example.com/', + 'attributionUrl' => 'https://example.com/', ]); $string = $image->getImageAuthorAttributionString(); $this->assertStringContainsString('itemprop="creator"', $string); diff --git a/packages/framework/tests/Unit/SchemaContractsTest.php b/packages/framework/tests/Unit/SchemaContractsTest.php index 0f1d96b02ca..7fc6766e666 100644 --- a/packages/framework/tests/Unit/SchemaContractsTest.php +++ b/packages/framework/tests/Unit/SchemaContractsTest.php @@ -51,15 +51,15 @@ public function testSchemasAreNotAccidentallyChanged() ], BlogPostSchema::AUTHOR_SCHEMA); $this->assertEquals([ - 'path' => 'string', - 'url' => 'string', - 'description' => 'string', - 'title' => 'string', - 'copyright' => 'string', - 'license' => 'string', - 'licenseUrl' => 'string', - 'author' => 'string', - 'credit' => 'string', + 'path' => 'string', + 'url' => 'string', + 'description' => 'string', + 'title' => 'string', + 'copyright' => 'string', + 'license' => 'string', + 'licenseUrl' => 'string', + 'author' => 'string', + 'attributionUrl' => 'string', ], BlogPostSchema::FEATURED_IMAGE_SCHEMA); $this->assertEquals([ diff --git a/tests/fixtures/_posts/typography-front-matter.md b/tests/fixtures/_posts/typography-front-matter.md index f5f03901204..ae83fe8c704 100644 --- a/tests/fixtures/_posts/typography-front-matter.md +++ b/tests/fixtures/_posts/typography-front-matter.md @@ -14,7 +14,7 @@ image: license: "the Unsplash License" licenseUrl: "https://unsplash.com/license" author: "Blake" - credit: "https://unsplash.com/photos/GFrBMipOd_E" + attributionUrl: "https://unsplash.com/photos/GFrBMipOd_E" --- ## Write something awesome. From 425a09d6b15ce19bda212dd77f02c429ac44681d Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 28 Oct 2022 15:35:29 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- .../src/Framework/Features/Blogging/Models/FeaturedImage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php b/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php index 55378300ae6..3607dbaf4b9 100644 --- a/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php +++ b/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php @@ -97,6 +97,7 @@ class FeaturedImage implements FeaturedImageSchema, Stringable * When added, the rendered $author's name will link to this URL. * * @note This was previously called "credit" but was renamed to "attributionUrl" for clarity. + * * @example "https://unsplash.com/photos/example". */ public ?string $attributionUrl = null;