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

Commit ce1ea65

Browse files
authored
Merge pull request #173 from readium/2.0.0-alpha.1
2.0.0-alpha.1
2 parents 7753a9c + cbbedab commit ce1ea65

File tree

11 files changed

+65
-19
lines changed

11 files changed

+65
-19
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
66

77
## [Unreleased]
88

9+
## [2.0.0-alpha.1]
10+
911
### Added
1012

1113
* `ReadiumWebPubParser` to parse all Readium Web Publication profiles, including [Audiobooks](https://readium.org/webpub-manifest/extensions/audiobook.html) and [LCP for PDF](https://readium.org/lcp-specs/notes/lcp-for-pdf.html). It parses both manifests and packages.
@@ -16,4 +18,4 @@ All notable changes to this project will be documented in this file.
1618
* [Prevent the embedded HTTP server from stopping when the device is locked](https://github.com/readium/r2-streamer-swift/pull/163), to allow background playback of audiobooks.
1719

1820
[unreleased]: https://github.com/readium/r2-streamer-swift/compare/master...HEAD
19-
[x.x.x]: https://github.com/readium/r2-streamer-swift/compare/1.2.5...x.x.x
21+
[2.0.0-alpha.1]: https://github.com/readium/r2-streamer-swift/compare/1.2.5...2.0.0-alpha.1

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#github "readium/r2-shared-swift" == 1.4.3
1+
github "readium/r2-shared-swift" "2.0.0-alpha.1"
22
github "dexman/Minizip" == 1.4.0
33
github "cezheng/Fuzi" == 3.1.2
44
github "krzyzanowskim/CryptoSwift" == 1.3.1

Cartfile.resolved

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ github "cezheng/Fuzi" "3.1.2"
22
github "dexman/Minizip" "1.4.0"
33
github "edrlab/GCDWebServer" "3.6.2"
44
github "krzyzanowskim/CryptoSwift" "1.3.1"
5+
github "readium/r2-shared-swift" "c77b663dfed7e8e0d9317c7c01daaccb878bf9fb"

R2Streamer.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
Pod::Spec.new do |s|
22

33
s.name = "R2Streamer"
4-
s.version = "1.2.5"
4+
s.version = "2.0.0-alpha.1"
55
s.license = "BSD 3-Clause License"
66
s.summary = "R2 Streamer"
77
s.homepage = "http://readium.github.io"
88
s.author = { "Aferdita Muriqi" => "[email protected]" }
9-
s.source = { :git => "https://github.com/readium/r2-streamer-swift.git", :tag => "1.2.5" }
9+
s.source = { :git => "https://github.com/readium/r2-streamer-swift.git", :tag => "2.0.0-alpha.1" }
1010
s.exclude_files = ["**/Info*.plist"]
1111
s.requires_arc = true
1212
s.resources = ['r2-streamer-swift/Resources/**']
1313
s.source_files = "r2-streamer-swift/**/*.{m,h,swift}"
1414
s.platform = :ios
1515
s.ios.deployment_target = "10.0"
16-
17-
s.libraries = 'z'
16+
s.libraries = 'z', 'xml2'
17+
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
1818

1919
s.dependency 'R2Shared'
2020
s.dependency 'Fuzi'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ install R2Streamer with Carthage:
2525
2. Update your Cartfile to include the following:
2626

2727
```ruby
28-
github "readium/r2-streamer-swift" ~> 1.0.7
28+
github "readium/r2-streamer-swift" "develop"
2929
```
3030

3131
3. Run `carthage update` and
@@ -57,7 +57,7 @@ R2Streamer with CocoaPods:
5757
use_frameworks!
5858
5959
target 'YourAppTargetName' do
60-
pod 'R2Streamer', :git => 'https://github.com/readium/r2-streamer-swift.git', '~> 1.0.7'
60+
pod 'R2Streamer', :git => 'https://github.com/readium/r2-streamer-swift.git', :branch => 'develop'
6161
end
6262
```
6363

r2-streamer-swift/Parser/CBZ/CBZParser.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public class CbzParser: PublicationParser {
5757
format: .cbz,
5858
positionListFactory: makePositionList(of:),
5959
metadata: Metadata(
60-
identifier: url.lastPathComponent,
6160
title: url.deletingPathExtension()
6261
.lastPathComponent
6362
.replacingOccurrences(of: "_", with: " ")

r2-streamer-swift/Parser/EPUB/EPUBMetadataParser.swift

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ final class EPUBMetadataParser: Loggable {
192192

193193
/// Parse and return the Epub unique identifier.
194194
/// https://github.com/readium/architecture/blob/master/streamer/parser/metadata.md#identifier
195-
private lazy var uniqueIdentifier: String? = metadataElement?
196-
.firstChild(xpath:"dc:identifier[@id=/opf:package/@unique-identifier]")?
197-
.stringValue
195+
private lazy var uniqueIdentifier: String? =
196+
dcElement(tag: "identifier[@id=/opf:package/@unique-identifier]")?
197+
.stringValue
198198

199199
/// https://github.com/readium/architecture/blob/master/streamer/parser/metadata.md#publication-date
200-
private lazy var publishedDate = metadataElement?
201-
.firstChild(xpath: "dc:date[not(@opf:event) or @opf:event='publication']")?
202-
.stringValue.dateFromISO8601
200+
private lazy var publishedDate =
201+
dcElement(tag: "date[not(@opf:event) or @opf:event='publication']")?
202+
.stringValue.dateFromISO8601
203203

204204
/// Parse the modifiedDate (date of last modification of the EPUB).
205205
/// https://github.com/readium/architecture/blob/master/streamer/parser/metadata.md#modification-date
@@ -210,7 +210,7 @@ final class EPUBMetadataParser: Loggable {
210210
.first
211211
}
212212
let epub2Date = {
213-
self.metadataElement?.firstChild(xpath: "dc:date[@opf:event='modification']")?
213+
self.dcElement(tag: "date[@opf:event='modification']")?
214214
.stringValue.dateFromISO8601
215215
}
216216
return epub3Date() ?? epub2Date()
@@ -479,4 +479,12 @@ final class EPUBMetadataParser: Loggable {
479479
}
480480
}
481481

482+
/// Returns the given `dc:` tag in the `metadata` element.
483+
///
484+
/// This looks under `metadata/dc-metadata` as well, to be compatible with old EPUB 2 files.
485+
private func dcElement(tag: String) -> XMLElement? {
486+
return metadataElement?
487+
.firstChild(xpath:"(.|opf:dc-metadata)/dc:\(tag)")
488+
}
489+
482490
}

r2-streamer-swift/Parser/EPUB/OPFMeta.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ struct OPFMetaList {
152152
let prefixes = OPFVocabulary.prefixes(in: document)
153153
document.definePrefix("opf", forNamespace: "http://www.idpf.org/2007/opf")
154154
document.definePrefix("dc", forNamespace: "http://purl.org/dc/elements/1.1/")
155-
155+
156156
// Parses `<meta>` and `<dc:x>` tags in order of appearance.
157-
self.metas = document.xpath("/opf:package/opf:metadata/opf:meta|/opf:package/opf:metadata/dc:*")
157+
let root = "/opf:package/opf:metadata"
158+
self.metas = document.xpath("\(root)/opf:meta|\(root)/dc:*|\(root)/opf:dc-metadata/dc:*|\(root)/opf:x-metadata/opf:meta")
158159
.compactMap { meta in
159160
if meta.tag == "meta" {
160161
// EPUB 3

r2-streamer-swiftTests/Parser/EPUB/EPUBMetadataParserTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ class EPUBMetadataParserTests: XCTestCase {
9999
))
100100
}
101101

102+
/// Old EPUB 2 files sometimes contain the `dc` tags under `dc-metadata` and `x-metadata`.
103+
/// See http://idpf.org/epub/20/spec/OPF_2.0_final_spec.html#Section2.2
104+
func testParseUnderDCMetadataElement() throws {
105+
let sut = try parseMetadata("dc-metadata")
106+
107+
XCTAssertEqual(sut.identifier, "urn:uuid:1a16ce38-82bd-4e9b-861e-773c2e787a50")
108+
XCTAssertEqual(sut.title, "Alice's Adventures in Wonderland")
109+
XCTAssertEqual(sut.modified, "2012-04-02T12:47:00Z".dateFromISO8601)
110+
XCTAssertEqual(sut.authors, [Contributor(name: "Lewis Carroll")])
111+
}
112+
102113
func testParseMainTitle() throws {
103114
let sut = try parseMetadata("title-main")
104115
XCTAssertEqual(sut.title, "Main title takes precedence")

0 commit comments

Comments
 (0)