-
-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Wikifeeds featured content models.
- Loading branch information
Showing
12 changed files
with
284 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Foundation | ||
|
||
public struct WidgetContentURL: Codable { | ||
|
||
// MARK: - Nested Types | ||
|
||
public struct PageURL: Codable { | ||
public let page: String | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
public let desktop: PageURL | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Foundation | ||
|
||
public struct WidgetFeaturedArticle: Codable { | ||
|
||
// MARK: - Nested Types | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case displayTitle = "displaytitle" | ||
case description | ||
case extract | ||
case languageCode = "lang" | ||
case languageDirection = "dir" | ||
case contentURL = "content_urls" | ||
case thumbnailImageSource = "thumbnail" | ||
case originalImageSource = "originalimage" | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
public var displayTitle: String | ||
public let description: String? | ||
public let extract: String | ||
public let languageCode: String | ||
public let languageDirection: String | ||
public let contentURL: WidgetContentURL | ||
public var thumbnailImageSource: WidgetImageSource? | ||
public var originalImageSource: WidgetImageSource? | ||
|
||
// MARK: - Computed Properties | ||
|
||
public var isRTL: Bool { | ||
return languageDirection.caseInsensitiveCompare("rtl") == .orderedSame | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Foundation | ||
|
||
public struct WidgetImageSource: Codable { | ||
|
||
// MARK: - Nested Types | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case source | ||
case width | ||
case height | ||
case data | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
public let source: String | ||
public let width: Int | ||
public let height: Int | ||
|
||
// Data is populated via local network request, not via API featured content API request | ||
public var data: Data? | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Foundation | ||
|
||
public struct WidgetOnThisDayElement: Codable { | ||
|
||
// MARK: - Nested Types | ||
|
||
public struct Page: Codable { | ||
|
||
// MARK: - Nested Types | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case title | ||
case displayTitle = "displaytitle" | ||
case normalizedTitle = "normalizedtitle" | ||
case description | ||
case language = "lang" | ||
case languageDirection = "dir" | ||
case extract | ||
case extractHTML = "extract_html" | ||
case contentURL = "content_urls" | ||
case thumbnailImageSource = "thumbnail" | ||
case originalImageSource = "originalimage" | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
let title: String | ||
let displayTitle: String | ||
let normalizedTitle: String | ||
let description: String? | ||
let language: String | ||
let languageDirection: String | ||
let extract: String | ||
let extractHTML: String | ||
let contentURL: WidgetContentURL | ||
let thumbnailImageSource: WidgetImageSource? | ||
let originalImageSource: WidgetImageSource? | ||
|
||
// MARK: - Computed Properties | ||
|
||
public var isRTL: Bool { | ||
return languageDirection.caseInsensitiveCompare("rtl") == .orderedSame | ||
} | ||
|
||
} | ||
|
||
// MARK: - Properties | ||
|
||
let text: String | ||
let year: Int | ||
let pages: [Page] | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Foundation | ||
|
||
public struct WidgetPictureOfTheDay: Codable { | ||
|
||
// MARK: - Nested Types | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case description | ||
case license | ||
case thumbnailImageSource = "thumbnail" | ||
case originalImageSource = "image" | ||
} | ||
|
||
public struct License: Codable { | ||
let type: String | ||
let url: String | ||
} | ||
|
||
public struct Description: Codable { | ||
enum CodingKeys: String, CodingKey { | ||
case text | ||
case html | ||
case language = "lang" | ||
} | ||
|
||
let text: String | ||
let html: String | ||
let language: String | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
let description: Description | ||
let license: License | ||
let thumbnailImageSource: WidgetImageSource? // thumbnail | ||
let originalImageSource: WidgetImageSource? // image | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Foundation | ||
|
||
public struct WidgetTitles: Codable { | ||
|
||
let canonical: String | ||
let normalized: String | ||
let display: String | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Foundation | ||
|
||
public struct WidgetTopRead: Codable { | ||
|
||
// MARK: - Nested Types | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case elements = "articles" | ||
} | ||
|
||
public struct Article: Codable { | ||
|
||
// MARK: - Nested Types | ||
|
||
public struct ViewHistoryDataPoint: Codable { | ||
let views: Int | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case views | ||
case titles | ||
case pageTitle = "title" | ||
case displayTitle = "displaytitle" | ||
case normalizedTitle = "normalizedtitle" | ||
case timestamp | ||
case viewHistory = "view_history" | ||
case thumbnailImageSource = "thumbnail" | ||
case originalImageSource = "originalimage" | ||
case language = "lang" | ||
case languageDirection = "dir" | ||
case contentURL = "content_urls" | ||
case extract | ||
case extractHTML = "extract_html" | ||
} | ||
|
||
// MARK: - Properties | ||
|
||
let views: Int | ||
let titles: WidgetTitles | ||
let pageTitle: String | ||
let displayTitle: String | ||
let normalizedTitle: String | ||
let timestamp: String | ||
let viewHistory: [ViewHistoryDataPoint] // ordered from oldest to newest | ||
let thumbnailImageSource: WidgetImageSource? | ||
let originalImageSource: WidgetImageSource? | ||
let language: String | ||
let languageDirection: String | ||
let contentURL: WidgetContentURL | ||
let extract: String | ||
let extractHTML: String | ||
|
||
// MARK: - Computed Properties | ||
|
||
public var isRTL: Bool { | ||
return languageDirection.caseInsensitiveCompare("rtl") == .orderedSame | ||
} | ||
|
||
} | ||
|
||
// MARK: - Properties | ||
|
||
public let elements: [Article] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.