Skip to content
This repository was archived by the owner on Feb 11, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ sudo: false

cache:
directories:
- elm-stuff/build-artifacts
- elm-stuff/0.19.1
- ~/.elm/0.19.1
- sysconfcpus

os:
Expand All @@ -24,17 +25,12 @@ before_install:
cd ..;
fi


install:
- nvm install $TARGET_NODE_VERSION
- nvm use $TARGET_NODE_VERSION
- node --version
- npm --version
- npm install -g [email protected]
- mv $(npm config get prefix)/bin/elm-make $(npm config get prefix)/bin/elm-make-old
- printf '%s\n\n' '#!/bin/bash' 'echo "Running elm-make with sysconfcpus -n 2"' '$TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm-make-old "$@"' > $(npm config get prefix)/bin/elm-make
- chmod +x $(npm config get prefix)/bin/elm-make
- travis_retry elm-package install --yes
- npm install -g [email protected]

script:
- elm-make src/Main.elm --output=/dev/null --yes
- $TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm make src/Main.elm --output=/dev/null
5 changes: 2 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
elm-css src/Stylesheets.elm
elm-make src/Main.elm --output build/main.js
uglifyjs ./build/main.js --output ./build/main.js --screw-ie8 --compress dead_code,pure_getters,negate_iife,cascade,hoist_funs --mangle toplevel=true
elm make src/Main.elm --output build/main.js
uglifyjs ./build/main.js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" | uglifyjs --mangle --output ./build/main.js
21 changes: 0 additions & 21 deletions elm-package.json

This file was deleted.

31 changes: 31 additions & 0 deletions elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
"elm/browser": "1.0.1",
"elm/core": "1.0.2",
"elm/html": "1.0.0",
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/url": "1.0.0",
"rtfeldman/elm-css": "16.0.1"
},
"indirect": {
"Skinney/murmur3": "2.0.8",
"elm/bytes": "1.0.8",
"elm/file": "1.0.5",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.2",
"rtfeldman/elm-hex": "1.0.0"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
43 changes: 23 additions & 20 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Built With Elm</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="assets/styles.css" type="text/css">
</head>
<body>
<script src="build/main.js"></script>
<script>
var app = Elm.Main.fullscreen();
app.ports.notifyOffsetChangedRaw.subscribe(function () {
setTimeout(function () {
window.scrollTo(0, 0);
if (document.activeElement) {
document.activeElement.blur();
}
}, 10);
});
</script>
</body>
<head>
<title>Built With Elm</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,600"
rel="stylesheet"
type="text/css"
/>
</head>
<body>
<script src="build/main.js"></script>
<script>
var app = Elm.Main.init();
app.ports.notifyOffsetChangedRaw.subscribe(function() {
setTimeout(function() {
window.scrollTo(0, 0);
if (document.activeElement) {
document.activeElement.blur();
}
}, 10);
});
</script>
</body>
</html>
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"description": "A list of projects and apps built with Elm.",
"main": "build/main.js",
"dependencies": {
"elm": "^0.18.0",
"elm-css": "^0.6.0",
"uglifyjs": "^2.4.10"
"elm": "latest-0.19.1"
},
"devDependencies": {
"elm-live": "^4.0.1"
},
"devDependencies": {},
"scripts": {
"build": "bash build.sh"
"build": "bash build.sh",
"dev": "elm-live src/Main.elm --open --start-page=index.html -- --output=build/main.js"
},
"repository": {
"type": "git",
Expand Down
23 changes: 11 additions & 12 deletions src/Cmds.elm
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
port module Cmds exposing (loadProjects, newPage, notifyOffsetChanged)

import Browser.Navigation exposing (Key)
import Http
import HttpBuilder exposing (withExpect)
import Json.Decode as Decode
import Json.Decode exposing (Decoder)
import Model exposing (Project, decodeProject)
import Navigation
import Query
import Task


projectsDecoder : Decode.Decoder (List Project)
projectsDecoder : Decoder (List Project)
projectsDecoder =
Decode.list decodeProject
Json.Decode.list decodeProject


port notifyOffsetChangedRaw : () -> Cmd msg


newPage : Int -> Cmd msg
newPage =
Navigation.newUrl << Query.pageUrl
newPage : Key -> Int -> Cmd msg
newPage key page =
Browser.Navigation.pushUrl key (Query.pageUrl page)


notifyOffsetChanged : Cmd msg
Expand All @@ -29,6 +27,7 @@ notifyOffsetChanged =

loadProjects : (Result Http.Error (List Project) -> msg) -> Cmd msg
loadProjects msg =
HttpBuilder.get "data/projects.json"
|> withExpect (Http.expectJson projectsDecoder)
|> HttpBuilder.send msg
Http.get
{ url = "data/projects.json"
, expect = Http.expectJson msg (Json.Decode.list decodeProject)
}
14 changes: 7 additions & 7 deletions src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module Main exposing (..)

import Browser
import Model exposing (Model)
import Navigation
import Query exposing (parsePage)
import Update exposing (Msg(NewPage), update, init)
import Update exposing (Msg(..), init, update)
import View exposing (view)


main : Program Never Model Msg
main : Program () Model Msg
main =
Navigation.program
(NewPage << parsePage)
{ init = init << parsePage
Browser.application
{ init = init
, view = view
, update = update
, subscriptions = always Sub.none
, onUrlRequest = OnUrlRequest
, onUrlChange = OnUrlChange
}
28 changes: 13 additions & 15 deletions src/Model.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Model exposing (Project, Model, decodeProject)
module Model exposing (Model, Project, decodeProject)

import Json.Decode as Decode exposing (field)
import Browser.Navigation exposing (Key)
import Json.Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (required)


type alias Project =
Expand All @@ -13,7 +15,8 @@ type alias Project =


type alias Model =
{ projects : List Project
{ key : Key
, projects : List Project
, isLoading : Bool
, loadFailed : Bool
, page : Int
Expand All @@ -22,16 +25,11 @@ type alias Model =
}


(|:) : Decode.Decoder (a -> b) -> Decode.Decoder a -> Decode.Decoder b
(|:) =
Decode.map2 (<|)


decodeProject : Decode.Decoder Project
decodeProject : Decoder Project
decodeProject =
Decode.succeed Project
|: (field "previewImageUrl" Decode.string)
|: (field "name" Decode.string)
|: (field "primaryUrl" Decode.string)
|: (field "description" Decode.string)
|: (field "repositoryUrl" (Decode.maybe Decode.string))
Json.Decode.succeed Project
|> required "previewImageUrl" Json.Decode.string
|> required "name" Json.Decode.string
|> required "primaryUrl" Json.Decode.string
|> required "description" Json.Decode.string
|> required "repositoryUrl" (Json.Decode.nullable Json.Decode.string)
14 changes: 8 additions & 6 deletions src/Query.elm
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module Query exposing (pageUrl, parsePage)

import Navigation exposing (Location)
import UrlParser exposing (..)
import Url exposing (Url)
import Url.Parser exposing ((<?>), Parser)
import Url.Parser.Query


pageParser : Parser (Maybe Int -> a) a
pageParser =
map (\_ n -> n) <| string <?> intParam "page"
Url.Parser.top <?> Url.Parser.Query.int "page"


parsePage : Location -> Int
parsePage : Url -> Int
parsePage =
parsePath pageParser
Url.Parser.parse pageParser
>> Maybe.withDefault Nothing
>> Maybe.withDefault 0

Expand All @@ -20,5 +21,6 @@ pageUrl : Int -> String
pageUrl page =
if page == 0 then
"/"

else
"?page=" ++ (toString page)
"?page=" ++ String.fromInt page
Loading