Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #349 from readium/2.2.0
Browse files Browse the repository at this point in the history
2.2.0
  • Loading branch information
mickael-menu authored Aug 11, 2020
2 parents 43b8eff + d63121f commit 639ee78
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 47 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

9 changes: 5 additions & 4 deletions Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ github "krzyzanowskim/CryptoSwift" == 1.3.1
github "cezheng/Fuzi" == 3.1.2
github "dexman/Minizip" == 1.4.0
github "scinfu/SwiftSoup" == 2.3.2
#github "readium/r2-shared-swift" == 1.4.3
#github "readium/r2-streamer-swift" == 1.2.5
#github "readium/r2-navigator-swift" == 1.2.6
#github "readium/readium-opds-swift" == 1.2.3

github "readium/r2-shared-swift" "2.0.0-alpha.1"
github "readium/r2-streamer-swift" "2.0.0-alpha.1"
github "readium/r2-navigator-swift" "2.0.0-alpha.1"
github "readium/readium-opds-swift" "2.0.0-alpha.1"
4 changes: 4 additions & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ github "edrlab/GCDWebServer" "3.6.2"
github "jdg/MBProgressHUD" "1.2.0"
github "krzyzanowskim/CryptoSwift" "1.3.1"
github "onevcat/Kingfisher" "5.14.0"
github "readium/r2-navigator-swift" "97128e606c20f4ee739c967c615068c70ad376f6"
github "readium/r2-shared-swift" "c77b663dfed7e8e0d9317c7c01daaccb878bf9fb"
github "readium/r2-streamer-swift" "cbbedab9bf8f9eb4ac4359ea3a8096e5eb2fee16"
github "readium/readium-opds-swift" "b6e903314f6b6ac5460b2ceacf6e3a2afa260f63"
github "scinfu/SwiftSoup" "2.3.2"
github "stephencelis/SQLite.swift" "0.12.2"
github "weichsel/ZIPFoundation" "0.9.11"
32 changes: 16 additions & 16 deletions r2-testapp-swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 327YA3JNGT;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1517,7 +1517,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.2.0;
OTHER_LDFLAGS = "-lxml2";
OTHER_SWIFT_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = org.readium.r2reader;
Expand All @@ -1538,7 +1538,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 327YA3JNGT;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1556,7 +1556,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.2.0;
OTHER_LDFLAGS = "-lxml2";
OTHER_SWIFT_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = org.readium.r2reader;
Expand All @@ -1577,7 +1577,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 327YA3JNGT;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1595,7 +1595,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.2.0;
OTHER_LDFLAGS = "-lxml2";
OTHER_SWIFT_FLAGS = "-DLCP";
PRODUCT_BUNDLE_IDENTIFIER = org.readium.r2reader;
Expand All @@ -1616,7 +1616,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 327YA3JNGT;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1634,7 +1634,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.2.0;
OTHER_LDFLAGS = "-lxml2";
OTHER_SWIFT_FLAGS = "-DLCP";
PRODUCT_BUNDLE_IDENTIFIER = org.readium.r2reader;
Expand All @@ -1654,7 +1654,7 @@
CODE_SIGN_ENTITLEMENTS = "r2-testapp-swift/r2-testapp-swift.entitlements";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 327YA3JNGT;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1672,7 +1672,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.2.0;
OTHER_LDFLAGS = "-lxml2";
OTHER_SWIFT_FLAGS = "-DLCP";
PRODUCT_BUNDLE_IDENTIFIER = org.readium.r2reader;
Expand All @@ -1691,7 +1691,7 @@
CODE_SIGN_ENTITLEMENTS = "r2-testapp-swift/r2-testapp-swift.entitlements";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 327YA3JNGT;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1709,7 +1709,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.2.0;
OTHER_LDFLAGS = "-lxml2";
OTHER_SWIFT_FLAGS = "-DLCP";
PRODUCT_BUNDLE_IDENTIFIER = org.readium.r2reader;
Expand Down Expand Up @@ -1847,7 +1847,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 327YA3JNGT;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1862,7 +1862,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.2.0;
OTHER_LDFLAGS = "-lxml2";
OTHER_SWIFT_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = org.readium.r2reader;
Expand All @@ -1883,7 +1883,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 13;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = 327YA3JNGT;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1898,7 +1898,7 @@
"$(inherited)",
"$(PROJECT_DIR)",
);
MARKETING_VERSION = 2.1.0;
MARKETING_VERSION = 2.2.0;
OTHER_LDFLAGS = "-lxml2";
OTHER_SWIFT_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = org.readium.r2reader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -36,8 +38,10 @@
ReferencedContainer = "container:r2-testapp-swift.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
<CodeCoverageTargets>
</CodeCoverageTargets>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -59,6 +63,8 @@
ReferencedContainer = "container:r2-testapp-swift.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
4 changes: 2 additions & 2 deletions r2-testapp-swift/Reader/CBZ/CBZViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class CBZViewController: ReaderViewController {
}

override var currentBookmark: Bookmark? {
guard let publicationID = publication.metadata.identifier,
guard
let locator = navigator.currentLocation,
let resourceIndex = publication.readingOrder.firstIndex(withHref: locator.href) else
{
return nil
}

return Bookmark(
publicationID: publicationID,
bookID: book.id,
resourceIndex: resourceIndex,
locator: locator
)
Expand Down
6 changes: 3 additions & 3 deletions r2-testapp-swift/Reader/Common/Bookmark/Bookmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import R2Shared
public class Bookmark {

public var id: Int64?
public var publicationID: String
public var bookID: Int64
public var resourceIndex: Int
public var locator: Locator
public var creationDate: Date

public init(id: Int64? = nil, publicationID: String, resourceIndex: Int, locator: Locator, creationDate: Date = Date()) {
public init(id: Int64? = nil, bookID: Int64, resourceIndex: Int, locator: Locator, creationDate: Date = Date()) {
self.id = id
self.publicationID = publicationID
self.bookID = bookID
self.resourceIndex = resourceIndex
self.locator = locator
self.creationDate = creationDate
Expand Down
10 changes: 5 additions & 5 deletions r2-testapp-swift/Reader/Common/Bookmark/BookmarkDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ import R2Shared

class BookmarkDataSource: Loggable {

let publicationID :String?
let bookID: Int64?
private(set) var bookmarks = [Bookmark]()

init() {
self.publicationID = nil
self.bookID = nil
self.reloadBookmarks()
}

init(publicationID: String) {
self.publicationID = publicationID
init(bookID: Int64) {
self.bookID = bookID
self.reloadBookmarks()
}

func reloadBookmarks() {
if let list = try? BookmarkDatabase.shared.bookmarks.bookmarkList(for: self.publicationID) {
if let list = try? BookmarkDatabase.shared.bookmarks.bookmarkList(for: self.bookID) {
self.bookmarks = list
self.bookmarks.sort { (b1, b2) -> Bool in
if b1.resourceIndex == b2.resourceIndex {
Expand Down
18 changes: 9 additions & 9 deletions r2-testapp-swift/Reader/Common/Bookmark/BookmarkDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BookmarksTable {
let tableName = Table("BOOKMARKS")

let bookmarkID = Expression<Int64>("id")
let publicationID = Expression<String>("publicationID")
let bookID = Expression<Int64>("bookID")

let resourceIndex = Expression<Int>("resourceIndex")
let resourceHref = Expression<String>("resourceHref")
Expand All @@ -70,7 +70,7 @@ class BookmarksTable {
_ = try? connection.run(tableName.create(temporary: false, ifNotExists: true) { t in
t.column(bookmarkID, primaryKey: PrimaryKey.autoincrement)
t.column(creationDate)
t.column(publicationID)
t.column(bookID)
t.column(resourceHref)
t.column(resourceIndex)
t.column(resourceType)
Expand All @@ -83,7 +83,7 @@ class BookmarksTable {
func insert(newBookmark: Bookmark) throws -> Int64? {
let db = BookmarkDatabase.shared.connection

let bookmark = tableName.filter(self.publicationID == newBookmark.publicationID && self.resourceHref == newBookmark.locator.href && self.resourceIndex == newBookmark.resourceIndex && self.locations == (newBookmark.locator.locations.jsonString ?? ""))
let bookmark = tableName.filter(self.bookID == newBookmark.bookID && self.resourceHref == newBookmark.locator.href && self.resourceIndex == newBookmark.resourceIndex && self.locations == (newBookmark.locator.locations.jsonString ?? ""))

// Check if empty.
guard try db.count(bookmark) == 0 else {
Expand All @@ -92,7 +92,7 @@ class BookmarksTable {

let insertQuery = tableName.insert(
creationDate <- newBookmark.creationDate,
publicationID <- newBookmark.publicationID,
bookID <- newBookmark.bookID,
resourceHref <- newBookmark.locator.href,
resourceIndex <- newBookmark.resourceIndex,
resourceType <- newBookmark.locator.type,
Expand Down Expand Up @@ -121,7 +121,7 @@ class BookmarksTable {
return true
}

func bookmarkList(for publicationID:String?=nil, resourceIndex:Int?=nil) throws -> [Bookmark]? {
func bookmarkList(for bookID: Int64? = nil, resourceIndex: Int? = nil) throws -> [Bookmark]? {

let db = BookmarkDatabase.shared.connection
// Check if empty.
Expand All @@ -130,12 +130,12 @@ class BookmarksTable {
}

let resultList = try { () -> AnySequence<Row> in
if let fetchingID = publicationID {
if let fetchingID = bookID {
if let fetchingIndex = resourceIndex {
let query = self.tableName.filter(self.publicationID == fetchingID && self.resourceIndex == fetchingIndex)
let query = self.tableName.filter(self.bookID == fetchingID && self.resourceIndex == fetchingIndex)
return try db.prepare(query)
}
let query = self.tableName.filter(self.publicationID == fetchingID)
let query = self.tableName.filter(self.bookID == fetchingID)
return try db.prepare(query)
}
return try db.prepare(self.tableName)
Expand All @@ -144,7 +144,7 @@ class BookmarksTable {
return resultList.map { row in
Bookmark(
id: row[self.bookmarkID],
publicationID: row[self.publicationID],
bookID: row[self.bookID],
resourceIndex: row[self.resourceIndex],
locator: Locator(
href: row[self.resourceHref],
Expand Down
2 changes: 1 addition & 1 deletion r2-testapp-swift/Reader/Common/ReaderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ReaderViewController: UIViewController, Loggable {
let book: Book
let drm: DRM?

lazy var bookmarksDataSource: BookmarkDataSource? = BookmarkDataSource(publicationID: publication.metadata.identifier ?? "")
lazy var bookmarksDataSource: BookmarkDataSource? = BookmarkDataSource(bookID: book.id)

private(set) var stackView: UIStackView!
private lazy var positionLabel = UILabel()
Expand Down
4 changes: 2 additions & 2 deletions r2-testapp-swift/Reader/EPUB/EPUBViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ class EPUBViewController: ReaderViewController {
}

override var currentBookmark: Bookmark? {
guard let publicationID = publication.metadata.identifier,
guard
let locator = navigator.currentLocation,
let resourceIndex = publication.readingOrder.firstIndex(withHref: locator.href) else
{
return nil
}
return Bookmark(publicationID: publicationID, resourceIndex: resourceIndex, locator: locator)
return Bookmark(bookID: book.id, resourceIndex: resourceIndex, locator: locator)
}

@objc func presentUserSettings() {
Expand Down
4 changes: 2 additions & 2 deletions r2-testapp-swift/Reader/PDF/PDFViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ final class PDFViewController: ReaderViewController {
}

override var currentBookmark: Bookmark? {
guard let publicationID = publication.metadata.identifier,
guard
let locator = navigator.currentLocation,
let resourceIndex = publication.readingOrder.firstIndex(withHref: locator.href) else
{
return nil
}

return Bookmark(
publicationID: publicationID,
bookID: book.id,
resourceIndex: resourceIndex,
locator: locator
)
Expand Down
2 changes: 2 additions & 0 deletions r2-testapp-swift/r2-testapp-swift-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIFileSharingEnabled</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down

0 comments on commit 639ee78

Please sign in to comment.