Update part12
This commit is contained in:
15
part12/ElmHubCss.elm
Normal file
15
part12/ElmHubCss.elm
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
module ElmHubCss exposing (..)
|
||||||
|
|
||||||
|
import Css exposing (..)
|
||||||
|
|
||||||
|
|
||||||
|
css : Stylesheet
|
||||||
|
css =
|
||||||
|
stylesheet
|
||||||
|
[ ((.) "content")
|
||||||
|
[ width (px 960)
|
||||||
|
, margin2 zero auto
|
||||||
|
, padding (px 30)
|
||||||
|
, fontFamilies [ "Helvetica", "Arial", "serif" ]
|
||||||
|
]
|
||||||
|
]
|
||||||
122
part12/Main.elm
122
part12/Main.elm
@@ -1,14 +1,126 @@
|
|||||||
module Main exposing (..)
|
module Main exposing (..)
|
||||||
|
|
||||||
import ElmHub exposing (..)
|
import Page.Home
|
||||||
|
import Page.Repository
|
||||||
|
import Navigation
|
||||||
|
import Page exposing (Page(..))
|
||||||
|
import Tuple2
|
||||||
|
import Html exposing (Html, div, h1, header, text, span)
|
||||||
|
import Html.Attributes exposing (class)
|
||||||
import Html.App as Html
|
import Html.App as Html
|
||||||
|
|
||||||
|
|
||||||
|
type Model
|
||||||
|
= Home Page.Home.Model
|
||||||
|
| Repository Page.Repository.Model
|
||||||
|
| NotFound
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= HomeMsg Page.Home.Msg
|
||||||
|
| RepositoryMsg Page.Repository.Msg
|
||||||
|
|
||||||
|
|
||||||
main : Program Never
|
main : Program Never
|
||||||
main =
|
main =
|
||||||
Html.program
|
Navigation.program (Navigation.makeParser Page.parser)
|
||||||
{ view = view
|
{ init = init
|
||||||
|
, subscriptions = subscriptions
|
||||||
|
, view = view
|
||||||
, update = update
|
, update = update
|
||||||
, init = ( initialModel, searchFeed initialModel.query )
|
, urlUpdate = urlUpdate
|
||||||
, subscriptions = \_ -> Sub.none
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
subscriptions : Model -> Sub Msg
|
||||||
|
subscriptions model =
|
||||||
|
case model of
|
||||||
|
Home pageModel ->
|
||||||
|
Page.Home.subscriptions pageModel
|
||||||
|
|> Sub.map HomeMsg
|
||||||
|
|
||||||
|
Repository pageModel ->
|
||||||
|
-- Repository has no subscriptions, so there's nothing to translate!
|
||||||
|
Sub.none
|
||||||
|
|
||||||
|
NotFound ->
|
||||||
|
-- NotFound has no subscriptions, so there's nothing to translate!
|
||||||
|
Sub.none
|
||||||
|
|
||||||
|
|
||||||
|
init : Result String Page -> ( Model, Cmd Msg )
|
||||||
|
init result =
|
||||||
|
case result of
|
||||||
|
Ok (Page.Home) ->
|
||||||
|
Page.Home.init
|
||||||
|
|> Tuple2.mapEach Home (Cmd.map HomeMsg)
|
||||||
|
|
||||||
|
Ok (Page.Repository repoOwner repoName) ->
|
||||||
|
Page.Repository.init repoOwner repoName
|
||||||
|
|> Tuple2.mapEach Repository (Cmd.map RepositoryMsg)
|
||||||
|
|
||||||
|
Ok (Page.NotFound) ->
|
||||||
|
( NotFound, Cmd.none )
|
||||||
|
|
||||||
|
Err err ->
|
||||||
|
( NotFound, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
|
view : Model -> Html Msg
|
||||||
|
view model =
|
||||||
|
withHeader <|
|
||||||
|
case model of
|
||||||
|
Home pageModel ->
|
||||||
|
Page.Home.view pageModel
|
||||||
|
|> Html.map HomeMsg
|
||||||
|
|
||||||
|
Repository pageModel ->
|
||||||
|
Page.Repository.view pageModel
|
||||||
|
|> Html.map RepositoryMsg
|
||||||
|
|
||||||
|
NotFound ->
|
||||||
|
h1 [] [ text "Page Not Found" ]
|
||||||
|
|
||||||
|
|
||||||
|
withHeader : Html msg -> Html msg
|
||||||
|
withHeader innerContent =
|
||||||
|
div [ class "content" ]
|
||||||
|
[ header []
|
||||||
|
[ h1 [] [ text "ElmHub" ]
|
||||||
|
, span [ class "tagline" ] [ text "Like GitHub, but for Elm things." ]
|
||||||
|
]
|
||||||
|
, innerContent
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
|
update msg model =
|
||||||
|
case ( msg, model ) of
|
||||||
|
( HomeMsg pageMsg, Home pageModel ) ->
|
||||||
|
Page.Home.update pageMsg pageModel
|
||||||
|
|> Tuple2.mapEach Home (Cmd.map HomeMsg)
|
||||||
|
|
||||||
|
( RepositoryMsg pageMsg, Repository pageModel ) ->
|
||||||
|
Page.Repository.update pageMsg pageModel
|
||||||
|
|> Tuple2.mapEach Repository (Cmd.map RepositoryMsg)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
|
urlUpdate : Result String Page -> Model -> ( Model, Cmd Msg )
|
||||||
|
urlUpdate result model =
|
||||||
|
case result of
|
||||||
|
Ok (Page.Home) ->
|
||||||
|
Page.Home.init
|
||||||
|
|> Tuple2.mapEach Home (Cmd.map HomeMsg)
|
||||||
|
|
||||||
|
Ok (Page.Repository repoOwner repoName) ->
|
||||||
|
Page.Repository.init repoOwner repoName
|
||||||
|
|> Tuple2.mapEach Repository (Cmd.map RepositoryMsg)
|
||||||
|
|
||||||
|
Ok (Page.NotFound) ->
|
||||||
|
( NotFound, Cmd.none )
|
||||||
|
|
||||||
|
Err err ->
|
||||||
|
( NotFound, Cmd.none )
|
||||||
|
|||||||
26
part12/Page.elm
Normal file
26
part12/Page.elm
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
module Page exposing (..)
|
||||||
|
|
||||||
|
import Navigation
|
||||||
|
import UrlParser exposing (Parser, (</>), format, int, s, string)
|
||||||
|
import String
|
||||||
|
|
||||||
|
|
||||||
|
type Page
|
||||||
|
= Home
|
||||||
|
| Repository String String
|
||||||
|
| NotFound
|
||||||
|
|
||||||
|
|
||||||
|
pageParser : Parser (Page -> a) a
|
||||||
|
pageParser =
|
||||||
|
UrlParser.oneOf
|
||||||
|
[ format Home (s "")
|
||||||
|
, format Repository (s "repositories" </> string </> string)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
parser : Navigation.Location -> Result String Page
|
||||||
|
parser location =
|
||||||
|
location.pathname
|
||||||
|
|> String.dropLeft 1
|
||||||
|
|> UrlParser.parse identity pageParser
|
||||||
204
part12/Page/Home.elm
Normal file
204
part12/Page/Home.elm
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
port module Page.Home exposing (..)
|
||||||
|
|
||||||
|
import Html exposing (..)
|
||||||
|
import Html.Attributes exposing (class, target, href, property, defaultValue)
|
||||||
|
import Html.Events exposing (..)
|
||||||
|
import Auth
|
||||||
|
import Json.Decode exposing (Decoder)
|
||||||
|
import Json.Decode.Pipeline exposing (decode, required)
|
||||||
|
import Navigation
|
||||||
|
import Table
|
||||||
|
|
||||||
|
|
||||||
|
type alias SearchResult =
|
||||||
|
{ id : Int
|
||||||
|
, name : String
|
||||||
|
, stars : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
searchResultDecoder : Decoder SearchResult
|
||||||
|
searchResultDecoder =
|
||||||
|
decode SearchResult
|
||||||
|
|> required "id" Json.Decode.int
|
||||||
|
|> required "full_name" Json.Decode.string
|
||||||
|
|> required "stargazers_count" Json.Decode.int
|
||||||
|
|
||||||
|
|
||||||
|
getQueryString : String -> String
|
||||||
|
getQueryString query =
|
||||||
|
-- See https://developer.github.com/v3/search/#example for how to customize!
|
||||||
|
"access_token="
|
||||||
|
++ Auth.token
|
||||||
|
++ "&q="
|
||||||
|
++ query
|
||||||
|
++ "+language:elm&sort=stars&order=desc"
|
||||||
|
|
||||||
|
|
||||||
|
responseDecoder : Decoder (List SearchResult)
|
||||||
|
responseDecoder =
|
||||||
|
Json.Decode.at [ "items" ] (Json.Decode.list searchResultDecoder)
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
{ query : String
|
||||||
|
, results : List SearchResult
|
||||||
|
, errorMessage : Maybe String
|
||||||
|
, tableState : Table.State
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
initialQuery : String
|
||||||
|
initialQuery =
|
||||||
|
"tutorial"
|
||||||
|
|
||||||
|
|
||||||
|
init : ( Model, Cmd Msg )
|
||||||
|
init =
|
||||||
|
( { query = initialQuery
|
||||||
|
, results = []
|
||||||
|
, errorMessage = Nothing
|
||||||
|
, tableState = Table.initialSort "Stars"
|
||||||
|
}
|
||||||
|
, githubSearch (getQueryString initialQuery)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
view : Model -> Html Msg
|
||||||
|
view model =
|
||||||
|
div [ class "home-container" ]
|
||||||
|
[ input [ class "search-query", onInput SetQuery, defaultValue model.query ] []
|
||||||
|
, button [ class "search-button", onClick Search ] [ text "Search" ]
|
||||||
|
, viewErrorMessage model.errorMessage
|
||||||
|
, Table.view tableConfig model.tableState model.results
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
tableConfig : Table.Config SearchResult Msg
|
||||||
|
tableConfig =
|
||||||
|
Table.config
|
||||||
|
{ toId = .id >> toString
|
||||||
|
, toMsg = SetTableState
|
||||||
|
, columns = [ starsColumn, nameColumn ]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
starsColumn : Table.Column SearchResult Msg
|
||||||
|
starsColumn =
|
||||||
|
Table.veryCustomColumn
|
||||||
|
{ name = "Stars"
|
||||||
|
, viewData = viewStars
|
||||||
|
, sorter = Table.increasingOrDecreasingBy (negate << .stars)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nameColumn : Table.Column SearchResult Msg
|
||||||
|
nameColumn =
|
||||||
|
Table.veryCustomColumn
|
||||||
|
{ name = "Name"
|
||||||
|
, viewData = viewSearchResult
|
||||||
|
, sorter = Table.increasingOrDecreasingBy .name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
viewErrorMessage : Maybe String -> Html a
|
||||||
|
viewErrorMessage errorMessage =
|
||||||
|
case errorMessage of
|
||||||
|
Just message ->
|
||||||
|
div [ class "error" ] [ text message ]
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
text ""
|
||||||
|
|
||||||
|
|
||||||
|
viewStars : SearchResult -> Table.HtmlDetails Msg
|
||||||
|
viewStars result =
|
||||||
|
Table.HtmlDetails []
|
||||||
|
[ span [ class "star-count" ] [ text (toString result.stars) ] ]
|
||||||
|
|
||||||
|
|
||||||
|
viewSearchResult : SearchResult -> Table.HtmlDetails Msg
|
||||||
|
viewSearchResult result =
|
||||||
|
Table.HtmlDetails []
|
||||||
|
[ a [ onClick (Visit ("/repositories/" ++ result.name)) ] [ text result.name ]
|
||||||
|
, button [ class "hide-result", onClick (DeleteById result.id) ]
|
||||||
|
[ text "X" ]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= Search
|
||||||
|
| Visit String
|
||||||
|
| SetQuery String
|
||||||
|
| DeleteById Int
|
||||||
|
| HandleSearchResponse (List SearchResult)
|
||||||
|
| HandleSearchError (Maybe String)
|
||||||
|
| SetTableState Table.State
|
||||||
|
| DoNothing
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
|
update msg model =
|
||||||
|
case msg of
|
||||||
|
Visit url ->
|
||||||
|
( model, Navigation.newUrl url )
|
||||||
|
|
||||||
|
Search ->
|
||||||
|
( model, githubSearch (getQueryString model.query) )
|
||||||
|
|
||||||
|
SetQuery query ->
|
||||||
|
( { model | query = query }, Cmd.none )
|
||||||
|
|
||||||
|
HandleSearchResponse results ->
|
||||||
|
( { model | results = results }, Cmd.none )
|
||||||
|
|
||||||
|
HandleSearchError error ->
|
||||||
|
( { model | errorMessage = error }, Cmd.none )
|
||||||
|
|
||||||
|
DeleteById idToHide ->
|
||||||
|
let
|
||||||
|
newResults =
|
||||||
|
model.results
|
||||||
|
|> List.filter (\{ id } -> id /= idToHide)
|
||||||
|
|
||||||
|
newModel =
|
||||||
|
{ model | results = newResults }
|
||||||
|
in
|
||||||
|
( newModel, Cmd.none )
|
||||||
|
|
||||||
|
SetTableState newState ->
|
||||||
|
( { model | tableState = newState }, Cmd.none )
|
||||||
|
|
||||||
|
DoNothing ->
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
|
decodeGithubResponse : Json.Decode.Value -> Msg
|
||||||
|
decodeGithubResponse value =
|
||||||
|
case Json.Decode.decodeValue responseDecoder value of
|
||||||
|
Ok results ->
|
||||||
|
HandleSearchResponse results
|
||||||
|
|
||||||
|
Err err ->
|
||||||
|
HandleSearchError (Just err)
|
||||||
|
|
||||||
|
|
||||||
|
decodeResponse : Json.Decode.Value -> Msg
|
||||||
|
decodeResponse json =
|
||||||
|
case Json.Decode.decodeValue responseDecoder json of
|
||||||
|
Err err ->
|
||||||
|
HandleSearchError (Just err)
|
||||||
|
|
||||||
|
Ok results ->
|
||||||
|
HandleSearchResponse results
|
||||||
|
|
||||||
|
|
||||||
|
subscriptions : Model -> Sub Msg
|
||||||
|
subscriptions _ =
|
||||||
|
githubResponse decodeResponse
|
||||||
|
|
||||||
|
|
||||||
|
port githubSearch : String -> Cmd msg
|
||||||
|
|
||||||
|
|
||||||
|
port githubResponse : (Json.Decode.Value -> msg) -> Sub msg
|
||||||
136
part12/Page/Repository.elm
Normal file
136
part12/Page/Repository.elm
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
module Page.Repository exposing (..)
|
||||||
|
|
||||||
|
import Html exposing (..)
|
||||||
|
import Html.Attributes exposing (class, target, href, property, defaultValue, src)
|
||||||
|
import Auth
|
||||||
|
import Http
|
||||||
|
import Task
|
||||||
|
import Json.Decode exposing (Decoder, int, string, list)
|
||||||
|
import Json.Decode.Pipeline exposing (decode, required)
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
{ repoOwner : String
|
||||||
|
, repoName : String
|
||||||
|
, repository : Maybe Repository
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type alias Repository =
|
||||||
|
{ id : Int
|
||||||
|
, issues : Int
|
||||||
|
, forks : Int
|
||||||
|
, watchers : Int
|
||||||
|
, owner : User
|
||||||
|
, description : String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type alias User =
|
||||||
|
{ id : Int
|
||||||
|
, username : String
|
||||||
|
, avatarUrl : String
|
||||||
|
, profileUrl : String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
userDecoder : Decoder User
|
||||||
|
userDecoder =
|
||||||
|
decode User
|
||||||
|
|> required "id" int
|
||||||
|
|> required "login" string
|
||||||
|
|> required "avatar_url" string
|
||||||
|
|> required "url" string
|
||||||
|
|
||||||
|
|
||||||
|
repoDecoder : Decoder Repository
|
||||||
|
repoDecoder =
|
||||||
|
decode Repository
|
||||||
|
|> required "id" int
|
||||||
|
|> required "open_issues_count" int
|
||||||
|
|> required "forks" int
|
||||||
|
|> required "watchers" int
|
||||||
|
|> required "owner" userDecoder
|
||||||
|
|> required "description" string
|
||||||
|
|
||||||
|
|
||||||
|
init : String -> String -> ( Model, Cmd Msg )
|
||||||
|
init repoOwner repoName =
|
||||||
|
( { repoOwner = repoOwner
|
||||||
|
, repoName = repoName
|
||||||
|
, repository = Nothing
|
||||||
|
}
|
||||||
|
, getRepoInfo repoOwner repoName
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
view : Model -> Html Msg
|
||||||
|
view model =
|
||||||
|
let
|
||||||
|
ownerUrl =
|
||||||
|
"https://github.com/" ++ model.repoOwner
|
||||||
|
|
||||||
|
repoUrl =
|
||||||
|
ownerUrl ++ "/" ++ model.repoName
|
||||||
|
|
||||||
|
details =
|
||||||
|
model.repository
|
||||||
|
|> Maybe.map viewDetails
|
||||||
|
|> Maybe.withDefault (text "")
|
||||||
|
in
|
||||||
|
div []
|
||||||
|
[ h2 []
|
||||||
|
[ a [ href repoUrl ] [ text model.repoName ] ]
|
||||||
|
, details
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
viewDetails : Repository -> Html Msg
|
||||||
|
viewDetails repo =
|
||||||
|
div []
|
||||||
|
[ p [ class "repo-description" ] [ text repo.description ]
|
||||||
|
, h3 []
|
||||||
|
[ a [ href repo.owner.profileUrl ]
|
||||||
|
[ img [ class "profile-photo", src repo.owner.avatarUrl ] []
|
||||||
|
, text repo.owner.username
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, table []
|
||||||
|
[ tbody []
|
||||||
|
[ tr [] [ th [] [ text "issues" ], td [] [ text (toString repo.issues) ] ]
|
||||||
|
, tr [] [ th [] [ text "forks" ], td [] [ text (toString repo.forks) ] ]
|
||||||
|
, tr [] [ th [] [ text "watchers" ], td [] [ text (toString repo.watchers) ] ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= HandleRepoError Http.Error
|
||||||
|
| HandleRepoResponse Repository
|
||||||
|
|
||||||
|
|
||||||
|
getRepoInfo : String -> String -> Cmd Msg
|
||||||
|
getRepoInfo repoOwner repoName =
|
||||||
|
let
|
||||||
|
url =
|
||||||
|
"https://api.github.com/repos/"
|
||||||
|
++ repoOwner
|
||||||
|
++ "/"
|
||||||
|
++ repoName
|
||||||
|
++ "?access_token="
|
||||||
|
++ Auth.token
|
||||||
|
|> Debug.log "getRepoInfo"
|
||||||
|
in
|
||||||
|
Http.get repoDecoder url
|
||||||
|
|> Task.perform HandleRepoError HandleRepoResponse
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
|
update msg model =
|
||||||
|
case msg of
|
||||||
|
HandleRepoError err ->
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
HandleRepoResponse repository ->
|
||||||
|
( { model | repository = Just repository }, Cmd.none )
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
Part 11
|
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
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -18,3 +15,13 @@ elm-package install
|
|||||||
```bash
|
```bash
|
||||||
elm-live Main.elm --open --pushstate --output=elm.js
|
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/latest)
|
||||||
|
|||||||
24
part12/Stylesheets.elm
Normal file
24
part12/Stylesheets.elm
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
port module Stylesheets exposing (..)
|
||||||
|
|
||||||
|
import Css.File exposing (..)
|
||||||
|
import ElmHubCss
|
||||||
|
import Html exposing (div)
|
||||||
|
import Html.App as Html
|
||||||
|
|
||||||
|
|
||||||
|
port files : CssFileStructure -> Cmd msg
|
||||||
|
|
||||||
|
|
||||||
|
cssFiles : CssFileStructure
|
||||||
|
cssFiles =
|
||||||
|
toFileStructure [ ( "style.css", compile [ ElmHubCss.css ] ) ]
|
||||||
|
|
||||||
|
|
||||||
|
main : Program Never
|
||||||
|
main =
|
||||||
|
Html.program
|
||||||
|
{ init = ( (), files cssFiles )
|
||||||
|
, view = \_ -> (div [] [])
|
||||||
|
, update = \_ _ -> ( (), Cmd.none )
|
||||||
|
, subscriptions = \_ -> Sub.none
|
||||||
|
}
|
||||||
@@ -9,10 +9,15 @@
|
|||||||
],
|
],
|
||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"Fresheyeball/elm-tuple-extra": "2.1.0 <= v < 3.0.0",
|
||||||
"NoRedInk/elm-decode-pipeline": "1.1.2 <= v < 2.0.0",
|
"NoRedInk/elm-decode-pipeline": "1.1.2 <= v < 2.0.0",
|
||||||
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
||||||
"elm-lang/html": "1.0.0 <= v < 2.0.0",
|
"elm-lang/html": "1.0.0 <= v < 2.0.0",
|
||||||
"evancz/elm-http": "3.0.1 <= v < 4.0.0"
|
"elm-lang/navigation": "1.0.0 <= v < 2.0.0",
|
||||||
|
"evancz/elm-http": "3.0.1 <= v < 4.0.0",
|
||||||
|
"evancz/elm-sortable-table": "1.0.0 <= v < 2.0.0",
|
||||||
|
"evancz/url-parser": "1.0.0 <= v < 2.0.0",
|
||||||
|
"rtfeldman/elm-css": "5.0.0 <= v < 6.0.0"
|
||||||
},
|
},
|
||||||
"elm-version": "0.17.0 <= v < 0.18.0"
|
"elm-version": "0.17.0 <= v < 0.18.0"
|
||||||
}
|
}
|
||||||
|
|||||||
2
part12/github.js
Normal file
2
part12/github.js
Normal file
File diff suppressed because one or more lines are too long
@@ -4,17 +4,29 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>ElmHub</title>
|
<title>ElmHub</title>
|
||||||
|
<script type="text/javascript" src="/github.js"></script>
|
||||||
<script type="text/javascript" src="/elm.js"></script>
|
<script type="text/javascript" src="/elm.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="/style.css">
|
<link rel="stylesheet" href="/style.css">
|
||||||
<link rel="icon" type="image/png" href="/elm-hub.png">
|
<link rel="icon" type="image/png" href="/elm-hub.png">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div id="elm-landing-pad"></div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var app = Elm.Main.fullscreen();
|
// documentation: https://github.com/michael/github
|
||||||
|
var github = new Github();
|
||||||
|
|
||||||
|
var app = Elm.Main.embed(document.getElementById("elm-landing-pad"));
|
||||||
|
|
||||||
|
function searchGithub(query) {
|
||||||
|
github.getSearch(query).repositories({}, function (err, repositories) {
|
||||||
|
app.ports.githubResponse.send(repositories);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
app.ports.githubSearch.subscribe(searchGithub);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user