Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Sources/FeedKit/FeedNamespace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ enum FeedNamespace: CaseIterable {
/// Represents the Podcast namespace, used for podcast-specific metadata
/// and extensions in podcast feeds.
case podcast
/// Represents the source namespace, used for Source-specific metadata
/// like markdown content.
case source

// MARK: Internal

Expand All @@ -86,6 +89,8 @@ enum FeedNamespace: CaseIterable {
"xmlns:atom"
case .podcast:
"xmlns:podcast"
case .source:
"xmlns:source"
}
}

Expand All @@ -112,6 +117,8 @@ enum FeedNamespace: CaseIterable {
"http://www.w3.org/2005/Atom"
case .podcast:
"https://podcastindex.org/namespace/1.0"
case .source:
"http://source.scripting.com/"
}
}
}
Expand Down Expand Up @@ -156,6 +163,9 @@ extension FeedNamespace {
case .podcast:
feed.channel?.podcast != nil ||
feed.channel?.items?.contains(where: { $0.podcast != nil }) ?? false

case .source:
feed.channel?.items?.contains(where: { $0.markdown != nil }) ?? false
}
}

Expand Down
10 changes: 10 additions & 0 deletions Sources/FeedKit/Feeds/RSS/RSSFeedItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public struct RSSFeedItem {
title: String? = nil,
link: String? = nil,
description: String? = nil,
markdown: String? = nil,
author: String? = nil,
categories: [RSSFeedCategory]? = nil,
comments: String? = nil,
Expand All @@ -55,6 +56,7 @@ public struct RSSFeedItem {
self.title = title
self.link = link
self.description = description
self.markdown = markdown
self.author = author
self.categories = categories
self.comments = comments
Expand Down Expand Up @@ -89,6 +91,11 @@ public struct RSSFeedItem {
/// Cinema was being staged.
public var description: String?

/// The markdown content for the item.
///
/// Example: ## Highlights
public var markdown: String?

/// Email address of the author of the item.
///
/// Example: oprah\@oxygen.net
Expand Down Expand Up @@ -254,6 +261,7 @@ extension RSSFeedItem: Codable {
case title
case link
case description
case markdown = "source:markdown"
case author
case category
case comments
Expand All @@ -275,6 +283,7 @@ extension RSSFeedItem: Codable {
title = try container.decodeIfPresent(String.self, forKey: CodingKeys.title)
link = try container.decodeIfPresent(String.self, forKey: CodingKeys.link)
description = try container.decodeIfPresent(String.self, forKey: CodingKeys.description)
markdown = try container.decodeIfPresent(String.self, forKey: CodingKeys.markdown)
author = try container.decodeIfPresent(String.self, forKey: CodingKeys.author)
categories = try container.decodeIfPresent([RSSFeedCategory].self, forKey: CodingKeys.category)
comments = try container.decodeIfPresent(String.self, forKey: CodingKeys.comments)
Expand All @@ -296,6 +305,7 @@ extension RSSFeedItem: Codable {
try container.encodeIfPresent(title, forKey: CodingKeys.title)
try container.encodeIfPresent(link, forKey: CodingKeys.link)
try container.encodeIfPresent(description, forKey: CodingKeys.description)
try container.encodeIfPresent(markdown, forKey: CodingKeys.markdown)
try container.encodeIfPresent(author, forKey: CodingKeys.author)
try container.encodeIfPresent(categories, forKey: CodingKeys.category)
try container.encodeIfPresent(comments, forKey: CodingKeys.comments)
Expand Down
6 changes: 5 additions & 1 deletion Tests/FeedKitTests/Resources/xml/RSS.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<rss version="2.0" xmlns:source="http://source.scripting.com/">
<channel>
<title>Iris</title>
<link>http://www.iris.news/</link>
Expand Down Expand Up @@ -50,6 +50,10 @@
<category domain="rec.arts.movies.reviews">1983/V</category>
<comments>http://dallas.example.com/feedback/1983/06/joebob.htm</comments>
<description>I'm headed for France. I wasn't gonna go this year, but then last week "Valley Girl" came out and I said to myself, Joe Bob, you gotta get out of the country for a while.</description>
<source:markdown><![CDATA[## Highlights

- Traveled to France.
- Talked about "Valley Girl".]]></source:markdown>
<enclosure length="24986239" type="audio/mpeg" url="http://dallas.example.com/joebob_050689.mp3" />
<guid isPermaLink="false">tag:dallas.example.com,4131:news</guid>
<pubDate>Fri, 05 Oct 2007 09:00:00 CST</pubDate>
Expand Down
1 change: 1 addition & 0 deletions Tests/FeedKitTests/Tests/RSSTests + Mocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ extension RSSTests {
title: "Seventh Heaven! Ryan Hurls Another No Hitter",
link: "http://dallas.example.com/1991/05/02/nolan.htm",
description: "I'm headed for France. I wasn't gonna go this year, but then last week \"Valley Girl\" came out and I said to myself, Joe Bob, you gotta get out of the country for a while.",
markdown: "## Highlights\n\n- Traveled to France.\n- Talked about \"Valley Girl\".",
author: "jbb@dallas.example.com (Joe Bob Briggs)",
categories: [
.init(
Expand Down
Loading