Skip to content

Commit 8c59238

Browse files
authored
Merge pull request #1258 from hydephp/finalize-rss-configuration
Create new array-based RSS feed config structure
2 parents 18f7c25 + d1c9a22 commit 8c59238

File tree

11 files changed

+46
-38
lines changed

11 files changed

+46
-38
lines changed

RELEASE_NOTES.md

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ This serves two purposes:
1414

1515
### Changed
1616
- Added default RSS feed description value to the config stub in [#1253](https://github.com/hydephp/develop/pull/1253)
17+
- Changed the RSS feed configuration structure to be an array of feed configurations in [#1258](https://github.com/hydephp/develop/pull/1258)
18+
- Replaced option `hyde.generate_rss_feed` with `hyde.rss.enabled`
19+
- Replaced option `hyde.rss_filename` with `hyde.rss.filename`
20+
- Replaced option `hyde.rss_description` with `hyde.rss.description`
1721

1822
### Deprecated
1923
- for soon-to-be removed features.

config/hyde.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,16 @@
108108
|
109109
*/
110110

111-
// Should the RSS feed be generated?
112-
'generate_rss_feed' => true,
111+
'rss' => [
112+
// Should the RSS feed be generated?
113+
'enabled' => true,
113114

114-
// What filename should the RSS file use?
115-
'rss_filename' => 'feed.xml',
115+
// What filename should the RSS file use?
116+
'filename' => 'feed.xml',
116117

117-
// The channel description.
118-
'rss_description' => env('SITE_NAME', 'HydePHP').' RSS Feed',
118+
// The channel description.
119+
'description' => env('SITE_NAME', 'HydePHP').' RSS Feed',
120+
],
119121

120122
/*
121123
|--------------------------------------------------------------------------

docs/digging-deeper/customization.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,22 @@ When enabled, an RSS feed with your Markdown blog posts will be generated when y
6565
Note that this requires that a site_url is set!
6666

6767
```php // config/hyde.php
68-
'generate_rss_feed' => true, // Default is true
68+
'rss.enabled' => true, // Default is true
6969
```
7070

7171
You can customize the output filename using the following:
7272

7373
```php // config/hyde.php
74-
'rss_filename' => 'feed.rss', // Default is feed.xml
74+
'rss.filename' => 'feed.rss', // Default is feed.xml
7575
```
7676

7777
You can set the RSS channel description using the following:
7878

7979
```php // config/hyde.php
80-
'rss_description' => 'A collection of articles and tutorials from my blog', // Example
80+
'rss.description' => 'A collection of articles and tutorials from my blog', // Example
8181
```
8282

83-
If an rss_description is not set one is created by appending "RSS Feed" to your site name.
83+
If an rss.description is not set one is created by appending "RSS Feed" to your site name.
8484

8585

8686
### Authors
@@ -327,9 +327,9 @@ name: HydePHP
327327
url: http://localhost
328328
pretty_urls: false
329329
generate_sitemap: true
330-
generate_rss_feed: true
331-
rss_filename: feed.xml
332-
# rss_description:
330+
rss.enabled: true
331+
rss.filename: feed.xml
332+
# rss.description:
333333
language: en
334334
output_directory: _site
335335
```

packages/framework/config/hyde.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,16 @@
108108
|
109109
*/
110110

111-
// Should the RSS feed be generated?
112-
'generate_rss_feed' => true,
111+
'rss' => [
112+
// Should the RSS feed be generated?
113+
'enabled' => true,
113114

114-
// What filename should the RSS file use?
115-
'rss_filename' => 'feed.xml',
115+
// What filename should the RSS file use?
116+
'filename' => 'feed.xml',
116117

117-
// The channel description.
118-
'rss_description' => env('SITE_NAME', 'HydePHP').' RSS Feed',
118+
// The channel description.
119+
'description' => env('SITE_NAME', 'HydePHP').' RSS Feed',
120+
],
119121

120122
/*
121123
|--------------------------------------------------------------------------

packages/framework/src/Facades/Features.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public static function rss(): bool
161161
{
162162
return static::resolveMockedInstance('rss') ?? Hyde::hasSiteUrl()
163163
&& static::hasMarkdownPosts()
164-
&& Config::getBool('hyde.generate_rss_feed', true)
164+
&& Config::getBool('hyde.rss.enabled', true)
165165
&& extension_loaded('simplexml')
166166
&& count(MarkdownPost::files()) > 0;
167167
}

packages/framework/src/Framework/Features/XmlGenerators/RssFeedGenerator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ protected function getImageLength(FeaturedImage $image): string
110110

111111
public static function getFilename(): string
112112
{
113-
return Config::getString('hyde.rss_filename', 'feed.xml');
113+
return Config::getString('hyde.rss.filename', 'feed.xml');
114114
}
115115

116116
public static function getDescription(): string
117117
{
118-
return Config::getString('hyde.rss_description', Site::name().' RSS Feed');
118+
return Config::getString('hyde.rss.description', Site::name().' RSS Feed');
119119
}
120120
}

packages/framework/tests/Feature/Commands/BuildRssFeedCommandTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BuildRssFeedCommandTest extends TestCase
1717
public function test_rss_feed_is_generated_when_conditions_are_met()
1818
{
1919
config(['hyde.url' => 'https://example.com']);
20-
config(['hyde.generate_rss_feed' => true]);
20+
config(['hyde.rss.enabled' => true]);
2121
$this->file('_posts/foo.md');
2222

2323
$this->assertFileDoesNotExist(Hyde::path('_site/feed.xml'));
@@ -30,8 +30,8 @@ public function test_rss_feed_is_generated_when_conditions_are_met()
3030
public function test_rss_filename_can_be_changed()
3131
{
3232
config(['hyde.url' => 'https://example.com']);
33-
config(['hyde.generate_rss_feed' => true]);
34-
config(['hyde.rss_filename' => 'blog.xml']);
33+
config(['hyde.rss.enabled' => true]);
34+
config(['hyde.rss.filename' => 'blog.xml']);
3535
$this->file('_posts/foo.md');
3636

3737
$this->assertFileDoesNotExist(Hyde::path('_site/feed.xml'));

packages/framework/tests/Feature/GlobalMetadataBagTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function test_site_metadata_automatically_adds_rss_feed_when_enabled()
6060
$this->emptyConfig();
6161

6262
config(['hyde.url' => 'foo']);
63-
config(['hyde.generate_rss_feed' => true]);
63+
config(['hyde.rss.enabled' => true]);
6464
$this->file('_posts/foo.md');
6565

6666
$this->assertEquals('<link rel="alternate" href="foo/feed.xml" type="application/rss+xml" title="HydePHP RSS Feed">', GlobalMetadataBag::make()->render());
@@ -71,7 +71,7 @@ public function test_site_metadata_rss_feed_uses_configured_site_url()
7171
$this->emptyConfig();
7272

7373
config(['hyde.url' => 'bar']);
74-
config(['hyde.generate_rss_feed' => true]);
74+
config(['hyde.rss.enabled' => true]);
7575
$this->file('_posts/foo.md');
7676

7777
$this->assertEquals('<link rel="alternate" href="bar/feed.xml" type="application/rss+xml" title="HydePHP RSS Feed">', GlobalMetadataBag::make()->render());
@@ -83,9 +83,9 @@ public function test_site_metadata_rss_feed_uses_configured_site_name()
8383

8484
config(['hyde.url' => 'foo']);
8585
config(['hyde.name' => 'Site']);
86-
config(['hyde.generate_rss_feed' => true]);
86+
config(['hyde.rss.enabled' => true]);
8787
$config = config('hyde');
88-
unset($config['rss_description']);
88+
unset($config['rss']['description']);
8989
config(['hyde' => $config]);
9090
$this->file('_posts/foo.md');
9191

@@ -97,8 +97,8 @@ public function test_site_metadata_rss_feed_uses_configured_rss_file_name()
9797
$this->emptyConfig();
9898

9999
config(['hyde.url' => 'foo']);
100-
config(['hyde.rss_filename' => 'posts.rss']);
101-
config(['hyde.generate_rss_feed' => true]);
100+
config(['hyde.rss.filename' => 'posts.rss']);
101+
config(['hyde.rss.enabled' => true]);
102102
$this->file('_posts/foo.md');
103103

104104
$this->assertStringContainsString(
@@ -147,7 +147,7 @@ protected function emptyConfig(): void
147147
{
148148
config(['hyde.url' => null]);
149149
config(['hyde.meta' => []]);
150-
config(['hyde.generate_rss_feed' => false]);
150+
config(['hyde.rss.enabled' => false]);
151151
config(['hyde.generate_sitemap' => false]);
152152
}
153153
}

packages/framework/tests/Feature/MetadataTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function setUp(): void
3131

3232
config(['hyde.url' => null]);
3333
config(['hyde.meta' => []]);
34-
config(['hyde.generate_rss_feed' => false]);
34+
config(['hyde.rss.enabled' => false]);
3535
config(['hyde.generate_sitemap' => false]);
3636
}
3737

packages/framework/tests/Feature/Services/RssFeedServiceTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function test_xml_channel_element_has_required_elements()
3939
{
4040
config(['hyde.name' => 'Test Blog']);
4141
config(['hyde.url' => 'https://example.com']);
42-
config(['hyde.rss_description' => 'Test Blog RSS Feed']);
42+
config(['hyde.rss.description' => 'Test Blog RSS Feed']);
4343

4444
$service = new RssFeedGenerator();
4545
$this->assertTrue(property_exists($service->getXmlElement()->channel, 'title'));
@@ -70,7 +70,7 @@ public function test_xml_channel_data_can_be_customized()
7070
{
7171
config(['hyde.name' => 'Foo']);
7272
config(['hyde.url' => 'https://blog.foo.com/bar']);
73-
config(['hyde.rss_description' => 'Foo is a web log about stuff']);
73+
config(['hyde.rss.description' => 'Foo is a web log about stuff']);
7474

7575
$service = new RssFeedGenerator();
7676
$this->assertEquals('Foo', $service->getXmlElement()->channel->title);
@@ -149,7 +149,7 @@ public function test_can_generate_feed_helper_returns_false_if_hyde_does_not_hav
149149
public function test_can_generate_feed_helper_returns_false_if_feeds_are_disabled_in_config()
150150
{
151151
config(['hyde.url' => 'foo']);
152-
config(['hyde.generate_rss_feed' => false]);
152+
config(['hyde.rss.enabled' => false]);
153153
$this->assertFalse(Features::rss());
154154
}
155155
}

packages/framework/tests/Feature/StaticSiteServiceTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function test_sitemap_is_generated_when_conditions_are_met()
166166
public function test_rss_feed_is_not_generated_when_conditions_are_not_met()
167167
{
168168
config(['hyde.url' => '']);
169-
config(['hyde.generate_rss_feed' => false]);
169+
config(['hyde.rss.enabled' => false]);
170170

171171
$this->artisan('build')
172172
->doesntExpectOutput('Generating RSS feed...')
@@ -176,7 +176,7 @@ public function test_rss_feed_is_not_generated_when_conditions_are_not_met()
176176
public function test_rss_feed_is_generated_when_conditions_are_met()
177177
{
178178
config(['hyde.url' => 'https://example.com']);
179-
config(['hyde.generate_rss_feed' => true]);
179+
config(['hyde.rss.enabled' => true]);
180180

181181
Filesystem::touch('_posts/foo.md');
182182

0 commit comments

Comments
 (0)