diff options
author | Joris | 2017-01-09 22:47:55 +0100 |
---|---|---|
committer | Joris | 2017-01-09 22:47:55 +0100 |
commit | f2264cf9176a7807a7993872cc1c2c437617c0b2 (patch) | |
tree | 6305075d29b8973ea073bf7d4c3aa296ee25b371 /src/main/scala | |
parent | b1b6cf18ee0da5d729c35800817c306bea64e73e (diff) |
Add books
Diffstat (limited to 'src/main/scala')
-rw-r--r-- | src/main/scala/reading/Books.scala | 437 | ||||
-rw-r--r-- | src/main/scala/reading/component/index/Books.scala | 3 | ||||
-rw-r--r-- | src/main/scala/reading/component/index/FiltersMenu.scala | 2 | ||||
-rw-r--r-- | src/main/scala/reading/component/index/style/Books.scala | 6 | ||||
-rw-r--r-- | src/main/scala/reading/models/Book.scala | 6 | ||||
-rw-r--r-- | src/main/scala/reading/models/Filter.scala | 11 | ||||
-rw-r--r-- | src/main/scala/reading/models/Genre.scala | 4 | ||||
-rw-r--r-- | src/main/scala/reading/models/Level.scala | 41 | ||||
-rw-r--r-- | src/main/scala/reading/models/Period.scala | 4 | ||||
-rw-r--r-- | src/main/scala/reading/models/Theme.scala | 12 |
10 files changed, 464 insertions, 62 deletions
diff --git a/src/main/scala/reading/Books.scala b/src/main/scala/reading/Books.scala index 886f337..3b77cb3 100644 --- a/src/main/scala/reading/Books.scala +++ b/src/main/scala/reading/Books.scala @@ -1,61 +1,430 @@ package reading -import reading.models.{Book, Period, Theme, Genre, Program} +import reading.models.{Book, Period, Theme, Genre, Program, Level} import Period._ import Theme._ import Genre._ import Program._ +import Level._ object Books { def apply(): Seq[Book] = Seq( Book( - title = "Les Dix petits nègres", - author = "Agatha Christie", - period = Siecle20, - genres = Seq(Policier), - themes = Seq(Peur), - programs = Seq(Monstre), - pages = 250 + title = "Sweet Sixteen", + author = "Annelise HEURTIER", + year = "2012", + period = Some(Annees50), + genres = Seq(RomanHistorique), + themes = Seq(Ecole, SegregationRaciale), + programs = Seq(), + level = Moyen ), Book( - title = "Le Joueur", - author = "Fiódor Dostoyevski", - period = Siecle19, - genres = Seq(), - themes = Seq(Peur), - programs = Seq(Heros), - pages = 170 + title = "Le Carnet d'Allie", + author = "Meg CABOT", + year = "2012-2016", + parts = 7, + period = Some(Contemporain), + genres = Seq(JournalIntime), + themes = Seq(Amitie, Famille), + programs = Seq(Autrui), + level = Moyen + ), + + Book( + title = "Une (irrésistible) envie de…", + author = "Meg CABOT", + year = "2007-2014", + parts = 5, + period = Some(Contemporain), + genres = Seq(Policier), + themes = Seq(VieNocturne), + programs = Seq(), + level = Difficile + ), + + Book( + title = "Les Filles au chocolat", + author = "Cathy CASSIDY", + year = "2011-2016", + parts = 9, + period = Some(Contemporain), + genres = Seq(), + themes = Seq(Amitie, Fratrie), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Le Monde de Charlie", + author = "Stephen CHBOSKY", + year = "2012", + period = Some(Contemporain), + genres = Seq(), + themes = Seq(Amitie, Rivalite), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Je veux vivre", + author = "Jenny DOWNHAM", + year = "2011", + period = Some(Contemporain), + genres = Seq(), + themes = Seq(Amour, Adolescence, Maladie), + programs = Seq(), + level = Difficile ), Book( - title = "Voyage au bout de la nuit", - author = "Céline", - period = Siecle20, - genres = Seq(), - themes = Seq(Peur), - programs = Seq(IndividuEtSociete), - pages = 380 + title = "Nos Etoiles contraires", + author = "John GREEN", + year = "2013", + period = Some(Contemporain), + genres = Seq(), + themes = Seq(Amour, Adolescence, Maladie), + programs = Seq(), + level = Moyen ), Book( - title = "Le Petit Prince", - author = "Antoine de Saint Exupéry", - period = Siecle19, - genres = Seq(Policier), - themes = Seq(Amitie), + title = "Lou !", + author = "Julien NEEL", + year = "2004-2016", + parts = 7, + period = Some(Contemporain), + genres = Seq(BD), + themes = Seq(College, Famille, Amitie), + programs = Seq(Autrui), + level = Facile + ), + + Book( + title = "Trois filles et…", + author = "Jacqueline WILSON", + year = "2000-2003", + parts = 4, + period = Some(Contemporain), + genres = Seq(), + themes = Seq(Amitie, Amour, Famille, Adolescence), + programs = Seq(Autrui), + level = Moyen + ), + + Book( + title = "Kiss", + author = "Jacqueline WILSON", + year = "2009", + period = None, + genres = Seq(), + themes = Seq(Amitie, Famille, Amour), + programs = Seq(Autrui), + level = Moyen + ), + + Book( + title = "Tintin", + author = "HERGE", + year = "20e siècle", + parts = 24, + period = Some(Siecle20), + genres = Seq(BD), + themes = Seq(Aventure, Amitie, College), + programs = Seq(RecitAventure, VoyageEtAventure), + level = Facile + ), + + Book( + title = "Le Royaume de Kensuké", + author = "Michael MORPURGO et François PLACE", + year = "2007", + period = None, + genres = Seq(RomanAventure), + themes = Seq(Aventure, Voyage), + programs = Seq(RecitAventure, VoyageEtAventure), + level = Facile + ), + + Book( + title = "L’Enfant Océan", + author = "J-C MOURLEVAT et Vincent DUTRAIT", + year = "2010", + period = None, + genres = Seq(), + themes = Seq(Aventure, Fratrie), programs = Seq(RecitAventure), - pages = 130 + level = Facile ), Book( - title = "Les Frères Karamazov", - author = "Fiódor Dostoyevski", - period = Siecle19, - genres = Seq(), - themes = Seq(Famille), + title = "L’oeil du loup", + author = "Daniel PENNAC", + year = "1984", + period = None, + genres = Seq(RomanAventure), + themes = Seq(Nature, Aventure), + programs = Seq(RecitAventure), + level = Facile + ), + + Book( + title = "Les Aventures de Tom Sawyer", + author = "Mark TWAIN", + year = "1876", + period = Some(Siecle19), + genres = Seq(RomanAventure), + themes = Seq(Amitie, Aventure), + programs = Seq(VoyageEtAventure), + level = Moyen + ), + + Book( + title = "Carnets de Cerise", + author = "Joris CHAMBLAIN et Aurélie NEYRET", + year = "2012-2016", + parts = 4, + period = Some(Contemporain), + genres = Seq(JournalIntime), + themes = Seq(Enquete), + programs = Seq(), + level = Facile + ), + + Book( + title = "Lady Grace", + author = "Patricia FINNEY", + year = "2005-2013", + parts = 12, + period = None, + genres = Seq(JournalIntime, RomanHistorique, Policier), + themes = Seq(), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Le Journal intime de Georgia NICOLSON", + author = "Louise RENNISON", + year = "2000-2014", + parts = 10, + period = Some(Contemporain), + genres = Seq(JournalIntime), + themes = Seq(Humour, Amitie, Amour, Famille, Adolescence), programs = Seq(Autrui), - pages = 850 + level = Moyen + ), + + Book( + title = "Journal d’une grosse nouille", + author = "RR RUSSELL", + year = "2012-2016", + parts = 10, + period = Some(Contemporain), + genres = Seq(JournalIntime), + themes = Seq(Ecole, Amitie, Amour, Humour), + programs = Seq(TraversSociete), + level = Moyen + ), + + Book( + title = "Les Colombes du Roi Soleil", + author = "Anne-Marie DESPLAT-DUC", + year = "", + period = Some(Louis14), + genres = Seq(RomanHistorique), + themes = Seq(Litterature), + programs = Seq(), + level = Facile + ), + + Book( + title = "A la Poursuite d’Olympe", + author = "Annie JAY", + year = "1995", + period = Some(Louis14), + genres = Seq(RomanHistorique), + themes = Seq(Emancipation), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Cheval de guerre", + author = "Michael MORPURGO", + year = "1986", + period = Some(Siecle20), + genres = Seq(RomanHistorique), + themes = Seq(Animal, Guerre, Amitie), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Soldat Peaceful", + author = "Michael MORPURGO", + year = "2004", + period = Some(Siecle20), + genres = Seq(RomanHistorique), + themes = Seq(Guerre, Fratrie), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Les Orangers de Versailles", + author = "Annie PIETRI", + year = "2000", + period = Some(Louis14), + genres = Seq(RomanHistorique), + themes = Seq(Enquete, Cour), + programs = Seq(), + level = Moyen + ), + + Book( + title = "L’Espionne du Roi-Soleil", + author = "Annie PIETRI", + year = "2002", + period = Some(Louis14), + genres = Seq(RomanHistorique), + themes = Seq(Famille, Enquete, Cour), + programs = Seq(), + level = Difficile + ), + + Book( + title = "L’Omelette au sucre", + author = "JP ARROU-VIGNOD", + year = "1999", + period = Some(Contemporain), + genres = Seq(Comique), + themes = Seq(Humour, Famille), + programs = Seq(), + level = Facile + ), + + Book( + title = "Matilda", + author = "Roald DAHL", + year = "1988", + period = None, + genres = Seq(Comique), + themes = Seq(Humour, Famille, Ecole), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Le Bon Gros Géant", + author = "Roald DAHL", + year = "1984", + period = None, + genres = Seq(Comique), + themes = Seq(Humour, Amitie, Aventure), + programs = Seq(Monstre, Autrui, Heros), + level = Moyen + ), + + Book( + title = "Fantastique Maître Renard", + author = "Roald DAHL", + year = "1977", + period = None, + genres = Seq(Comique), + themes = Seq(Humour, Famille, Animaux), + programs = Seq(Resister), + level = Facile + ), + + Book( + title = "Mortelle Adèle", + author = "Mr TAN", + year = "2013-2016", + parts = 11, + period = Some(Contemporain), + genres = Seq(BD), + themes = Seq(Humour, Amitie, Famille), + programs = Seq(), + level = Facile + ), + + Book( + title = "Les Plus belles histoires du Prince de Motordu", + author = "PEF", + year = "2014", + period = None, + genres = Seq(Comique), + themes = Seq(Famille), + programs = Seq(), + level = Facile + ), + + Book( + title = "Les Dix petits nègres", + author = "Agatha Christie", + year = "1939", + period = Some(Siecle20), + genres = Seq(Policier), + themes = Seq(Enquete), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Le Crime de l’Orient-Express", + author = "Agatha Christie", + year = "1934", + period = Some(Siecle20), + genres = Seq(Policier), + themes = Seq(Enquete, Voyage), + programs = Seq(), + level = Difficile + ), + + Book( + title = "Cinq petits cochons", + author = "Agatha Christie", + year = "1942", + period = Some(Siecle20), + genres = Seq(Policier), + themes = Seq(Famille, Enquete), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Un Cadavre dans la bibliothèque", + author = "Agatha Christie", + year = "1942", + period = Some(Siecle20), + genres = Seq(Policier), + themes = Seq(Enquete), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Le Meurtre de Roger Ackroyd", + author = "Agatha Christie", + year = "1926", + period = Some(Siecle20), + genres = Seq(Policier), + themes = Seq(Amour, Enquete), + programs = Seq(), + level = Moyen + ), + + Book( + title = "Le Chien des Baskerville", + author = "Arthur CONAN DOYLE", + year = "1902", + period = Some(Siecle20), + genres = Seq(Policier, Fantastique), + themes = Seq(Malediction, Enquete), + programs = Seq(), + level = Moyen ) ) } diff --git a/src/main/scala/reading/component/index/Books.scala b/src/main/scala/reading/component/index/Books.scala index 23a42da..435bf50 100644 --- a/src/main/scala/reading/component/index/Books.scala +++ b/src/main/scala/reading/component/index/Books.scala @@ -35,8 +35,7 @@ object Books { div(BooksStyle.item, s"programme : ${book.programs.sorted.mkString(", ")}"), div(BooksStyle.item, s"thème : ${book.themes.sorted.mkString(", ")}"), div(BooksStyle.item, s"genre : ${book.genres.sorted.mkString(", ")}"), - div(BooksStyle.item, s"période : ${book.period}"), - div(BooksStyle.item, s"${book.pages} pages") + div(BooksStyle.item, s"période : ${book.period}") ) ) ) diff --git a/src/main/scala/reading/component/index/FiltersMenu.scala b/src/main/scala/reading/component/index/FiltersMenu.scala index 68ace94..fcc8550 100644 --- a/src/main/scala/reading/component/index/FiltersMenu.scala +++ b/src/main/scala/reading/component/index/FiltersMenu.scala @@ -25,7 +25,7 @@ object FiltersMenu { }, group(books, filters, "Theme", Theme.values.map(Filter.apply(_))), group(books, filters, "Genre", Genre.values.map(Filter.apply(_))), - group(books, filters, "Niveau", Level.filters), + group(books, filters, "Niveau", Level.values.map(Filter.apply(_))), group(books, filters, "Période", Period.values.map(Filter.apply(_))) ) } diff --git a/src/main/scala/reading/component/index/style/Books.scala b/src/main/scala/reading/component/index/style/Books.scala index bbedf3a..fc3a18f 100644 --- a/src/main/scala/reading/component/index/style/Books.scala +++ b/src/main/scala/reading/component/index/style/Books.scala @@ -13,8 +13,8 @@ object Books extends StyleSheet.Inline { ) val book = style( - marginBottom(30.px), - marginRight(30.px) + marginBottom(40.px), + marginRight(60.px) ) val title = style( @@ -34,7 +34,7 @@ object Books extends StyleSheet.Inline { val cover = style( height(150.px), - marginRight(30.px) + marginRight(40.px) ) val item = style( diff --git a/src/main/scala/reading/models/Book.scala b/src/main/scala/reading/models/Book.scala index 344b4c6..1ee7eb6 100644 --- a/src/main/scala/reading/models/Book.scala +++ b/src/main/scala/reading/models/Book.scala @@ -3,11 +3,13 @@ package reading.models case class Book ( title: String, author: String, - period: Period, + year: String, + parts: Int = 1, + period: Option[Period], genres: Seq[Genre], themes: Seq[Theme], programs: Seq[Program], - pages: Int + level: Level ) extends Ordered[Book] { def compare(that: Book) = { def formatTitle(title: String) = diff --git a/src/main/scala/reading/models/Filter.scala b/src/main/scala/reading/models/Filter.scala index 00c7994..5aabcc6 100644 --- a/src/main/scala/reading/models/Filter.scala +++ b/src/main/scala/reading/models/Filter.scala @@ -38,7 +38,7 @@ object FilterFactory { implicit object PeriodFilter extends FilterFactory[Period] { def create(period: Period): Filter = new Filter { - def filter(book: Book): Boolean = book.period == period + def filter(book: Book): Boolean = book.period == Some(period) val kind: FilterKind = PeriodKind val name: String = period.toString() } @@ -79,4 +79,13 @@ object FilterFactory { val name: String = grade.toString() } } + + implicit object LevelFilter extends FilterFactory[Level] { + def create(level: Level): Filter = + new Filter { + def filter(book: Book): Boolean = book.level == level + val kind: FilterKind = LevelKind + val name: String = level.toString() + } + } } diff --git a/src/main/scala/reading/models/Genre.scala b/src/main/scala/reading/models/Genre.scala index 1b4aabd..44f96cd 100644 --- a/src/main/scala/reading/models/Genre.scala +++ b/src/main/scala/reading/models/Genre.scala @@ -18,6 +18,8 @@ sealed trait Genre extends EnumEntry with Ordered[Genre] { case Merveilleux => "merveilleux" case SF => "SF" case BD => "BD" + case RomanAventure => "roman d'aventure" + case Comique => "comique" } } @@ -32,4 +34,6 @@ object Genre extends Enum[Genre] { case object Merveilleux extends Genre case object SF extends Genre case object BD extends Genre + case object RomanAventure extends Genre + case object Comique extends Genre } diff --git a/src/main/scala/reading/models/Level.scala b/src/main/scala/reading/models/Level.scala index c297912..ebec020 100644 --- a/src/main/scala/reading/models/Level.scala +++ b/src/main/scala/reading/models/Level.scala @@ -1,22 +1,25 @@ package reading.models -object Level { - val filters: Seq[Filter] = - Seq( - new Filter { - def filter(book: Book): Boolean = book.pages < 200 - val kind: FilterKind = LevelKind - val name: String = "facile" - }, - new Filter { - def filter(book: Book): Boolean = book.pages >= 200 && book.pages < 400 - val kind: FilterKind = LevelKind - val name: String = "moyen" - }, - new Filter { - def filter(book: Book): Boolean = book.pages > 400 - val kind: FilterKind = LevelKind - val name: String = "difficile" - } - ) +import enumeratum._ + +sealed trait Level extends EnumEntry with Ordered[Level] { + import Level._ + + def compare(that: Level): Int = { + values.indexOf(that) - values.indexOf(this) + } + + override def toString(): String = this match { + case Facile => "facile" + case Moyen => "moyen" + case Difficile => "difficile" + } +} + +object Level extends Enum[Level] { + val values = findValues + + case object Facile extends Level + case object Moyen extends Level + case object Difficile extends Level } diff --git a/src/main/scala/reading/models/Period.scala b/src/main/scala/reading/models/Period.scala index 0dfa3bf..8500591 100644 --- a/src/main/scala/reading/models/Period.scala +++ b/src/main/scala/reading/models/Period.scala @@ -9,6 +9,8 @@ sealed trait Period extends EnumEntry { case Louis14 => "Louis XIV" case Siecle19 => "19ème siècle" case Siecle20 => "20ème siècle" + case Annees50 => "années 50" + case Contemporain => "contemporain" } } @@ -18,4 +20,6 @@ object Period extends Enum[Period] { case object Louis14 extends Period case object Siecle19 extends Period case object Siecle20 extends Period + case object Annees50 extends Period + case object Contemporain extends Period } diff --git a/src/main/scala/reading/models/Theme.scala b/src/main/scala/reading/models/Theme.scala index d816f1c..238a29d 100644 --- a/src/main/scala/reading/models/Theme.scala +++ b/src/main/scala/reading/models/Theme.scala @@ -39,6 +39,12 @@ sealed trait Theme extends EnumEntry with Ordered[Theme] { case Peur => "peur" case Pirate => "pirate" case Rivalite => "rivalité" + case SegregationRaciale => "ségrégation raciale" + case VieNocturne => "vie nocturne" + case Voyage => "voyage" + case Animaux => "animaux" + case College => "collège" + case Maladie => "maladie" } } @@ -74,4 +80,10 @@ object Theme extends Enum[Theme] { case object Peur extends Theme case object Pirate extends Theme case object Rivalite extends Theme + case object SegregationRaciale extends Theme + case object VieNocturne extends Theme + case object Voyage extends Theme + case object Animaux extends Theme + case object College extends Theme + case object Maladie extends Theme } |