Upgrade everything to 0.18
This commit is contained in:
35
Main.elm
35
Main.elm
@@ -6,14 +6,12 @@ have everything set up properly.
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.App as Html
|
||||
import Auth
|
||||
import Http
|
||||
import Task exposing (Task)
|
||||
import Json.Decode exposing (Decoder)
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = view
|
||||
@@ -35,10 +33,13 @@ type alias Model =
|
||||
|
||||
searchFeed : Cmd Msg
|
||||
searchFeed =
|
||||
Auth.token
|
||||
|> (++) "https://api.github.com/search/repositories?q=test&access_token="
|
||||
|> Http.get (Json.Decode.succeed "")
|
||||
|> Task.perform ItFailed (\_ -> ItWorked)
|
||||
let
|
||||
url =
|
||||
"https://api.github.com/search/repositories?q=test&access_token=" ++ Auth.token
|
||||
in
|
||||
Json.Decode.succeed ()
|
||||
|> Http.get url
|
||||
|> Http.send Response
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
@@ -57,17 +58,16 @@ view model =
|
||||
|
||||
|
||||
type Msg
|
||||
= ItWorked
|
||||
| ItFailed Http.Error
|
||||
= Response (Result Http.Error ())
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
ItWorked ->
|
||||
Response (Ok ()) ->
|
||||
( { status = "You're all set!" }, Cmd.none )
|
||||
|
||||
ItFailed err ->
|
||||
Response (Err err) ->
|
||||
let
|
||||
status =
|
||||
case err of
|
||||
@@ -77,18 +77,21 @@ update msg model =
|
||||
Http.NetworkError ->
|
||||
"Network error. Check your Internet connection?"
|
||||
|
||||
Http.UnexpectedPayload msg ->
|
||||
Http.BadUrl url ->
|
||||
"Invalid test URL: " ++ url
|
||||
|
||||
Http.BadPayload msg _ ->
|
||||
"Something is misconfigured: " ++ msg
|
||||
|
||||
Http.BadResponse code msg ->
|
||||
case code of
|
||||
Http.BadStatus { status } ->
|
||||
case status.code of
|
||||
401 ->
|
||||
"Auth.elm does not have a valid token. :( Try recreating Auth.elm by following the steps in the README under the section “Create a GitHub Personal Access Token”."
|
||||
|
||||
_ ->
|
||||
"GitHub's Search API returned an error: "
|
||||
++ (toString code)
|
||||
++ (toString status.code)
|
||||
++ " "
|
||||
++ msg
|
||||
++ status.message
|
||||
in
|
||||
( { status = status }, Cmd.none )
|
||||
|
||||
@@ -3,7 +3,7 @@ Getting Started
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install [Node.js](http://nodejs.org) 4.0.0 or higher
|
||||
1. Install [Node.js](http://nodejs.org) 6.9.2 or higher
|
||||
|
||||
2. Add a plugin for your editor of choice: [Atom](https://atom.io/packages/language-elm), [Sublime Text](https://packagecontrol.io/packages/Elm%20Language%20Support), [VS Code](https://github.com/sbrink/vscode-elm), [Light Table](https://github.com/rundis/elm-light), [Vim](https://github.com/lambdatoast/elm.vim), [Emacs](https://github.com/jcollard/elm-mode), [Brackets](https://github.com/lepinay/elm-brackets)
|
||||
|
||||
@@ -12,12 +12,9 @@ Getting Started
|
||||
4. Run the following command to install everything else:
|
||||
|
||||
```bash
|
||||
npm install -g elm elm-test elm-css elm-live@2.5.0
|
||||
npm install -g elm elm-test elm-css elm-live@2.6.1
|
||||
```
|
||||
|
||||
**Note to Windows 10 users running Bash:** There is [a bug in Windows Bash](https://github.com/Microsoft/BashOnWindows/issues/307) which will mess up the installers. This does not affect the normal Windows terminal, so if you use it instead of Windows Bash, you should be fine!
|
||||
|
||||
**Note to OS X users:** If step 4 gives you an `EACCESS` error on OS X, try [this fix](https://docs.npmjs.com/getting-started/fixing-npm-permissions):
|
||||
**Note to macOS users:** If step 4 gives you an `EACCESS` error, try [this fix](https://docs.npmjs.com/getting-started/fixing-npm-permissions):
|
||||
|
||||
|
||||
```
|
||||
|
||||
@@ -3,7 +3,6 @@ port module ElmHub exposing (..)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
|
||||
import Html.Events exposing (..)
|
||||
import Html.App as Html
|
||||
import Auth
|
||||
import Json.Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (..)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import ElmHub
|
||||
import Html.App as Html
|
||||
import Html
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never ElmHub.Model ElmHub.Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = ElmHub.view
|
||||
|
||||
@@ -37,4 +37,4 @@ Then visit [localhost:8000](http://localhost:8000) and choose `HtmlRunner.elm`.
|
||||
|
||||
## References
|
||||
|
||||
* [Html.map](http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html-App#map)
|
||||
* [Html.map](http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html#map)
|
||||
|
||||
@@ -6,11 +6,11 @@ import Test.Runner.Html as Runner
|
||||
|
||||
-- To run this:
|
||||
--
|
||||
-- cd into part8/test
|
||||
-- cd into part10/test
|
||||
-- elm-reactor
|
||||
-- navigate to HtmlRunner.elm
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Runner.run Tests.all
|
||||
|
||||
@@ -3,7 +3,6 @@ port module ElmHub exposing (..)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
|
||||
import Html.Events exposing (..)
|
||||
import Html.App as Html
|
||||
import Auth
|
||||
import Json.Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (..)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import ElmHub
|
||||
import Html.App as Html
|
||||
import Html
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never ElmHub.Model ElmHub.Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = ElmHub.view
|
||||
|
||||
@@ -3,7 +3,6 @@ port module ElmHub exposing (..)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
|
||||
import Html.Events exposing (..)
|
||||
import Html.App as Html
|
||||
import Html.Lazy exposing (lazy, lazy3)
|
||||
import Auth
|
||||
import Json.Decode exposing (Decoder)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import ElmHub
|
||||
import Html.App as Html
|
||||
import Html
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never ElmHub.Model ElmHub.Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = ElmHub.view
|
||||
|
||||
@@ -3,7 +3,6 @@ port module ElmHub exposing (..)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
|
||||
import Html.Events exposing (..)
|
||||
import Html.App as Html
|
||||
import Html.Lazy exposing (lazy, lazy3)
|
||||
import Auth
|
||||
import Json.Decode exposing (Decoder)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import ElmHub
|
||||
import Html.App as Html
|
||||
import Html
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never ElmHub.Model ElmHub.Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = ElmHub.view
|
||||
|
||||
@@ -3,7 +3,6 @@ port module Stylesheets exposing (..)
|
||||
import Css.File exposing (..)
|
||||
import ElmHubCss
|
||||
import Html exposing (div)
|
||||
import Html.App as Html
|
||||
|
||||
|
||||
port files : CssFileStructure -> Cmd msg
|
||||
@@ -14,7 +13,7 @@ cssFiles =
|
||||
toFileStructure [ ( "style.css", compile [ ElmHubCss.css ] ) ]
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Html.program
|
||||
{ init = ( (), files cssFiles )
|
||||
|
||||
@@ -3,7 +3,7 @@ port module ElmHub exposing (..)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, defaultValue, type_, checked, placeholder, value)
|
||||
import Html.Events exposing (..)
|
||||
import Html.App as Html
|
||||
|
||||
import Html.Lazy exposing (lazy, lazy3)
|
||||
import Auth
|
||||
import Json.Decode exposing (Decoder)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import ElmHub
|
||||
import Html.App as Html
|
||||
import Html
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never ElmHub.Model ElmHub.Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = ElmHub.view
|
||||
|
||||
@@ -3,7 +3,7 @@ port module Stylesheets exposing (..)
|
||||
import Css.File exposing (..)
|
||||
import ElmHubCss
|
||||
import Html exposing (div)
|
||||
import Html.App as Html
|
||||
|
||||
|
||||
port files : CssFileStructure -> Cmd msg
|
||||
|
||||
@@ -13,7 +13,7 @@ cssFiles =
|
||||
toFileStructure [ ( "style.css", compile [ ElmHubCss.css ] ) ]
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Html.program
|
||||
{ init = ( (), files cssFiles )
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module Main exposing (..)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.App as Html
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module Main exposing (..)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.App as Html
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module Main exposing (..)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.App as Html
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick, onInput)
|
||||
|
||||
@@ -98,7 +97,7 @@ update msg model =
|
||||
model
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Html.beginnerProgram
|
||||
{ view = view
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module Main exposing (..)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.App as Html
|
||||
import Html.Attributes exposing (class, target, href, property, defaultValue)
|
||||
import Html.Events exposing (..)
|
||||
import Json.Decode exposing (..)
|
||||
@@ -9,7 +8,7 @@ import Json.Decode.Pipeline exposing (..)
|
||||
import SampleResponse
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Html.beginnerProgram
|
||||
{ view = view
|
||||
|
||||
@@ -5,13 +5,11 @@ import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, property, defaultValue)
|
||||
import Html.Events exposing (..)
|
||||
import Http
|
||||
import Html.App as Html
|
||||
import Task exposing (Task)
|
||||
import Json.Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (..)
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = view
|
||||
@@ -32,17 +30,13 @@ searchFeed query =
|
||||
++ "+language:elm&sort=stars&order=desc"
|
||||
|
||||
-- HINT: responseDecoder may be useful here.
|
||||
task =
|
||||
"TODO replace this String with a Task using http://package.elm-lang.org/packages/evancz/elm-http/latest/Http#get"
|
||||
request =
|
||||
"TODO replace this String with a Request built using http://package.elm-lang.org/packages/elm-lang/http/latest/Http#get"
|
||||
in
|
||||
-- TODO replace this Cmd.none with a call to Task.perform
|
||||
-- http://package.elm-lang.org/packages/elm-lang/core/latest/Task#perform
|
||||
-- TODO replace this Cmd.none with a call to Http.send
|
||||
-- http://package.elm-lang.org/packages/elm-lang/http/latest/Http#send
|
||||
--
|
||||
-- HINT: pass these to Task.perform, but in a different order than this!
|
||||
--
|
||||
-- task
|
||||
-- HandleSearchResponse
|
||||
-- HandleSearchError
|
||||
-- HINT: request and HandleSearchResponse may be useful here.
|
||||
Cmd.none
|
||||
|
||||
|
||||
@@ -120,8 +114,7 @@ type Msg
|
||||
= Search
|
||||
| SetQuery String
|
||||
| DeleteById Int
|
||||
| HandleSearchResponse (List SearchResult)
|
||||
| HandleSearchError Http.Error
|
||||
| HandleSearchResponse (Result Http.Error (List SearchResult))
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
@@ -130,17 +123,19 @@ update msg model =
|
||||
Search ->
|
||||
( model, searchFeed model.query )
|
||||
|
||||
HandleSearchResponse results ->
|
||||
HandleSearchResponse result ->
|
||||
case result of
|
||||
Ok results ->
|
||||
( { model | results = results }, Cmd.none )
|
||||
|
||||
HandleSearchError error ->
|
||||
Err error ->
|
||||
-- TODO if decoding failed, store the message in model.errorMessage
|
||||
--
|
||||
-- HINT 1: Remember, model.errorMessage is a Maybe String - so it
|
||||
-- can only be set to either Nothing or (Just "some string here")
|
||||
--
|
||||
-- Hint 2: look for "decode" in the documentation for this union type:
|
||||
-- http://package.elm-lang.org/packages/evancz/elm-http/latest/Http#Error
|
||||
-- http://package.elm-lang.org/packages/elm-lang/http/latest/Http#Error
|
||||
--
|
||||
-- Hint 3: to check if this is working, break responseDecoder
|
||||
-- by changing "stargazers_count" to "description"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
port module Main exposing (..)
|
||||
|
||||
import Html.App as Html
|
||||
import Json.Decode exposing (..)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, property, defaultValue)
|
||||
@@ -10,7 +9,7 @@ import Json.Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (..)
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = view
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import ElmHub
|
||||
import Html.App as Html
|
||||
import Html
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never ElmHub.Model ElmHub.Msg
|
||||
main =
|
||||
Html.program
|
||||
{ view = ElmHub.view
|
||||
|
||||
@@ -6,11 +6,11 @@ import Test.Runner.Html as Runner
|
||||
|
||||
-- To run this:
|
||||
--
|
||||
-- cd into part8/test
|
||||
-- cd into part9/test
|
||||
-- elm-reactor
|
||||
-- navigate to HtmlRunner.elm
|
||||
|
||||
|
||||
main : Program Never
|
||||
main : Program Never Model Msg
|
||||
main =
|
||||
Runner.run Tests.all
|
||||
|
||||
Reference in New Issue
Block a user