From 6a3891959e7e2e5c9d2408abef07280f7224ad19 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 3 Sep 2016 00:09:51 -0700 Subject: [PATCH] Delete final --- final/ElmHub.elm | 138 ----------------------------------------- final/ElmHub/Css.elm | 14 ----- final/Main.elm | 14 ----- final/README.md | 30 --------- final/SearchResult.elm | 55 ---------------- final/Stylesheets.elm | 10 --- final/elm-hub.png | Bin 2126 -> 0 bytes final/elm-package.json | 19 ------ final/index.html | 20 ------ final/style.css | 6 -- 10 files changed, 306 deletions(-) delete mode 100644 final/ElmHub.elm delete mode 100644 final/ElmHub/Css.elm delete mode 100644 final/Main.elm delete mode 100644 final/README.md delete mode 100644 final/SearchResult.elm delete mode 100644 final/Stylesheets.elm delete mode 100644 final/elm-hub.png delete mode 100644 final/elm-package.json delete mode 100644 final/index.html delete mode 100644 final/style.css diff --git a/final/ElmHub.elm b/final/ElmHub.elm deleted file mode 100644 index 8a62be7..0000000 --- a/final/ElmHub.elm +++ /dev/null @@ -1,138 +0,0 @@ -module ElmHub exposing (..) - -import Html exposing (..) -import Html.Attributes exposing (..) -import Html.Events exposing (..) -import Html.App as Html -import Http -import Auth -import Task exposing (Task) -import Json.Decode exposing (Decoder) -import Dict exposing (Dict) -import SearchResult - - -searchFeed : String -> Cmd Msg -searchFeed query = - let - url = - "https://api.github.com/search/repositories?access_token=" - ++ Auth.token - ++ "&q=" - ++ query - ++ "+language:elm&sort=stars&order=desc" - in - Task.perform HandleSearchError HandleSearchResponse (Http.get responseDecoder url) - - -responseDecoder : Decoder (List SearchResult.Model) -responseDecoder = - Json.Decode.at [ "items" ] (Json.Decode.list SearchResult.decoder) - - -type alias Model = - { query : String - , results : Dict Int SearchResult.Model - , errorMessage : Maybe String - } - - -initialModel : Model -initialModel = - { query = "tutorial" - , results = Dict.empty - , errorMessage = Nothing - } - - -view : Model -> Html Msg -view model = - div [ class "content" ] - [ header [] - [ h1 [] [ text "ElmHub" ] - , span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ] - ] - , input [ class "search-query", onInput SetQuery, defaultValue model.query ] [] - , button [ class "search-button", onClick Search ] [ text "Search" ] - , viewErrorMessage model.errorMessage - , ul [ class "results" ] (viewSearchResults model.results) - ] - - -viewErrorMessage : Maybe String -> Html a -viewErrorMessage errorMessage = - case errorMessage of - Just message -> - div [ class "error" ] [ text message ] - - Nothing -> - text "" - - -viewSearchResults : Dict Int SearchResult.Model -> List (Html Msg) -viewSearchResults results = - results - |> Dict.values - |> List.sortBy (.stars >> negate) - |> List.map viewSearchResult - - -viewSearchResult : SearchResult.Model -> Html Msg -viewSearchResult result = - result - |> SearchResult.view - |> Html.App.map (UpdateSearchResult result.id) - - -type Msg - = Search - | SetQuery String - | UpdateSearchResult Int SearchResult.Msg - | HandleSearchResponse (List SearchResult.Model) - | HandleSearchError Http.Error - - -update : Msg -> Model -> ( Model, Cmd Msg ) -update msg model = - case msg of - Search -> - model ! [ searchFeed model.query ] - - SetQuery query -> - { model | query = query, errorMessage = Nothing } ! [] - - HandleSearchError error -> - case error of - Http.UnexpectedPayload str -> - { model | errorMessage = Just str } ! [] - - _ -> - { model | errorMessage = Just "Error loading search results" } ! [] - - HandleSearchResponse results -> - let - resultsById : Dict Int SearchResult.Model - resultsById = - results - |> List.map (\result -> ( result.id, result )) - |> Dict.fromList - in - { model | results = resultsById } ! [] - - UpdateSearchResult id childMsg -> - case Dict.get id model.results of - Nothing -> - model ! [] - - Just childModel -> - let - ( newChildModel, childCmd ) = - SearchResult.update childMsg childModel - - cmd = - Cmd.map (UpdateSearchResult id) childCmd - - newResults = - Dict.insert id newChildModel model.results - in - { model | results = newResults } ! [ cmd ] diff --git a/final/ElmHub/Css.elm b/final/ElmHub/Css.elm deleted file mode 100644 index b897eb4..0000000 --- a/final/ElmHub/Css.elm +++ /dev/null @@ -1,14 +0,0 @@ -module ElmHub.Css exposing (..) - -import Css exposing (..) - - -css = - stylesheet - [ ((.) "content") - [ width (px 960) - , margin2 zero auto - , padding (px 30) - , fontFamilies [ "Helvetica", "Arial", "serif" ] - ] - ] diff --git a/final/Main.elm b/final/Main.elm deleted file mode 100644 index 46942db..0000000 --- a/final/Main.elm +++ /dev/null @@ -1,14 +0,0 @@ -module Main exposing (..) - -import ElmHub exposing (..) -import Html.App as Html - - -main : Program Never -main = - Html.program - { view = view - , update = update - , init = ( initialModel, searchFeed initialModel.query ) - , subscriptions = \_ -> Sub.none - } diff --git a/final/README.md b/final/README.md deleted file mode 100644 index 6d48895..0000000 --- a/final/README.md +++ /dev/null @@ -1,30 +0,0 @@ -Part 12 -======= - -The instructor will paste notes from the lesson, including code examples from -Q&A, in [this document](https://docs.google.com/document/d/1ApuSOk9DP0YsQrxhW7-WE8UOEAV4PPnLDDeqUOL2o5k/edit?usp=sharing). - -## Installation - -```bash -elm-package install -``` - -(Answer `y` when prompted.) - - -## Building - -```bash -elm-live Main.elm --open --pushstate --output=elm.js -``` - -## Compiling CSS - -```bash -elm css Stylesheets.elm -``` - -## References - -* [Elm CSS documentation](http://package.elm-lang.org/packages/rtfeldman/elm-css/1.1.0/) diff --git a/final/SearchResult.elm b/final/SearchResult.elm deleted file mode 100644 index a72972d..0000000 --- a/final/SearchResult.elm +++ /dev/null @@ -1,55 +0,0 @@ -module SearchResult exposing (..) - -import Html exposing (..) -import Html.Attributes exposing (class, target, href, property, defaultValue) -import Html.Events exposing (..) -import Json.Decode exposing (Decoder) -import Json.Decode.Pipeline exposing (..) - - -type alias Model = - { id : Int - , name : String - , stars : Int - , expanded : Bool - } - - -type Msg - = Expand - | Collapse - - -decoder : Decoder Model -decoder = - decode Model - |> required "id" Json.Decode.int - |> required "full_name" Json.Decode.string - |> required "stargazers_count" Json.Decode.int - |> hardcoded True - - -update : Msg -> Model -> ( Model, Cmd Msg ) -update msg model = - case msg of - Expand -> - { model | expanded = True } ! [] - - Collapse -> - { model | expanded = False } ! [] - - -view : Model -> Html Msg -view model = - li [] <| - if model.expanded then - [ span [ class "star-count" ] [ text (toString model.stars) ] - , a [ href ("https://github.com/" ++ model.name), target "_blank" ] - [ text model.name ] - , button [ class "hide-result", onClick Collapse ] - [ text "X" ] - ] - else - [ button [ class "expand-result", onClick Expand ] - [ text "Show" ] - ] diff --git a/final/Stylesheets.elm b/final/Stylesheets.elm deleted file mode 100644 index cef5923..0000000 --- a/final/Stylesheets.elm +++ /dev/null @@ -1,10 +0,0 @@ -module Stylesheets exposing (..) - -import Css.File exposing (..) -import ElmHub.Css - - -port files : CssFileStructure -port files = - toFileStructure - [ ( "style.css", compile ElmHub.Css.css ) ] diff --git a/final/elm-hub.png b/final/elm-hub.png deleted file mode 100644 index ba32816a8df14eb878b6e39914bf889c799673aa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2126 zcmV-U2(kBxP)WFU8GbZ8()Nlj2>E@cM*00**3L_t(o!=;ydbj?>5 z$3Of0?(g165Jo7`23@5cL{u*(iFtTbkbm9H-uPq*82VNJHLI-_xsy>fA>B|sAtSM zp1^{x2LYH{oM>pRqXqdj!cd^I-y1mKuBdR8mM*J|Y-yTigNUyJUc;*#K5_;)>)Rex zuYpoQ@J7IVM9v}1208;6rb@IoYP_mT=e{c7)x!fm-y&u6wa6LZB(3mBy#(ZbALkxV zV1CzwLGZ0WzdFn`g81BlkHP|M2jGv+kxE;e4nP4p8q7xY~ToAKcwgUhYrDEANWgSrq4chq1m2Z zZU0+t+L@#jEk*AA04;C1S$63do0=}|IVv+|Pw_(~q0O|}ugg<;uWlQ#{pKxF0{T8$ z)KGbwSu%^o+fw7R!y;@g9$E!Jw#_h}rcvzftX46 zQ^PfS`~0{A7lZxe&i+zM1^H{2kUT!a5RukEn8)KerIhl051AB7Ff^0rFdG;#nXbk(DW~ z%$*jv2XIu^99=nR%A$6Wy&JlPjRBA+2NPj4;rD0Fr^H0DCQPpEu{4=*$+wUYevt%@+}TUY&dO+{u}7 zKUwOs+3mALNhoYJn)AgOw3A{Yvv&%5fYqJ8OY(r3S>3}c2UWrQdQ zQ4;59{7CefW9m=MA1%A44Ar-qgjOJJwAO=e`{hELvlosHin^NNuro!3%SLRsUSA3f z3vpQl(41;g)!<(5iZ64Qr*~MBKhH4j(?rx=T~tI+N@5*N9&dNHsC0Hz%+)J~q56x6 zp*4|iFYiZ}o?AMGvr|n6zZan#7;D6KO(+qO4}n`iJBvV#*Zn@<(*NbYHM8T^y;(N9 zV~U8F_wKENQmT`qS&xqAKUp~=s%_*YWvXXAZk^k+q;&Bh^SgA@!C(<`fpo1oB;P9_ zGr~&7D4+>YAtF~dy|?)M=q>w}n~pFSB4Iq(&_0jnUtjM?82XD>oy|^qepIn;?`~gt zOCAe%a8qk;G#O6iJz&}kiYz3>ehWrZT7Iq7P#N4mXFto3T0BAO9BLZ zZuhQ@!xEFuWfNl$C%R=apM~0A+hSG16jx@@3$0UJnFU(=Gs_PjC`~QczbFJ;qxCCR zn1bUXa3-Xv*g?;;6r^kp$8)I#2e%a+;&LEB-zy*Re#I6Z4T3irZV|}K&LYJ%BLbKj z@cWyVpFTOY&7W6HF--e3L>#~cpeG{zLcHbyHUXPM2(<&zzze{)fVP?DkZl7#TeJ4~ zlW%){T=i)t`3q4^hTqW(lu}-w*R!eO(l_Hg``0VN5!bB>>6_N_`bxqXDyD#a86SB*J#R;%URQ zSFTHX<`_WQ&cj1MwjedVBLKXYljNL~R(Pm6sBBuA*hvv$(#3(KeBi2!%5+hWI?ZoQ2FUnkP$ga&JuvM!XqPqcPs@3Z7zZQ zI48+@xi-efp z;Y#3~CBc6KFXtpV^Cno}K@#U+5ikunWUbo|)O$VtKXD7qJ0u8@X8-^I07*qoM6N<$ Ef>T55F8}}l diff --git a/final/elm-package.json b/final/elm-package.json deleted file mode 100644 index 691c683..0000000 --- a/final/elm-package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "1.0.0", - "summary": "Like GitHub, but for Elm stuff.", - "repository": "https://github.com/rtfeldman/elm-workshop.git", - "license": "BSD-3-Clause", - "source-directories": [ - ".", - ".." - ], - "exposed-modules": [], - "dependencies": { - "NoRedInk/elm-decode-pipeline": "1.1.2 <= v < 2.0.0", - "elm-lang/core": "4.0.1 <= v < 5.0.0", - "elm-lang/html": "1.0.0 <= v < 2.0.0", - "evancz/elm-http": "3.0.1 <= v < 4.0.0", - "rtfeldman/elm-css": "3.1.0 <= v < 4.0.0" - }, - "elm-version": "0.17.0 <= v < 0.18.0" -} \ No newline at end of file diff --git a/final/index.html b/final/index.html deleted file mode 100644 index 8e8b831..0000000 --- a/final/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - ElmHub - - - - - - - - - - - - diff --git a/final/style.css b/final/style.css deleted file mode 100644 index 9d13aae..0000000 --- a/final/style.css +++ /dev/null @@ -1,6 +0,0 @@ -.content { - width: 960px; - margin: 0 auto; - padding: 30px; - font-family: Helvetica, Arial, serif; -}