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

Refactoring Publication models + XmlParser rewrite with namespaces handling #88

Merged
merged 47 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2e265f9
Replace usages of PageProgressionDirection as a name by usages as enu…
qnga Jan 17, 2020
454d928
Rewrite XmlParser with careful namespace handling
qnga Jan 17, 2020
86c7a34
Clean up media overlays
qnga Jan 18, 2020
aa18398
Refactor Properties model and add JSON tools
mickael-menu Jan 23, 2020
6c72bdb
Add lang property inheritance into the Xml Parser
qnga Jan 23, 2020
2314b0a
Refactor Link model
mickael-menu Jan 24, 2020
494a5e1
Add Presentation and EpubLayout shared models, add warnings logger to…
mickael-menu Jan 24, 2020
5a927ed
Add EPUB, OPDS and Presentation Properties extensions
mickael-menu Jan 27, 2020
dba8aad
Refactor Subject and add LocalizedString
mickael-menu Jan 27, 2020
e703c28
Refactor Contributor, Metadata and ReadingProgression
mickael-menu Jan 28, 2020
890ab55
Add PublicationCollection (sub-collection object) and WebPublication
mickael-menu Jan 28, 2020
28765f4
Refactor Publication, add ContentLayout and OPDS/EPUB Publication ext…
mickael-menu Jan 29, 2020
8407284
Refactor new shared Publication model, merge Publication and WebPubli…
mickael-menu Jan 29, 2020
e9e85bd
Extract Encryption extension and make Link immutable
mickael-menu Jan 30, 2020
6596e59
Deprecate old Publication shared models
mickael-menu Jan 30, 2020
18661ce
Update EPUB and Presentation modules from the JSON schema changes
mickael-menu Jan 30, 2020
271ab11
Reorganize Publication models
mickael-menu Jan 30, 2020
5e6a9c5
Add more deprecation aliases to fix build errors in the test-app
mickael-menu Jan 30, 2020
a4b89e0
Merge remote-tracking branch 'upstream/fixes/publication-models' into…
qnga Jan 30, 2020
6c742be
Refactor WarningLogger to handle generic warnings
mickael-menu Jan 31, 2020
fa7adf9
Merge branch 'PR/85' into fixes/publication-models
mickael-menu Jan 31, 2020
f60ba44
Remove Overflow.SCROLLED_CONTINUOUS
mickael-menu Jan 31, 2020
592a363
Make Presentation properties nullable
mickael-menu Jan 31, 2020
f12716b
Fix warnings and deprecation instructions
mickael-menu Jan 31, 2020
f062a53
Fix a bug, change default lang to "", add methods and tests in XmlParser
qnga Feb 2, 2020
7742f5c
Search recursively in alternates in linkWithHref style functions
qnga Feb 2, 2020
25fb453
Refactor LocalizedString using a Map and exposing transformation func…
mickael-menu Feb 3, 2020
a071ba7
Merge branch 'PR/85' into fixes/publication-models
mickael-menu Feb 3, 2020
9c95b57
Remove Link.mediaOverlays, fix some deprecation warnings
mickael-menu Feb 3, 2020
99acabb
Make the Publication models Parcelable instead of Serializable, to be…
mickael-menu Feb 4, 2020
12a3da8
Fix entity processing in XmlParser
mickael-menu Feb 4, 2020
5fe2b29
Generalize parsing of Enum raw values into KeyMapper
mickael-menu Feb 7, 2020
bfac0ee
Fix computing the ContentLayout from ReadingProgression and language
mickael-menu Feb 7, 2020
c03ec40
Fix formatting in XmlParser and argument order in test assertions
qnga Feb 8, 2020
7a21ab9
Rename ContentLayout.key to ContentLayout.cssId to improve clarity
mickael-menu Feb 9, 2020
b90be72
Merge remote-tracking branch 'upstream/fixes/publication-models' into…
qnga Feb 10, 2020
bc3b28f
Rewrite and test normalize function
qnga Feb 10, 2020
362fa97
Add Presentation.layoutOf(Link)
mickael-menu Feb 10, 2020
dc7b5b0
Parse `belongs_to` as an alternative to `belongsTo` in RWPM
mickael-menu Feb 11, 2020
8e79747
Minor cosmetic fixes
mickael-menu Feb 11, 2020
731710c
Merge branch 'pull/90' into fixes/publication-models
mickael-menu Feb 11, 2020
045fcae
Fix parsing of Contributor.position and EncryptionTest
mickael-menu Feb 12, 2020
06b39d8
Rename String.toIso8601Date to String.iso8601ToDate
mickael-menu Feb 12, 2020
4c14c78
Use Set for rels, fix Date tests, rename LocalizedString.get into Loc…
mickael-menu Feb 13, 2020
b8a60a2
Cosmetic changes
qnga Feb 14, 2020
fbb793b
Rename KeyMapper to MapCompanion
mickael-menu Feb 14, 2020
a4e5b44
Put WarningLogger as internal until the Streamer API is specified
mickael-menu Feb 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion r2-shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ dependencies {
implementation 'nl.komponents.kovenant:kovenant-jvm:3.3.0'
implementation 'nl.komponents.kovenant:kovenant-functional:3.3.0'
implementation 'joda-time:joda-time:2.9.9'

testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:3.14.0'
testImplementation 'org.mockito:mockito-core:2.19.0'
testImplementation 'xmlpull:xmlpull:1.1.3.1'
testImplementation 'net.sf.kxml:kxml2:2.3.0'
testImplementation 'org.json:json:20190722'

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}
49 changes: 0 additions & 49 deletions r2-shared/src/main/java/org/readium/r2/shared/Collection.kt

This file was deleted.

109 changes: 0 additions & 109 deletions r2-shared/src/main/java/org/readium/r2/shared/Contributor.kt

This file was deleted.

92 changes: 92 additions & 0 deletions r2-shared/src/main/java/org/readium/r2/shared/Deprecated.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Module: r2-shared-kotlin
* Developers: Mickaël Menu
*
* Copyright (c) 2020. Readium Foundation. All rights reserved.
* Use of this source code is governed by a BSD-style license which is detailed in the
* LICENSE file present in the project repository where this source code is maintained.
*/

@file:Suppress("RemoveRedundantQualifierName")

package org.readium.r2.shared

import org.json.JSONObject
import org.readium.r2.shared.extensions.removeLastComponent
import org.readium.r2.shared.publication.Collection
import org.readium.r2.shared.publication.Contributor
import org.readium.r2.shared.publication.Link
import org.readium.r2.shared.publication.Metadata
import org.readium.r2.shared.publication.Properties
import org.readium.r2.shared.publication.Subject
import org.readium.r2.shared.publication.encryption.Encryption
import org.readium.r2.shared.publication.presentation.Presentation
import java.net.URL


@Deprecated("Refactored into [LocalizedString]", ReplaceWith("org.readium.r2.shared.publication.LocalizedString"))
typealias MultilanguageString = org.readium.r2.shared.publication.LocalizedString

@Deprecated("Renamed into [ContentLayout]", ReplaceWith("org.readium.r2.shared.publication.ContentLayout"))
typealias ContentLayoutStyle = org.readium.r2.shared.publication.ContentLayout

@Deprecated("Renamed into [ReadingProgression]", ReplaceWith("org.readium.r2.shared.publication.ReadingProgression"))
typealias PageProgressionDirection = org.readium.r2.shared.publication.ReadingProgression

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.Publication"))
typealias Publication = org.readium.r2.shared.publication.Publication

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.Link"))
typealias Link = Link

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.Properties"))
typealias Properties = Properties

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.Metadata"))
typealias Metadata = Metadata

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.Contributor"))
typealias Contributor = Contributor

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.Collection"))
typealias Collection = Collection

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.Subject"))
typealias Subject = Subject

@Deprecated("Moved to another package", ReplaceWith("org.readium.r2.shared.publication.encryption.Encryption"))
typealias Encryption = Encryption

@Deprecated("Refactored into [Presentation]", ReplaceWith("org.readium.r2.shared.publication.presentation.Presentation"))
typealias Rendition = Presentation

@Deprecated("Refactored into [EpubLayout]", ReplaceWith("org.readium.r2.shared.publication.epub.EpubLayout"))
typealias RenditionLayout = org.readium.r2.shared.publication.epub.EpubLayout

@Deprecated("Refactored into [Presentation.Overflow]", ReplaceWith("org.readium.r2.shared.publication.presentation.Presentation.Overflow"))
typealias RenditionFlow = Presentation.Overflow

@Deprecated("Refactored into [Presentation.Orientation]", ReplaceWith("org.readium.r2.shared.publication.presentation.Presentation.Orientation"))
typealias RenditionOrientation = Presentation.Orientation

@Deprecated("Refactored into [Presentation.Spread]", ReplaceWith("org.readium.r2.shared.publication.presentation.Presentation.Spread"))
typealias RenditionSpread = Presentation.Spread

@Deprecated("Use [Publication::fromJSON] instead", ReplaceWith("Publication.fromJSON(pubDict)", "org.readium.r2.shared.publication.Publication"))
fun parsePublication(pubDict: JSONObject): org.readium.r2.shared.publication.Publication {
return org.readium.r2.shared.publication.Publication.fromJSON(pubDict)
?: throw Exception("Invalid publication")
}

@Deprecated("Use [Link::fromJSON] instead", ReplaceWith("Link.fromJSON(linkDict)", "org.readium.r2.shared.publication.Link"))
fun parseLink(linkDict: JSONObject, feedUrl: URL? = null): Link =
Link.fromJSON(linkDict, normalizeHref = {
if (feedUrl == null) {
it
} else {
getAbsolute(it, feedUrl.toString())
}
}) ?: Link(href = "#")

@Deprecated("Moved to another package", ReplaceWith("removeLastComponent()", "org.readium.r2.shared.extensions.removeLastComponent"))
fun URL.removeLastComponent(): URL = removeLastComponent()
27 changes: 0 additions & 27 deletions r2-shared/src/main/java/org/readium/r2/shared/Encryption.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

package org.readium.r2.shared

import org.readium.r2.shared.util.MapCompanion
import java.io.Serializable

enum class Injectable(val rawValue: String): Serializable {
Script("scripts"),
Font("fonts"),
Style("styles");

companion object {
operator fun invoke(rawValue: String) = values().firstOrNull { it.rawValue == rawValue }
}
companion object : MapCompanion<String, Injectable>(values(), Injectable::rawValue)

}
16 changes: 13 additions & 3 deletions r2-shared/src/main/java/org/readium/r2/shared/JSONable.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
/*
* Module: r2-shared-kotlin
* Developers: Aferdita Muriqi, Clément Baumann
* Developers: Aferdita Muriqi, Clément Baumann, Mickaël Menu
*
* Copyright (c) 2018. Readium Foundation. All rights reserved.
* Copyright (c) 2020. Readium Foundation. All rights reserved.
* Use of this source code is governed by a BSD-style license which is detailed in the
* LICENSE file present in the project repository where this source code is maintained.
*/

package org.readium.r2.shared

import org.json.JSONArray
import org.json.JSONObject

interface JSONable {

/**
* Serializes the object to its JSON representation.
*/
fun toJSON(): JSONObject

}
}

/**
* Serializes a list of [JSONable] into a [JSONArray].
*/
fun List<JSONable>.toJSON(): JSONArray =
JSONArray(map(JSONable::toJSON))
Loading