Skip to content

Commit

Permalink
Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonkearns committed May 31, 2023
1 parent b4d9e2b commit 1052e1c
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A **statically typed** site generator, written with pure Elm.
## Getting Started Resources

- [elm-pages Docs Site](https://elm-pages.com/docs)
- [elm-pages Elm API Docs](https://package.elm-lang.org/packages/dillonkearns/elm-pages/latest/)
- [elm-pages Elm API Docs](https://package.elm-lang.org/packages/dillonkearns/elm-pages/9.0.0/)
- [Quick start repo](https://github.com/dillonkearns/elm-pages-starter) [(live site hosted here)](https://elm-pages-starter.netlify.com)
- [Introducing `elm-pages` blog post](https://elm-pages.com/blog/introducing-elm-pages)
- [`examples` folder](https://github.com/dillonkearns/elm-pages/blob/master/examples/) (includes https://elm-pages.com site source)
Expand Down
3 changes: 1 addition & 2 deletions elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@
"robinheghan/fnv1a": "1.0.0 <= v < 2.0.0",
"rtfeldman/elm-css": "18.0.0 <= v < 19.0.0",
"the-sett/elm-syntax-dsl": "6.0.2 <= v < 7.0.0",
"turboMaCk/non-empty-list-alias": "1.2.0 <= v < 2.0.0",
"vito/elm-ansi": "10.0.1 <= v < 11.0.0"
},
"test-dependencies": {
"avh4/elm-program-test": "4.0.0 <= v < 5.0.0",
"elm-explorations/test": "2.0.1 <= v < 3.0.0",
"the-sett/elm-pretty-printer": "3.0.0 <= v < 4.0.0"
}
}
}
1 change: 0 additions & 1 deletion src/ApiRoute.elm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ import FatalError exposing (FatalError)
import Head
import Internal.ApiRoute exposing (ApiRoute(..), ApiRouteBuilder(..))
import Internal.Request
import Json.Decode as Decode
import Json.Encode
import Pattern
import Regex
Expand Down
19 changes: 1 addition & 18 deletions src/FormData.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module FormData exposing (encode, parse, parseToList)
module FormData exposing (parse, parseToList)

import Dict exposing (Dict)
import List.NonEmpty exposing (NonEmpty)
import Url


Expand Down Expand Up @@ -60,19 +59,3 @@ decode string =
|> String.replace "+" " "
|> Url.percentDecode
|> Maybe.withDefault ""


encode : Dict String (NonEmpty String) -> String
encode dict =
dict
|> Dict.toList
|> List.concatMap
(\( key, values ) ->
values
|> List.NonEmpty.toList
|> List.map
(\value ->
Url.percentEncode key ++ "=" ++ Url.percentEncode value
)
)
|> String.join "&"
24 changes: 0 additions & 24 deletions src/Server/Request.elm
Original file line number Diff line number Diff line change
Expand Up @@ -118,31 +118,12 @@ import Form.Validation as Validation
import FormData
import Internal.Request
import Json.Decode
import List.NonEmpty
import Pages.Form
import QueryParams
import Time
import Url


optionalField : String -> Json.Decode.Decoder a -> Json.Decode.Decoder (Maybe a)
optionalField fieldName decoder_ =
let
finishDecoding : Json.Decode.Value -> Json.Decode.Decoder (Maybe a)
finishDecoding json =
case Json.Decode.decodeValue (Json.Decode.field fieldName Json.Decode.value) json of
Ok _ ->
-- The field is present, so run the decoder on it.
Json.Decode.map Just (Json.Decode.field fieldName decoder_)

Err _ ->
-- The field was missing, which is fine!
Json.Decode.succeed Nothing
in
Json.Decode.value
|> Json.Decode.andThen finishDecoding


{-| -}
headers : Request -> Dict String String
headers (Internal.Request.Request req) =
Expand Down Expand Up @@ -569,11 +550,6 @@ rawFormData request =
-- )


rawContentType : Request -> Maybe String
rawContentType (Internal.Request.Request req) =
req.rawHeaders |> Dict.get "content-type"


{-| True if the `content-type` header is present AND matches the given argument.
Examples:
Expand Down
7 changes: 3 additions & 4 deletions tests/ApiRouteTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module ApiRouteTests exposing (all)
import ApiRoute exposing (..)
import BackendTask
import Expect
import FatalError
import Internal.ApiRoute exposing (tryMatch, withRoutes)
import Pattern exposing (Pattern(..))
import Server.Response
Expand Down Expand Up @@ -112,7 +111,7 @@ all =
[ test "no dynamic segments" <|
\() ->
succeed
(\request ->
(\_ ->
""
|> Server.Response.plainText
|> BackendTask.succeed
Expand All @@ -124,7 +123,7 @@ all =
, test "two literal segments" <|
\() ->
succeed
(\request ->
(\_ ->
""
|> Server.Response.plainText
|> BackendTask.succeed
Expand Down Expand Up @@ -174,7 +173,7 @@ all =
\() ->
succeed
(\repo ->
\request ->
\_ ->
BackendTask.succeed ("Data for repo " ++ repo |> Server.Response.plainText)
)
|> literal "api"
Expand Down
1 change: 0 additions & 1 deletion tests/CookieTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module CookieTest exposing (all)
import CookieParser
import Dict
import Expect
import FatalError
import Test exposing (Test, describe, test)


Expand Down
1 change: 0 additions & 1 deletion tests/FormDataTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module FormDataTest exposing (all)

import Dict
import Expect
import FatalError
import FormData
import Test exposing (Test, describe, test)

Expand Down
1 change: 0 additions & 1 deletion tests/HeadTests.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module HeadTests exposing (suite)

import Expect
import FatalError
import Head
import Json.Decode
import Test exposing (Test, describe, test)
Expand Down
1 change: 0 additions & 1 deletion tests/Pages/RouteParamsTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Elm.CodeGen
import Elm.Pretty
import Elm.ToString
import Expect exposing (Expectation)
import FatalError
import Fuzz exposing (Fuzzer)
import Pages.Internal.RoutePattern as RoutePattern
import Pretty
Expand Down
1 change: 0 additions & 1 deletion tests/PathTests.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module PathTests exposing (all)

import Expect
import FatalError
import Test exposing (Test, describe, test)
import UrlPath

Expand Down
1 change: 0 additions & 1 deletion tests/RouteTests.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module RouteTests exposing (all)

import Expect
import FatalError
import List.Extra
import Regex
import Test exposing (Test, describe, test)
Expand Down
1 change: 0 additions & 1 deletion tests/SetCookieTest.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module SetCookieTest exposing (all)

import Expect
import FatalError
import Server.SetCookie exposing (..)
import Test exposing (Test, describe, test)
import Time
Expand Down

0 comments on commit 1052e1c

Please sign in to comment.