diff --git a/part1/src/Page/Home.elm b/part1/src/Page/Home.elm index e86e37f..f3a2474 100644 --- a/part1/src/Page/Home.elm +++ b/part1/src/Page/Home.elm @@ -6,7 +6,7 @@ import Html.Attributes exposing (attribute, class, classList, href, id, placehol page = div [ class "home-page" ] - [ p [] [ text "TODO: Replace this

with the banner" ] + [ banner , div [ class "container page" ] [ div [ class "row" ] [ div [ class "col-md-9" ] [ feed ] @@ -17,22 +17,11 @@ page = banner = - {- TODO Add a logo and tagline to this banner, so its structure becomes: - -

- - HINT 1: the
above is an element with 2 child nodes. - - HINT 2: the
below is an element with text. - -} div [ class "banner" ] [ div [ class "container" ] - [ text "TODO: Put a

here instead of this text, then add a

right after the

" ] + [ h1 [ class "logo-font" ] [ text "conduit" ] + , p [] [ text "A place to share your knowledge." ] + ] ] diff --git a/part2/src/Page/Home.elm b/part2/src/Page/Home.elm index 698781e..b8ed077 100644 --- a/part2/src/Page/Home.elm +++ b/part2/src/Page/Home.elm @@ -13,9 +13,7 @@ view tags = , div [ class "col-md-3" ] [ div [ class "sidebar" ] [ p [] [ text "Popular Tags" ] - - -- TODO instead of passing [] to viewTags, pass the actual tags - , viewTags [] + , viewTags tags ] ] ] @@ -26,18 +24,14 @@ view tags = viewTags tags = let renderedTags = - -- TODO use `List.map` and `viewTag` to render the tags - [] + -- List.map (\tag -> viewTag tag) tags + List.map viewTag tags in div [ class "tag-list" ] renderedTags viewTag tagName = - {- TODO render something like this: - - - -} - button [] [] + button [ class "tag-pill tag-default" ] [ text tagName ] viewBanner = diff --git a/part3/src/Page/Home.elm b/part3/src/Page/Home.elm index 1299a47..22407a5 100644 --- a/part3/src/Page/Home.elm +++ b/part3/src/Page/Home.elm @@ -12,7 +12,7 @@ import Html.Events exposing (onClick) initialModel = - { tags = [ "foo", "bar", "dragons" ] + { tags = [ "foo", "bar", "baz", "dragons", "tag name goes here" ] , selectedTag = "" } @@ -23,13 +23,7 @@ initialModel = update msg model = if msg.operation == "SELECT_TAG" then - {- TODO Return `model` with the `selectedTag` field set to `msg.data` - - HINT: Record update syntax looks like this: - - { model | foo = bar } - -} - model + { model | selectedTag = msg.data } else model @@ -66,28 +60,15 @@ viewBanner = viewTag selectedTagName tagName = let - {- TODO Set the classname to "tag-pill tag-selected" only when the - current tagName is equal to the selected one. - -} classname = - if False then + if tagName == selectedTagName then "tag-pill tag-selected" else "tag-pill tag-default" in - {- TODO add an onClick handler here which selects `tagName` - - HINT: Take look at `update` above, to check what it expects `msg` - to be. It will look something like this: - - button - [ class classname - , onClick { operation = "SOMETHING", data = "tag name goes here" } - ] - [ text tagName ] - -} button [ class classname + , onClick { operation = "SELECT_TAG", data = tagName } ] [ text tagName ] diff --git a/part4/src/Page/Home.elm b/part4/src/Page/Home.elm index 0f99930..53fa30c 100644 --- a/part4/src/Page/Home.elm +++ b/part4/src/Page/Home.elm @@ -27,8 +27,7 @@ type alias Model = -- MODEL -- -{-| TODO add a type annotation to initialModel --} +initialModel : Model initialModel = { tags = [ "foo", "bar", "dragons" ] , selectedTag = "" @@ -49,8 +48,7 @@ viewBanner = ] -{-| TODO add a type annotation to view --} +view : Model -> Html Msg view model = div [ class "home-page" ] [ viewBanner @@ -72,8 +70,7 @@ view model = ] -{-| TODO add a type annotation to viewTag --} +viewTag : String -> String -> Html Msg viewTag selectedTagName tagName = let classname = @@ -93,8 +90,7 @@ viewTag selectedTagName tagName = -- UPDATE -- -{-| TODO add a type annotation to update --} +update : Msg -> Model -> Model update msg model = if msg.operation == "SELECT_TAG" then { model | selectedTag = msg.data } diff --git a/part5/src/Page/Article/Editor.elm b/part5/src/Page/Article/Editor.elm index a05e76c..8e9635d 100644 --- a/part5/src/Page/Article/Editor.elm +++ b/part5/src/Page/Article/Editor.elm @@ -99,18 +99,9 @@ viewForm model = Html.form [ onSubmit Save ] [ fieldset [] [ Form.input - {- TODO Sign up for an account (you can enter nonsense for all - the signup fields) and then click `New Post` in the header to - view the Article Editor. - - When the user enters some input for Article Title, - we want to update the `title` field in the Model. - - HINT: We'll need to add something to the definition of Msg to - do this. Look at how SetDescription is used in the next field! - -} [ class "form-control-lg" , placeholder "Article Title" + , onInput SetTitle , value model.title ] [] @@ -146,6 +137,7 @@ viewForm model = type Msg = Save | SetDescription String + | SetTitle String | SetBody String | SetTags String | CreateCompleted (Result Http.Error (Article Body)) @@ -174,13 +166,9 @@ update user msg model = errors -> ( { model | errors = errors }, Cmd.none ) - ------------------------------------------------------------------------ - -- -- - -- TODO add something here that sets the title based on user input. -- - -- -- - -- HINT: take a look at how SetDescription does something similar! -- - -- -- - ------------------------------------------------------------------------ + SetTitle title -> + ( { model | title = title }, Cmd.none ) + SetDescription description -> ( { model | description = description }, Cmd.none ) diff --git a/part6/src/Page/Profile.elm b/part6/src/Page/Profile.elm index 24f9130..0225a7f 100644 --- a/part6/src/Page/Profile.elm +++ b/part6/src/Page/Profile.elm @@ -75,25 +75,20 @@ view session model = loggedInUser = session.user - {- TODO figure out if this is the loggedInUser's profile - or not, based on whether that user's username matches this - profile's username. - - HINT: The type of Maybe is: - - type Maybe val - = Just val - | Nothing - -} isMyProfile = - False + case loggedInUser of + Just user -> + profile.username == user.username + + Nothing -> + True in div [ class "profile-page" ] [ Errors.view DismissErrors model.errors , div [ class "user-info" ] [ div [ class "container" ] [ div [ class "row" ] - [ viewProfileInfo profile ] + [ viewProfileInfo isMyProfile profile ] ] ] , div [ class "container" ] @@ -101,18 +96,8 @@ view session model = ] -viewProfileInfo : Profile -> Html Msg -viewProfileInfo profile = - let - {- TODO delete this hardcoded isMyProfile declaration, and have - viewProfileInfo accept isMyProfile as an argument instead. - - HINT: The module will no longer compile after this change! Follow - the compiler's error messages to resolve this. - -} - isMyProfile = - False - in +viewProfileInfo : Bool -> Profile -> Html Msg +viewProfileInfo isMyProfile profile = div [ class "col-xs-12 col-md-10 offset-md-1" ] [ img [ class "user-img", UserPhoto.src profile.image ] [] , h4 [] [ User.usernameToHtml profile.username ] diff --git a/server/data/articles.db b/server/data/articles.db index 2372986..f63d96f 100644 --- a/server/data/articles.db +++ b/server/data/articles.db @@ -1,5 +1,6 @@ -{"title":"Elm is fun!","description":"Elm","body":"I've really been enjoying it!","tagList":["elm","fun"],"slug":"elm-is-fun--zb6nba","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523441276},"updatedAt":{"$$date":1525523441276},"_id":"AfnCDbXe6wi8Vg8C"} +{"title":"this is my title","description":"this is just a test","body":"Hello World!","tagList":[],"slug":"this-is-my-title-ladzo0","author":"gsZdyqSGbQscoIU6","createdAt":{"$$date":1525546112100},"updatedAt":{"$$date":1525546112100},"_id":"9kCKBGvHDiWaDSjj"} {"title":"Elm is fun!","description":"Programming","body":"I've really been enjoying it!","tagList":["elm","fun"],"slug":"elm-is-fun--zb6nba","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523441276},"updatedAt":{"$$date":1525523455652},"_id":"AfnCDbXe6wi8Vg8C"} {"title":"Who says undefined isn't a function anyway?","description":"Functions","body":"Quite frankly I think undefined can be anything it wants to be, if it believes in itself.","tagList":["programming"],"slug":"who-says-undefined-isnt-a-function-anyway-t39ope","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523547620},"updatedAt":{"$$date":1525523547620},"_id":"CDCDlBclmwWpWdCX"} -{"title":"This compiler is pretty neat","description":"Elm","body":"It tells me about problems in my code. How neat is that?","tagList":["compilers","elm"],"slug":"this-compiler-is-pretty-neat-9ycui8","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523694805},"updatedAt":{"$$date":1525523694805},"_id":"ttAbrJu6OrOJ7jAf"} {"title":"Are dragons real?","description":"dragons","body":"Do Komodo Dragons count? I think they should. It's right there in the name!","tagList":["dragons"],"slug":"are-dragons-real-467lsh","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523750396},"updatedAt":{"$$date":1525523750396},"_id":"I2h7s1VuXciCP5nl"} +{"title":"Hello World","description":"stuff","body":"this is not port 8000","tagList":[],"slug":"hello-world-dwkkns","author":"gsZdyqSGbQscoIU6","createdAt":{"$$date":1525547607765},"updatedAt":{"$$date":1525547607765},"_id":"fiusiOt77z4zbKe8"} +{"title":"This compiler is pretty neat","description":"Elm","body":"It tells me about problems in my code. How neat is that?","tagList":["compilers","elm"],"slug":"this-compiler-is-pretty-neat-9ycui8","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523694805},"updatedAt":{"$$date":1525523694805},"_id":"ttAbrJu6OrOJ7jAf"} diff --git a/server/data/follows.db b/server/data/follows.db index e69de29..1d9b162 100644 --- a/server/data/follows.db +++ b/server/data/follows.db @@ -0,0 +1 @@ +{"follow":"Z1YiwpVIz2GQQ13Q","user":"gsZdyqSGbQscoIU6","createdAt":{"$$date":1525550850919},"_id":"f8Yep9EguoPa8Rwn"} diff --git a/server/data/users.db b/server/data/users.db index d1c44ca..b9f16d9 100644 --- a/server/data/users.db +++ b/server/data/users.db @@ -1,2 +1,2 @@ -{"username":"SamSample","email":"sam@sample.com","password":"$2a$10$6bury.WsF0p7chmqoqQc..S5HZ6qPK/KuqVfXxBjSasmDPxF3fj3W","bio":"","image":null,"createdAt":{"$$date":1525523183044},"_id":"Z1YiwpVIz2GQQ13Q"} {"username":"SamSample","email":"sam@sample.com","password":"samsample","bio":"I'm the sample user for the workshop. Hi!","image":"https://user-images.githubusercontent.com/1094080/39663282-6459c64e-503e-11e8-8da8-a2af2c81d052.png","createdAt":{"$$date":1525523183044},"_id":"Z1YiwpVIz2GQQ13Q","updatedAt":{"$$date":1525523378471}} +{"username":"wefjbsfdjkhdgrskjhsdfgjhb","email":"sdfgjhsgjhbdfgkjhsdf@sfgdhjfjhgdfgf.com","password":"$2a$10$gnFdddybmitDP.yKM3OjfubgZ1O3geK9N8LymFV4mZYaSGe9WYPby","bio":"","image":null,"createdAt":{"$$date":1525546056406},"_id":"gsZdyqSGbQscoIU6"}