~ben/aurelius

c5e36d6e11965221b1d3d3440ce79e49ab72a956 — Ben Sima 3 years ago 3c292db
Personalize the quote list

Next step: store this in local storage and allow the user to customize it
2 files changed, 46 insertions(+), 0 deletions(-)

M src/Main.elm
M src/Routing.elm
M src/Main.elm => src/Main.elm +44 -0
@@ 10,6 10,7 @@ import Random
import RemoteData exposing (RemoteData(..), WebData)
import RemoteData.Infix exposing (..)
import Routing exposing (parseLocation, Route(..))
import Set
import Types exposing (..)




@@ 120,6 121,9 @@ view model =
        QuoteRoute book section ->
            shoveWebData (Quote.view model.route) model.quotes

        Ben ->
            model.quotes
                |> shoveWebData (List.filterMap isaFav >> List.map Quote.view_ >> div [])

wrap : Html Msg -> Html Msg
wrap kids =


@@ 157,3 161,43 @@ navbar =
                [ text "GitHub" ]
            ]
        ]


isaFav : Quote -> Maybe Quote
isaFav quote =
    if Set.member ( quote.book, quote.section ) bensFavs
    then Just quote
    else Nothing


bensFavs : Set.Set ( Int, Int )
bensFavs =
    Set.fromList
        [ ( 2, 1 )
        , ( 2, 5 )
        , ( 3, 5 )
        , ( 3, 10 )
        , ( 4, 7 )
        , ( 5, 1 )
        , ( 5, 20 )
        , ( 5, 22 )
        , ( 5, 37 )
        , ( 6, 2 )
        , ( 6, 6 )
        , ( 6, 13 )
        , ( 6, 39 )
        , ( 6, 45 )
        , ( 6, 48 )
        , ( 6, 53 )
        , ( 7, 22 )
        , ( 7, 59 )
        , ( 7, 69 )
        , ( 9, 4 )
        , ( 9, 5 )
        , ( 9, 40 )
        , ( 10, 1 )
        , ( 10, 16 )
        , ( 10, 27 )
        , ( 10, 29 )
        , ( 11, 7 )
        ]

M src/Routing.elm => src/Routing.elm +2 -0
@@ 8,6 8,7 @@ type Route
    | Index
    | AllQuotes
    | NotFoundRoute
    | Ben


matchers : Parser (Route -> a) a


@@ 16,6 17,7 @@ matchers =
        [ map QuoteRoute  ( int </> int)
        , map AllQuotes (s "all")
        , map Index top
        , map Ben (s "ben")
        ]