aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala')
-rw-r--r--src/main/scala/reading/Books.scala8
-rw-r--r--src/main/scala/reading/component/index/BookDetail.scala2
-rw-r--r--src/main/scala/reading/component/index/Books.scala2
-rw-r--r--src/main/scala/reading/models/Book.scala16
-rw-r--r--src/main/scala/reading/models/Compare.scala17
-rw-r--r--src/main/scala/reading/models/Genre.scala7
-rw-r--r--src/main/scala/reading/models/Period.scala7
-rw-r--r--src/main/scala/reading/models/Theme.scala7
8 files changed, 36 insertions, 30 deletions
diff --git a/src/main/scala/reading/Books.scala b/src/main/scala/reading/Books.scala
index 68ca93c..4049720 100644
--- a/src/main/scala/reading/Books.scala
+++ b/src/main/scala/reading/Books.scala
@@ -1409,7 +1409,7 @@ object Books {
),
Book(
- title = "A Copier 100 fois",
+ title = "À Copier 100 fois",
author = "Antoine DOLE",
year = "xxx",
period = Some(Contemporain),
@@ -1661,7 +1661,7 @@ object Books {
),
Book(
- title = "Les ailes de la sylphide",
+ title = "Les Ailes de la Sylphide",
author = "Pascale MARET",
year = "xxx",
period = Some(Contemporain),
@@ -1756,7 +1756,7 @@ object Books {
),
Book(
- title = "Le Bazar des mauvais rêves : nouvelles",
+ title = "Le Bazar des mauvais rêves : nouvelles",
author = "Stephen KING",
year = "2016",
parts = 42,
@@ -2044,7 +2044,7 @@ object Books {
),
Book(
- title = "Boys don't cry",
+ title = "Boys don’t cry",
author = "Malorie BLACKMAN",
year = "2011",
period = Some(Contemporain),
diff --git a/src/main/scala/reading/component/index/BookDetail.scala b/src/main/scala/reading/component/index/BookDetail.scala
index f2d0d5d..7df771b 100644
--- a/src/main/scala/reading/component/index/BookDetail.scala
+++ b/src/main/scala/reading/component/index/BookDetail.scala
@@ -16,7 +16,7 @@ object BookDetail {
img(
BookStyle.cover,
src := s"cover/${book.title}.jpg",
- alt := book.title
+ alt := s"${book.title}, ${book.author}"
),
div(
diff --git a/src/main/scala/reading/component/index/Books.scala b/src/main/scala/reading/component/index/Books.scala
index b75a5b0..66d4423 100644
--- a/src/main/scala/reading/component/index/Books.scala
+++ b/src/main/scala/reading/component/index/Books.scala
@@ -30,7 +30,7 @@ object Books {
img(
BooksStyle.cover,
src := s"cover/${book.title}.jpg",
- alt := book.title,
+ alt := s"${book.title}, ${book.author}",
RxAttr(onclick, Rx(() => focus() = Some(book)))
)
)
diff --git a/src/main/scala/reading/models/Book.scala b/src/main/scala/reading/models/Book.scala
index 34af272..7d72f23 100644
--- a/src/main/scala/reading/models/Book.scala
+++ b/src/main/scala/reading/models/Book.scala
@@ -11,20 +11,8 @@ case class Book(
programs: Seq[Program],
level: Level
) extends Ordered[Book] {
- def compare(that: Book) = {
- def formatTitle(title: String) =
- title
- .toLowerCase
- .replaceAll("^les ", "")
- .replaceAll("^le ", "")
- .replaceAll("^l’", "")
- .replaceAll("^à la ", "")
- .replaceAll("^au ", "")
- .replaceAll("^aux ", "")
- .replaceAll("é", "e")
- .replaceAll("è", "e")
- formatTitle(this.title).compare(formatTitle(that.title))
- }
+ def compare(that: Book) =
+ Compare.format(this.title).compare(Compare.format(that.title))
}
object Book {
diff --git a/src/main/scala/reading/models/Compare.scala b/src/main/scala/reading/models/Compare.scala
new file mode 100644
index 0000000..dd763fe
--- /dev/null
+++ b/src/main/scala/reading/models/Compare.scala
@@ -0,0 +1,17 @@
+package reading.models
+
+object Compare {
+ def format(str: String): String =
+ str
+ .toLowerCase
+ .replaceAll("^les ", "")
+ .replaceAll("^le ", "")
+ .replaceAll("^l’", "")
+ .replaceAll("^à la ", "")
+ .replaceAll("^à ", "")
+ .replaceAll("^au ", "")
+ .replaceAll("^aux ", "")
+ .replaceAll("^années ", "")
+ .replaceAll("é", "e")
+ .replaceAll("è", "e")
+}
diff --git a/src/main/scala/reading/models/Genre.scala b/src/main/scala/reading/models/Genre.scala
index b5fc6c4..4006815 100644
--- a/src/main/scala/reading/models/Genre.scala
+++ b/src/main/scala/reading/models/Genre.scala
@@ -5,9 +5,8 @@ import enumeratum._
sealed trait Genre extends EnumEntry with Ordered[Genre] {
import Genre._
- def compare(that: Genre): Int = {
- values.indexOf(that) - values.indexOf(this)
- }
+ def compare(that: Genre) =
+ Compare.format(this.prettyPrint).compare(Compare.format(that.prettyPrint))
def prettyPrint(): String = this match {
case JournalIntime => "journal intime"
@@ -29,7 +28,7 @@ sealed trait Genre extends EnumEntry with Ordered[Genre] {
}
object Genre extends Enum[Genre] {
- val values = findValues
+ val values = findValues.sorted
case object JournalIntime extends Genre
case object RomanHistorique extends Genre
diff --git a/src/main/scala/reading/models/Period.scala b/src/main/scala/reading/models/Period.scala
index 90d6015..a962217 100644
--- a/src/main/scala/reading/models/Period.scala
+++ b/src/main/scala/reading/models/Period.scala
@@ -2,9 +2,12 @@ package reading.models
import enumeratum._
-sealed trait Period extends EnumEntry {
+sealed trait Period extends EnumEntry with Ordered[Period] {
import Period._
+ def compare(that: Period) =
+ Compare.format(this.prettyPrint).compare(Compare.format(that.prettyPrint))
+
def prettyPrint(): String = this match {
case Antiquite => "Antiquité"
case MA => "Moyen âge"
@@ -21,7 +24,7 @@ sealed trait Period extends EnumEntry {
}
object Period extends Enum[Period] {
- val values = findValues
+ val values = findValues.sorted
case object Antiquite extends Period
case object MA extends Period
diff --git a/src/main/scala/reading/models/Theme.scala b/src/main/scala/reading/models/Theme.scala
index 116bff8..61186a9 100644
--- a/src/main/scala/reading/models/Theme.scala
+++ b/src/main/scala/reading/models/Theme.scala
@@ -5,9 +5,8 @@ import enumeratum._
sealed trait Theme extends EnumEntry with Ordered[Theme] {
import Theme._
- def compare(that: Theme): Int = {
- values.indexOf(that) - values.indexOf(this)
- }
+ def compare(that: Theme) =
+ Compare.format(this.prettyPrint).compare(Compare.format(that.prettyPrint))
def prettyPrint(): String = this match {
case Amitie => "amitié"
@@ -90,7 +89,7 @@ sealed trait Theme extends EnumEntry with Ordered[Theme] {
}
object Theme extends Enum[Theme] {
- val values = findValues
+ val values = findValues.sorted
case object Adolescence extends Theme
case object Americain extends Theme