From 092633c1bcda63bf40a2947afd25e0f2c7499705 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sun, 21 Apr 2024 15:57:29 +0200 Subject: [PATCH 1/2] Add documentation of the new RSS feed API Closes #413 --- docs/migration/wsc60/php.md | 4 ++ docs/php/api/rss_feeds.md | 89 +++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 3 files changed, 94 insertions(+) create mode 100644 docs/php/api/rss_feeds.md diff --git a/docs/migration/wsc60/php.md b/docs/migration/wsc60/php.md index 28bde610..b92a11d9 100644 --- a/docs/migration/wsc60/php.md +++ b/docs/migration/wsc60/php.md @@ -28,3 +28,7 @@ class MyForm extends AbstractForm { } } ``` + +## RSS Feeds + +A [new API](../../php/api/rss_feeds.md) for the output of content as an RSS feed has been introduced. diff --git a/docs/php/api/rss_feeds.md b/docs/php/api/rss_feeds.md new file mode 100644 index 00000000..932325b4 --- /dev/null +++ b/docs/php/api/rss_feeds.md @@ -0,0 +1,89 @@ +The RSS feed API makes it possible to output content in the RSS format in accordance with the [RSS 2.0 specifications](https://www.rssboard.org/rss-specification). +The [ArticleRssFeedPage](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/page/ArticleRssFeedPage.class.php) is available as a reference implementation. + +## `RssFeed` + +[RssFeed](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeed.class.php) represents an RSS feed. + +After content has been added to the RSS feed, the feed can be output as XML using the `render` method. + +Example: + +```php +$feed = new RssFeed(); +... +$output = $feed->render(); +``` + +## `RssFeedCategory` + +[RssFeedCategory](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedCategory.class.php) represents a category of a feed item. A feed item can have multiple categories. + +An instance of `RssFeedCategory` is created implicitly when a category is assigned to a feed item. + +Example: + +```php +$item = new RssFeedItem(); +$item->category('title', 'domain'); +``` + +## `RssFeedChannel` + +[RssFeedChannel](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedChannel.class.php) represents a channel within an RSS feed. + +Example: + +```php +$feed = new RssFeed(); +$channel = new RssFeedChannel(); +$channel + ->title('title') + ->description('description') + ->link('https://www.example.net'); +$feed->channel($channel); +``` + +## `RssFeedEnclosure` + +[RssFeedEnclosure](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedEnclosure.class.php) represents an enclosure of a feed item. A feed item can only have one enclosure. + +An instance of `RssFeedEnclosure` is created implicitly when an enclosure is assigned to a feed item. + +Example: + +```php +$item = new RssFeedItem(); +$item->enclosure('url', /*size*/1024, 'mime/type'); +``` + +## `RssFeedItem` + +[RssFeedItem](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedItem.class.php) represents an item in an RSS feed. + +Example: + +```php +$feed = new RssFeed(); +$channel = new RssFeedChannel(); +$feed->channel($channel); + +$item = new RssFeedItem(); +$item + ->title('title') + ->link('url'); +$channel->item($item); +``` + +## `RssFeedSource` + +[RssFeedSource](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedSource.class.php) represents the scource of a feed item. A feed item can only have one scource. + +An instance of `RssFeedSource` is created implicitly when an scource is assigned to a feed item. + +Example: + +```php +$item = new RssFeedItem(); +$item->source('title', 'url'); +``` diff --git a/mkdocs.yml b/mkdocs.yml index 1195ba04..e4f50a58 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -40,6 +40,7 @@ nav: - 'Package Installation Plugins': 'php/api/package_installation_plugins.md' - 'User Activity Points': 'php/api/user_activity_points.md' - 'User Notifications': 'php/api/user_notifications.md' + - 'RSS Feeds': 'php/api/rss_feeds.md' - 'Sitemaps': 'php/api/sitemaps.md' - 'Code Style': 'php/code-style.md' - 'Apps': 'php/apps.md' From cc7a499527efcfa71f278d4b4b4226d34908ebb2 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sun, 21 Apr 2024 16:03:06 +0200 Subject: [PATCH 2/2] Fix typo Co-authored-by: Alexander Ebert --- docs/php/api/rss_feeds.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/php/api/rss_feeds.md b/docs/php/api/rss_feeds.md index 932325b4..49186cd1 100644 --- a/docs/php/api/rss_feeds.md +++ b/docs/php/api/rss_feeds.md @@ -77,9 +77,9 @@ $channel->item($item); ## `RssFeedSource` -[RssFeedSource](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedSource.class.php) represents the scource of a feed item. A feed item can only have one scource. +[RssFeedSource](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedSource.class.php) represents the source of a feed item. A feed item can only have one source. -An instance of `RssFeedSource` is created implicitly when an scource is assigned to a feed item. +An instance of `RssFeedSource` is created implicitly when an source is assigned to a feed item. Example: