Skip to content

Commit 4329388

Browse files
authored
Deprecate the Presentation Hints from the RWPM models (#631)
1 parent e12fd18 commit 4329388

34 files changed

+175
-621
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ All notable changes to this project will be documented in this file. Take a look
1010

1111
* You can now access the `viewport` property of an `EPUBNavigatorViewController` to obtain information about the visible portion of the publication, including the visible positions and reading order indices.
1212

13+
### Deprecated
14+
15+
#### Shared
16+
17+
* The Presentation Hints properties are deprecated from the Readium Web Publication Manifest models. [See the official documentation](https://readium.org/webpub-manifest/profiles/epub.html#appendix-b---deprecated-properties).
18+
1319
### Fixed
1420

1521
#### Navigator

Sources/Navigator/EPUB/EPUBNavigatorViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ extension EPUBNavigatorViewController: EditingActionsControllerDelegate {
12021202
extension EPUBNavigatorViewController: PaginationViewDelegate {
12031203
func paginationView(_ paginationView: PaginationView, pageViewAtIndex index: Int) -> (UIView & PageView)? {
12041204
let spread = spreads[index]
1205-
let spreadViewType = (spread.layout == .fixed) ? EPUBFixedSpreadView.self : EPUBReflowableSpreadView.self
1205+
let spreadViewType = (publication.metadata.layout == .fixed) ? EPUBFixedSpreadView.self : EPUBReflowableSpreadView.self
12061206
let spreadView = spreadViewType.init(
12071207
viewModel: viewModel,
12081208
spread: spread,

Sources/Navigator/EPUB/EPUBNavigatorViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ final class EPUBNavigatorViewModel: Loggable {
288288
guard
289289
let link = publication.linkWithHREF(href),
290290
link.mediaType?.isHTML == true,
291-
publication.metadata.presentation.layout(of: link) == .reflowable
291+
publication.metadata.layout == .reflowable
292292
else {
293293
return resource
294294
}

Sources/Navigator/EPUB/EPUBSpread.swift

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ struct EPUBSpread: Loggable {
2323
/// Spread reading progression direction.
2424
var readingProgression: ReadingProgression
2525

26-
/// Rendition layout of the links in the spread.
27-
var layout: EPUBLayout
28-
29-
init(spread: Bool, readingOrderIndices: ReadingOrderIndices, readingProgression: ReadingProgression, layout: EPUBLayout) {
26+
init(spread: Bool, readingOrderIndices: ReadingOrderIndices, readingProgression: ReadingProgression) {
3027
precondition(!readingOrderIndices.isEmpty, "A spread must have at least one page")
3128
precondition(spread || readingOrderIndices.count == 1, "A one-page spread must have only one page")
3229
precondition(!spread || 1 ... 2 ~= readingOrderIndices.count, "A two-pages spread must have one or two pages max")
3330
self.spread = spread
3431
self.readingOrderIndices = readingOrderIndices
3532
self.readingProgression = readingProgression
36-
self.layout = layout
3733
}
3834

3935
/// Returns the left-most reading order index in the spread.
@@ -83,7 +79,7 @@ struct EPUBSpread: Loggable {
8379
/// - url: Full URL to the resource.
8480
/// - page [left|center|right]: (optional) Page position of the linked resource in the spread.
8581
func json(forBaseURL baseURL: HTTPURL, readingOrder: ReadingOrder) -> [[String: Any]] {
86-
func makeLinkJSON(_ index: ReadingOrder.Index, page: Presentation.Page? = nil) -> [String: Any]? {
82+
func makeLinkJSON(_ index: ReadingOrder.Index, page: Properties.Page? = nil) -> [String: Any]? {
8783
guard let link = readingOrder.getOrNil(index) else {
8884
return nil
8985
}
@@ -136,12 +132,11 @@ struct EPUBSpread: Loggable {
136132
readingOrder: [Link],
137133
readingProgression: ReadingProgression
138134
) -> [EPUBSpread] {
139-
readingOrder.enumerated().map { index, link in
135+
readingOrder.enumerated().map { index, _ in
140136
EPUBSpread(
141137
spread: false,
142138
readingOrderIndices: index ... index,
143-
readingProgression: readingProgression,
144-
layout: publication.metadata.presentation.layout(of: link)
139+
readingProgression: readingProgression
145140
)
146141
}
147142
}
@@ -157,22 +152,20 @@ struct EPUBSpread: Loggable {
157152
var index = 0
158153
while index < readingOrder.count {
159154
let first = readingOrder[index]
160-
let layout = publication.metadata.presentation.layout(of: first)
161155

162156
var spread = EPUBSpread(
163157
spread: true,
164158
readingOrderIndices: index ... index,
165-
readingProgression: readingProgression,
166-
layout: layout
159+
readingProgression: readingProgression
167160
)
168161

169162
let nextIndex = index + 1
170-
// To be displayed together, the two pages must have a fixed layout,
171-
// and have consecutive position hints (Properties.Page).
163+
// To be displayed together, two pages must be part of a fixed
164+
// layout publication and have consecutive position hints
165+
// (Properties.Page).
172166
if
173167
let second = readingOrder.getOrNil(nextIndex),
174-
layout == .fixed,
175-
layout == publication.metadata.presentation.layout(of: second),
168+
publication.metadata.layout == .fixed,
176169
publication.areConsecutive(first, second, index: index)
177170
{
178171
spread.readingOrderIndices = index ... nextIndex

Sources/Navigator/EPUB/Preferences/EPUBPreferencesEditor.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ public final class EPUBPreferencesEditor: StatefulPreferencesEditor<EPUBPreferen
2121
metadata: Metadata,
2222
defaults: EPUBDefaults
2323
) {
24-
layout = metadata.presentation.layout ?? .reflowable
24+
switch metadata.layout {
25+
case .fixed:
26+
layout = .fixed
27+
default:
28+
layout = .reflowable
29+
}
2530
self.defaults = defaults
2631

2732
super.init(

Sources/Navigator/EPUB/Preferences/EPUBSettings.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ public struct EPUBSettings: ConfigurableSettings {
169169
readingProgression: readingProgression,
170170
scroll: scroll,
171171
spread: preferences.spread
172-
?? Spread(metadata.presentation.spread)
173172
?? defaults.spread
174173
?? .auto,
175174
textAlign: preferences.textAlign

Sources/Navigator/Preferences/Types.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,6 @@ public enum Spread: String, Codable, Hashable {
2323
case never
2424
/// The publication should always be displayed in a spread.
2525
case always
26-
27-
init?(_ spread: ReadiumShared.Presentation.Spread?) {
28-
guard let spread = spread else {
29-
return nil
30-
}
31-
switch spread {
32-
case .both:
33-
self = .always
34-
case .none:
35-
self = .never
36-
case .auto, .landscape:
37-
self = .auto
38-
}
39-
}
4026
}
4127

4228
/// Direction of the reading progression across resources.
@@ -53,7 +39,7 @@ public enum ReadingProgression: String, Codable, Hashable {
5339
}
5440

5541
/// Returns the starting page for the reading progression.
56-
var startingPage: Presentation.Page {
42+
var startingPage: Properties.Page {
5743
switch self {
5844
case .ltr:
5945
return .right

Sources/Shared/Publication/Accessibility/AccessibilityMetadataDisplayGuide.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public struct AccessibilityMetadataDisplayGuide: Sendable, Equatable {
206206
}
207207

208208
public init(publication: Publication) {
209-
let isFixedLayout = publication.metadata.presentation.layout == .fixed
209+
let isFixedLayout = publication.metadata.layout == .fixed
210210
let a11y = publication.metadata.accessibility ?? Accessibility()
211211

212212
visualAdjustments = {

Sources/Shared/Publication/Extensions/EPUB/Properties+EPUB.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public extension Properties {
2323
}
2424

2525
/// Hint about the nature of the layout for the linked resources.
26+
@available(*, unavailable, message: "This was removed from RWPM. You can still use the EPUB extensibility to access the original value.")
2627
var layout: EPUBLayout? {
2728
parseRaw(otherProperties["layout"])
2829
}

Sources/Shared/Publication/Extensions/Presentation/Metadata+Presentation.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Foundation
88

99
/// Presentation extensions for `Metadata`.
1010
public extension Metadata {
11-
var presentation: Presentation {
12-
(try? Presentation(json: otherMetadata["presentation"], warnings: self)) ?? Presentation()
13-
}
11+
@available(*, unavailable, message: "This was removed from RWPM. You can still use the EPUB extensibility to access the original values.")
12+
var presentation: Presentation { fatalError() }
1413
}

0 commit comments

Comments
 (0)