Skip to content

Commit

Permalink
Merge branch 'develop' into task/PP-2079-cover-images-not-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricecarrier7 committed Jan 30, 2025
2 parents dc85701 + d3a391d commit 665c12d
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 157 deletions.
9 changes: 9 additions & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Files ignored for scc line of code calculation
readium-sdk/
readium-shared-js/
TestResources
mobile-bookmark-spec/
PalaceTests/
adobe-rmsdk/
PalaceConfig/
*.xcassets
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
binary "https://liblcp.dita.digital/readium/liblcp/ios/carthage/xHwy01rpnw/liblcp.json" ~> 3.0.0

2 changes: 0 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
github "PureLayout/PureLayout" "v3.1.9"
github "dexman/Minizip" "1.4.0"

binary "https://liblcp.dita.digital/readium/liblcp/ios/carthage/xHwy01rpnw/liblcp.json" "3.0.0"
8 changes: 0 additions & 8 deletions Palace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
2D382BD71D08BA99002C423D /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D382BD61D08BA99002C423D /* Log.swift */; };
2D4379FE1C46FDB600AE1AD5 /* ReaderClientCert.sig in Resources */ = {isa = PBXBuildFile; fileRef = 085D31FB1BE7BE86007F7672 /* ReaderClientCert.sig */; };
2D62568B1D412BCB0080A81F /* BundledHTMLViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D62568A1D412BCB0080A81F /* BundledHTMLViewController.swift */; };
2D6256911D41582A0080A81F /* software-licenses.html in Resources */ = {isa = PBXBuildFile; fileRef = 2D6256901D41582A0080A81F /* software-licenses.html */; };
2D754BBB2002E2FB0061D34F /* TPPOPDSAcquisition.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D754BBA2002E2FB0061D34F /* TPPOPDSAcquisition.m */; };
2D754BC22002F1B10061D34F /* TPPOPDSIndirectAcquisition.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D754BC12002F1B10061D34F /* TPPOPDSIndirectAcquisition.m */; };
2D87909D20127AA300E2763F /* TPPOPDSAcquisitionPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D87909C20127AA300E2763F /* TPPOPDSAcquisitionPath.m */; };
Expand Down Expand Up @@ -517,7 +516,6 @@
73EB0B5B25821DF4006BC997 /* TPPProblemReportViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 085D31D81BE29ED4007F7672 /* TPPProblemReportViewController.xib */; };
73EB0B5C25821DF4006BC997 /* readium-shared-js_all.js in Resources */ = {isa = PBXBuildFile; fileRef = 5A69290D1B95ACC600FB4C10 /* readium-shared-js_all.js */; };
73EB0B5D25821DF4006BC997 /* ReaderClientCert.sig in Resources */ = {isa = PBXBuildFile; fileRef = 085D31FB1BE7BE86007F7672 /* ReaderClientCert.sig */; };
73EB0B5E25821DF4006BC997 /* software-licenses.html in Resources */ = {isa = PBXBuildFile; fileRef = 2D6256901D41582A0080A81F /* software-licenses.html */; };
73EB0B5F25821DF4006BC997 /* TPP_Launch_Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E65977C41F82AC91003CD6BC /* TPP_Launch_Screen.storyboard */; };
73EB0B6025821DF4006BC997 /* Accounts.json in Resources */ = {isa = PBXBuildFile; fileRef = 03F94CCE1DD627AA00CE8F4F /* Accounts.json */; };
73EB0B6125821DF4006BC997 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A823D819192BABA400B55DE2 /* InfoPlist.strings */; };
Expand Down Expand Up @@ -949,7 +947,6 @@
D570B6D42BA20139003FE991 /* readium-shared-js_all.js in Resources */ = {isa = PBXBuildFile; fileRef = 5A69290D1B95ACC600FB4C10 /* readium-shared-js_all.js */; };
D570B6D52BA20139003FE991 /* ReaderClientCert.sig in Resources */ = {isa = PBXBuildFile; fileRef = 085D31FB1BE7BE86007F7672 /* ReaderClientCert.sig */; };
D570B6D62BA20139003FE991 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 17E81F32261FF758001003C2 /* Localizable.stringsdict */; };
D570B6D72BA20139003FE991 /* software-licenses.html in Resources */ = {isa = PBXBuildFile; fileRef = 2D6256901D41582A0080A81F /* software-licenses.html */; };
D570B6D82BA20139003FE991 /* TPP_Launch_Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E65977C41F82AC91003CD6BC /* TPP_Launch_Screen.storyboard */; };
D570B6D92BA20139003FE991 /* Accounts.json in Resources */ = {isa = PBXBuildFile; fileRef = 03F94CCE1DD627AA00CE8F4F /* Accounts.json */; };
D570B6DA2BA20139003FE991 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A823D819192BABA400B55DE2 /* InfoPlist.strings */; };
Expand Down Expand Up @@ -1701,7 +1698,6 @@
2D382BCF1D08B1F5002C423D /* Palace-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Palace-Bridging-Header.h"; sourceTree = "<group>"; };
2D382BD61D08BA99002C423D /* Log.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = "<group>"; };
2D62568A1D412BCB0080A81F /* BundledHTMLViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BundledHTMLViewController.swift; sourceTree = "<group>"; };
2D6256901D41582A0080A81F /* software-licenses.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "software-licenses.html"; sourceTree = "<group>"; };
2D6AF74A1E7E341F005CEC90 /* Palace+RMSDK.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Palace+RMSDK.xcconfig"; path = "../Palace+RMSDK.xcconfig"; sourceTree = "<group>"; };
2D754BB92002E2FB0061D34F /* TPPOPDSAcquisition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TPPOPDSAcquisition.h; sourceTree = "<group>"; };
2D754BBA2002E2FB0061D34F /* TPPOPDSAcquisition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TPPOPDSAcquisition.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3340,7 +3336,6 @@
84B7A3421B84E8FE00584FB2 /* OpenDyslexicFont */,
11C113D319F842E2005B3F63 /* Reader */,
E61D7F631F6AC78B0091C781 /* SimplyE.entitlements */,
2D6256901D41582A0080A81F /* software-licenses.html */,
110F853C19D5FA7300052DF7 /* DetailSummaryTemplate.html */,
738EF2D12405E3D900F388FB /* .gitignore */,
73DA43A12404B4A900985482 /* Cartfile */,
Expand Down Expand Up @@ -4073,7 +4068,6 @@
73EB0B5C25821DF4006BC997 /* readium-shared-js_all.js in Resources */,
73EB0B5D25821DF4006BC997 /* ReaderClientCert.sig in Resources */,
17E81F2F261FF758001003C2 /* Localizable.stringsdict in Resources */,
73EB0B5E25821DF4006BC997 /* software-licenses.html in Resources */,
73EB0B5F25821DF4006BC997 /* TPP_Launch_Screen.storyboard in Resources */,
73EB0B6025821DF4006BC997 /* Accounts.json in Resources */,
73EB0B6125821DF4006BC997 /* InfoPlist.strings in Resources */,
Expand Down Expand Up @@ -4110,7 +4104,6 @@
5A69290E1B95ACC600FB4C10 /* readium-shared-js_all.js in Resources */,
2D4379FE1C46FDB600AE1AD5 /* ReaderClientCert.sig in Resources */,
17E81F2C261FF758001003C2 /* Localizable.stringsdict in Resources */,
2D6256911D41582A0080A81F /* software-licenses.html in Resources */,
E65977C51F82AC91003CD6BC /* TPP_Launch_Screen.storyboard in Resources */,
03F94CCF1DD627AA00CE8F4F /* Accounts.json in Resources */,
A823D81B192BABA400B55DE2 /* InfoPlist.strings in Resources */,
Expand Down Expand Up @@ -4147,7 +4140,6 @@
D570B6D42BA20139003FE991 /* readium-shared-js_all.js in Resources */,
D570B6D52BA20139003FE991 /* ReaderClientCert.sig in Resources */,
D570B6D62BA20139003FE991 /* Localizable.stringsdict in Resources */,
D570B6D72BA20139003FE991 /* software-licenses.html in Resources */,
D570B6D82BA20139003FE991 /* TPP_Launch_Screen.storyboard in Resources */,
D570B6D92BA20139003FE991 /* Accounts.json in Resources */,
D570B6DA2BA20139003FE991 /* InfoPlist.strings in Resources */,
Expand Down
12 changes: 5 additions & 7 deletions Palace/Accounts/Library/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ protocol AccountLogoDelegate: AnyObject {
details = AccountDetails(authenticationDocument: authenticationDocument, uuid: uuid)
}
}

var logoUrl: URL? = nil


var loansUrl: URL? {
return details?.loansUrl
Expand All @@ -423,12 +424,9 @@ protocol AccountLogoDelegate: AnyObject {
logo = UIImage(named: "LibraryLogoMagic")!

homePageUrl = publication.links.first(where: { $0.rel == "alternate" })?.href
logoUrl = publication.thumbnailURL

super.init()

DispatchQueue.main.async {
self.loadLogo(imageURL: publication.thumbnailURL)
}
}

/// Load authentication documents from the network or cache.
Expand Down Expand Up @@ -515,8 +513,8 @@ protocol AccountLogoDelegate: AnyObject {
}
}

private func loadLogo(imageURL: URL?) {
guard let url = imageURL else { return }
func loadLogo() {
guard let url = self.logoUrl else { return }

self.fetchImage(from: url, completion: {
guard let image = $0 else { return }
Expand Down
4 changes: 4 additions & 0 deletions Palace/Accounts/Library/AccountsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ let currentAccountIdentifierKey = "TPPCurrentAccountIdentifier"
// changing the `accountsSets` dictionary will also change `currentAccount`
Log.debug(#function, "hadAccount=\(hadAccount) currentAccountID=\(currentAccountId ?? "N/A") currentAcct=\(String(describing: currentAccount))")
if hadAccount != (self.currentAccount != nil) {
self.currentAccount?.loadLogo()
self.currentAccount?.loadAuthenticationDocument(using: TPPUserAccount.sharedAccount(), completion: { success in
DispatchQueue.main.async {
var mainFeed = URL(string: self.currentAccount?.catalogUrl ?? "")
Expand Down Expand Up @@ -225,6 +226,9 @@ let currentAccountIdentifierKey = "TPPCurrentAccountIdentifier"
// successfully
completion(true)
}
for account in accountSet {
account.loadLogo()
}
} catch (let error) {
TPPErrorLogger.logError(error,
summary: "Error while parsing catalog feed")
Expand Down
2 changes: 1 addition & 1 deletion Palace/Network/TPPNetworkResponder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ extension TPPNetworkResponder: URLSessionDataDelegate {
private func logTaskCompletion(taskID: Int, startDate: Date, metadata: inout [String: Any]) {
let elapsed = Date().timeIntervalSince(startDate)
metadata["elapsedTime"] = elapsed
Log.info(#file, "Task \(taskID) completed, elapsed time: \(elapsed) sec")
Log.info(#file, "Task \(taskID) completed (\(metadata["currentRequest"] ?? "nil")), elapsed time: \(elapsed) sec")
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ extension AdobeDRMContainer: Container {
return nil
}

return DRMResource(data: data, path: url.anyURL.string, drmContainer: self)
return DataResource(data: self.decode(data, at: url.anyURL.string), sourceURL: url.absoluteURL)
}

// MARK: - Helpers
Expand Down Expand Up @@ -141,67 +141,4 @@ extension AdobeDRMContainer: Container {
}
}
}

struct DRMResource: Resource {
private let data: Data
private let path: String
private let drmContainer: AdobeDRMContainer

init(data: Data, path: String, drmContainer: AdobeDRMContainer) {
self.data = data
self.path = path
self.drmContainer = drmContainer
}

func read(range: Range<UInt64>?) async throws -> Data {
let fullData = drmContainer.decode(data, at: path)

if let range = range {
let start = Int(clamping: range.lowerBound)
let end = Int(clamping: range.upperBound)
let intRange = start..<end

guard intRange.lowerBound >= 0, intRange.upperBound <= fullData.count else {
throw ReadError.access(.fileSystem(.fileNotFound(nil)))
}

return fullData.subdata(in: intRange)
} else {
return fullData
}
}

var sourceURL: AbsoluteURL? {
drmContainer.sourceURL
}

func properties() async -> ReadResult<ResourceProperties> {
var props = ResourceProperties()
props.length = UInt64(data.count)
return .success(props)
}

func estimatedLength() async -> ReadResult<UInt64?> {
return .success(UInt64(data.count))
}

func stream(range: Range<UInt64>?, consume: @escaping (Data) -> Void) async -> ReadResult<Void> {
do {
let chunk = try await read(range: range)
consume(chunk)
return .success(())
} catch {
return .failure(.access(.other(error)))
}
}

func close() {}
}

extension ResourceProperties {
public var length: UInt64? {
get { self["length"] }
set { self["length"] = newValue }
}
}
#endif
7 changes: 4 additions & 3 deletions Palace/Settings/NewSettings/TPPSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ struct TPPSettingsView: View {
}

@ViewBuilder private var softwareLicenseRow: some View {
let viewController = BundledHTMLViewController(
fileURL: Bundle.main.url(forResource: "software-licenses", withExtension: "html")!,
title: Strings.Settings.softwareLicenses
let viewController = RemoteHTMLViewController(
URL: URL(string: TPPSettings.TPPSoftwareLicensesURLString)!,
title: Strings.Settings.softwareLicenses,
failureMessage: Strings.Error.loadFailedError
)

let wrapper = UIViewControllerWrapper(viewController, updater: { _ in })
Expand Down
3 changes: 2 additions & 1 deletion Palace/Settings/TPPSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import Foundation
static let TPPAboutPalaceURLString = "http://thepalaceproject.org/"
static let TPPUserAgreementURLString = "https://legal.palaceproject.io/End%20User%20License%20Agreement.html"
static let TPPPrivacyPolicyURLString = "https://legal.palaceproject.io/Privacy%20Policy.html"

static let TPPSoftwareLicensesURLString = "https://legal.palaceproject.io/software-licenses.html"

static private let customMainFeedURLKey = "NYPLSettingsCustomMainFeedURL"
static private let accountMainFeedURLKey = "NYPLSettingsAccountMainFeedURL"
static private let userPresentedAgeCheckKey = "NYPLUserPresentedAgeCheckKey"
Expand Down
70 changes: 0 additions & 70 deletions Palace/software-licenses.html

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/count-loc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# In order to run this script you need the scc tool installed
# https://github.com/boyter/scc
# brew install scc

scc . -p --include-symlinks --no-gitmodule --no-complexity --no-cocomo

0 comments on commit 665c12d

Please sign in to comment.