You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,21 @@ All notable changes to this project will be documented in this file. Take a look
4
4
5
5
**Warning:** Features marked as *alpha* may change or be removed in a future release without notice. Use with caution.
6
6
7
-
<!-- ## [Unreleased] -->
7
+
## [Unreleased]
8
+
9
+
### Changed
10
+
11
+
* Many APIs now expect one of the new URL types (`RelativeURL`, `AbsoluteURL`, `HTTPURL` and `FileURL`). This is helpful because:
12
+
* It validates at compile time that we provide a URL that is supported.
13
+
* The API's capabilities are better documented, e.g. a download API could look like this : `download(url: HTTPURL) -> FileURL`.
14
+
15
+
#### Shared
16
+
17
+
*`Link` and `Locator`'s `href` are normalized as valid URLs to improve interoperability with the Readium Web toolkits.
18
+
***You MUST migrate your database if you were persisting HREFs and Locators**. Take a look at [the migration guide](Documentation/Migration%20Guide.md) for guidance.
19
+
* Links are not resolved to the `self` URL of a manifest anymore. However, you can still normalize the HREFs yourselves by calling `Manifest.normalizeHREFsToSelf()`.
20
+
*`Publication.localizedTitle` is now optional, as we cannot guarantee a publication will always have a title.
Copy file name to clipboardExpand all lines: Documentation/Migration Guide.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,55 @@
2
2
3
3
All migration steps necessary in reading apps to upgrade to major versions of the Swift Readium toolkit will be documented in this file.
4
4
5
+
## Unreleased
6
+
7
+
### Migration of HREFs and Locators (bookmarks, annotations, etc.)
8
+
9
+
:warning: This requires a database migration in your application, if you were persisting `Locator` objects.
10
+
11
+
In Readium v2.x, a `Link` or `Locator`'s `href` could be either:
12
+
13
+
* a valid absolute URL for a streamed publication, e.g. `https://domain.com/isbn/dir/my%20chapter.html`,
14
+
* a percent-decoded path for a local archive such as an EPUB, e.g. `/dir/my chapter.html`.
15
+
* Note that it was relative to the root of the archive (`/`).
16
+
17
+
To improve the interoperability with other Readium toolkits (in particular the Readium Web Toolkits, which only work in a streaming context) **Readium v3 now generates and expects valid URLs** for `Locator` and `Link`'s `href`.
18
+
19
+
*`https://domain.com/isbn/dir/my%20chapter.html` is left unchanged, as it was already a valid URL.
20
+
*`/dir/my chapter.html` becomes the relative URL path `dir/my%20chapter.html`
21
+
* We dropped the `/` prefix to avoid issues when resolving to a base URL.
22
+
* Special characters are percent-encoded.
23
+
24
+
**You must migrate the HREFs or Locators stored in your database** when upgrading to Readium 3. To assist you, two helpers are provided: `AnyURL(legacyHREF:)` and `Locator(legacyJSONString:)`.
25
+
26
+
Here's an example of a [GRDB migration](https://swiftpackageindex.com/groue/grdb.swift/master/documentation/grdb/migrations) that can serve as inspiration:
27
+
28
+
```swift
29
+
migrator.registerMigration("normalizeHREFs") { db in
30
+
let normalizedRows: [(id: Int, href: String, locator: String)] =
31
+
try Row.fetchAll(db, sql: "SELECT id, href, locator FROM bookmarks")
32
+
.compactMap { row in
33
+
guard
34
+
let normalizedHREF =AnyURL(legacyHREF: row["href"])?.string,
35
+
let normalizedLocator =tryLocator(legacyJSONString: row["locator"])?.jsonString
0 commit comments