mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 04:43:03 +03:00
Rename StaticHttp to DataSource.
This commit is contained in:
parent
03fc86e577
commit
47fccf2cca
@ -1,6 +1,7 @@
|
||||
module Article exposing (..)
|
||||
|
||||
import Cloudinary
|
||||
import DataSource
|
||||
import Date exposing (Date)
|
||||
import Element exposing (Element)
|
||||
import Glob
|
||||
@ -8,7 +9,6 @@ import OptimizedDecoder
|
||||
import Pages.ImagePath exposing (ImagePath)
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.StaticFile as StaticFile
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
|
||||
|
||||
type alias BlogPost =
|
||||
@ -17,7 +17,7 @@ type alias BlogPost =
|
||||
}
|
||||
|
||||
|
||||
blogPostsGlob : StaticHttp.Request (List { filePath : String, slug : String })
|
||||
blogPostsGlob : DataSource.Request (List { filePath : String, slug : String })
|
||||
blogPostsGlob =
|
||||
Glob.succeed BlogPost
|
||||
|> Glob.keep Glob.fullFilePath
|
||||
@ -27,22 +27,22 @@ blogPostsGlob =
|
||||
|> Glob.toStaticHttp
|
||||
|
||||
|
||||
allMetadata : StaticHttp.Request (List ( PagePath, ArticleMetadata ))
|
||||
allMetadata : DataSource.Request (List ( PagePath, ArticleMetadata ))
|
||||
allMetadata =
|
||||
--StaticFile.glob "content/blog/*.md"
|
||||
blogPostsGlob
|
||||
|> StaticHttp.map
|
||||
|> DataSource.map
|
||||
(\paths ->
|
||||
paths
|
||||
|> List.map
|
||||
(\{ filePath, slug } ->
|
||||
StaticHttp.map2 Tuple.pair
|
||||
(StaticHttp.succeed <| "blog/" ++ slug)
|
||||
DataSource.map2 Tuple.pair
|
||||
(DataSource.succeed <| "blog/" ++ slug)
|
||||
(StaticFile.request filePath (StaticFile.frontmatter frontmatterDecoder))
|
||||
)
|
||||
)
|
||||
|> StaticHttp.resolve
|
||||
|> StaticHttp.map
|
||||
|> DataSource.resolve
|
||||
|> DataSource.map
|
||||
(\articles ->
|
||||
articles
|
||||
|> List.filterMap
|
||||
@ -69,7 +69,7 @@ type alias DataFromFile msg =
|
||||
--fileRequest : String -> StaticHttp.Request (DataFromFile msg)
|
||||
|
||||
|
||||
fileRequest : String -> StaticHttp.Request ArticleMetadata
|
||||
fileRequest : String -> DataSource.Request ArticleMetadata
|
||||
fileRequest filePath =
|
||||
StaticFile.request
|
||||
--"content/blog/extensible-markdown-parsing-in-elm.md"
|
||||
|
@ -1,8 +1,8 @@
|
||||
module MySitemap exposing (install)
|
||||
|
||||
import DataSource
|
||||
import Head
|
||||
import Pages.Platform exposing (Builder)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Sitemap
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ install :
|
||||
{ siteUrl : String
|
||||
}
|
||||
-> (List item -> List { path : String, lastMod : Maybe String })
|
||||
-> StaticHttp.Request (List item)
|
||||
-> DataSource.Request (List item)
|
||||
-> Builder pathKey userModel userMsg route
|
||||
-> Builder pathKey userModel userMsg route
|
||||
install config toSitemapEntry request builder =
|
||||
@ -18,7 +18,7 @@ install config toSitemapEntry request builder =
|
||||
|> Pages.Platform.withGlobalHeadTags [ Head.sitemapLink "/sitemap.xml" ]
|
||||
|> Pages.Platform.withFileGenerator
|
||||
(request
|
||||
|> StaticHttp.map
|
||||
|> DataSource.map
|
||||
(\items ->
|
||||
[ Ok
|
||||
{ path = [ "sitemap.xml" ]
|
||||
|
@ -1,9 +1,9 @@
|
||||
module RssPlugin exposing (generate)
|
||||
|
||||
import DataSource
|
||||
import Head
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.Platform exposing (Builder)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Rss
|
||||
import Time
|
||||
|
||||
@ -16,7 +16,7 @@ generate :
|
||||
, indexPage : PagePath
|
||||
}
|
||||
-> (item -> Maybe Rss.Item)
|
||||
-> StaticHttp.Request (List item)
|
||||
-> DataSource.Request (List item)
|
||||
-> Builder pathKey userModel userMsg route
|
||||
-> Builder pathKey userModel userMsg route
|
||||
generate options metadataToRssItem itemsRequest builder =
|
||||
@ -30,7 +30,7 @@ generate options metadataToRssItem itemsRequest builder =
|
||||
builder
|
||||
|> Pages.Platform.withFileGenerator
|
||||
(itemsRequest
|
||||
|> StaticHttp.map
|
||||
|> DataSource.map
|
||||
(\items ->
|
||||
{ path = feedFilePath
|
||||
, content =
|
||||
|
@ -1,8 +1,8 @@
|
||||
module ServerRequest exposing (ServerRequest, expectHeader, init, optionalHeader, staticData, toStaticHttp)
|
||||
|
||||
import DataSource
|
||||
import Internal.OptimizedDecoder exposing (OptimizedDecoder)
|
||||
import OptimizedDecoder
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Secrets
|
||||
|
||||
|
||||
@ -15,17 +15,17 @@ init constructor =
|
||||
ServerRequest (OptimizedDecoder.succeed constructor)
|
||||
|
||||
|
||||
staticData : StaticHttp.Request String
|
||||
staticData : DataSource.Request String
|
||||
staticData =
|
||||
StaticHttp.get (Secrets.succeed "$$elm-pages$$headers")
|
||||
DataSource.get (Secrets.succeed "$$elm-pages$$headers")
|
||||
(OptimizedDecoder.field "headers"
|
||||
(OptimizedDecoder.field "accept-language" OptimizedDecoder.string)
|
||||
)
|
||||
|
||||
|
||||
toStaticHttp : ServerRequest decodesTo -> StaticHttp.Request decodesTo
|
||||
toStaticHttp : ServerRequest decodesTo -> DataSource.Request decodesTo
|
||||
toStaticHttp (ServerRequest decoder) =
|
||||
StaticHttp.get (Secrets.succeed "$$elm-pages$$headers") decoder
|
||||
DataSource.get (Secrets.succeed "$$elm-pages$$headers") decoder
|
||||
|
||||
|
||||
expectHeader : String -> ServerRequest (String -> value) -> ServerRequest value
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Shared exposing (Model, Msg(..), SharedMsg(..), StaticData, template)
|
||||
|
||||
import Browser.Navigation
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import DocumentSvg
|
||||
import Element exposing (Element)
|
||||
@ -14,7 +15,6 @@ import Html exposing (Html)
|
||||
import Html.Attributes as Attr
|
||||
import OptimizedDecoder as D
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Palette
|
||||
import Secrets
|
||||
import SharedTemplate exposing (SharedTemplate)
|
||||
@ -101,9 +101,9 @@ subscriptions _ _ =
|
||||
Sub.none
|
||||
|
||||
|
||||
staticData : StaticHttp.Request StaticData
|
||||
staticData : DataSource.Request StaticData
|
||||
staticData =
|
||||
StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||
DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||
(D.field "stargazers_count" D.int)
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
module SharedTemplate exposing (..)
|
||||
|
||||
import Browser.Navigation
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Html exposing (Html)
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Route exposing (Route)
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ type alias SharedTemplate sharedMsg sharedModel sharedStaticData mappedMsg =
|
||||
-> (sharedMsg -> mappedMsg)
|
||||
-> Document mappedMsg
|
||||
-> { body : Html mappedMsg, title : String }
|
||||
, staticData : StaticHttp.Request sharedStaticData
|
||||
, staticData : DataSource.Request sharedStaticData
|
||||
, subscriptions : PagePath -> sharedModel -> Sub sharedMsg
|
||||
, onPageChange :
|
||||
Maybe
|
||||
|
@ -1,12 +1,12 @@
|
||||
module Showcase exposing (..)
|
||||
|
||||
import DataSource
|
||||
import Element
|
||||
import Element.Border
|
||||
import Element.Font
|
||||
import FontAwesome
|
||||
import OptimizedDecoder as Decode
|
||||
import Pages.Secrets as Secrets
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Palette
|
||||
|
||||
|
||||
@ -120,15 +120,15 @@ entryDecoder =
|
||||
(Decode.maybe (Decode.field "Repository URL" Decode.string))
|
||||
|
||||
|
||||
staticRequest : StaticHttp.Request (List Entry)
|
||||
staticRequest : DataSource.Request (List Entry)
|
||||
staticRequest =
|
||||
StaticHttp.request
|
||||
DataSource.request
|
||||
(Secrets.succeed
|
||||
(\airtableToken ->
|
||||
{ url = "https://api.airtable.com/v0/appDykQzbkQJAidjt/elm-pages%20showcase?maxRecords=100&view=Grid%202"
|
||||
, method = "GET"
|
||||
, headers = [ ( "Authorization", "Bearer " ++ airtableToken ), ( "view", "viwayJBsr63qRd7q3" ) ]
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
)
|
||||
|> Secrets.with "AIRTABLE_TOKEN"
|
||||
|
@ -2,6 +2,7 @@ module Site exposing (config)
|
||||
|
||||
import Cloudinary
|
||||
import Color
|
||||
import DataSource
|
||||
import Head
|
||||
import Json.Encode
|
||||
import MimeType
|
||||
@ -9,7 +10,6 @@ import Pages.ImagePath as ImagePath exposing (ImagePath)
|
||||
import Pages.Manifest as Manifest
|
||||
import Pages.Manifest.Category
|
||||
import Pages.PagePath as PagePath
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Route exposing (Route)
|
||||
import SiteConfig exposing (SiteConfig)
|
||||
import Sitemap
|
||||
@ -33,7 +33,7 @@ config =
|
||||
generateFiles :
|
||||
List (Maybe Route)
|
||||
->
|
||||
StaticHttp.Request
|
||||
DataSource.Request
|
||||
(List
|
||||
(Result
|
||||
String
|
||||
@ -43,7 +43,7 @@ generateFiles :
|
||||
)
|
||||
)
|
||||
generateFiles allRoutes =
|
||||
StaticHttp.succeed
|
||||
DataSource.succeed
|
||||
[ siteMap allRoutes |> Ok
|
||||
]
|
||||
|
||||
@ -53,11 +53,11 @@ type alias StaticData =
|
||||
}
|
||||
|
||||
|
||||
staticData : StaticHttp.Request StaticData
|
||||
staticData : DataSource.Request StaticData
|
||||
staticData =
|
||||
StaticHttp.map StaticData
|
||||
DataSource.map StaticData
|
||||
--(StaticFile.request "site-name.txt" StaticFile.body)
|
||||
(StaticHttp.succeed "site-name")
|
||||
(DataSource.succeed "site-name")
|
||||
|
||||
|
||||
head : StaticData -> List Head.Tag
|
||||
|
@ -2,6 +2,7 @@ module Template.Blog exposing (Model, Msg, StaticData, template)
|
||||
|
||||
import Article
|
||||
import Browser.Navigation
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Element
|
||||
import Head
|
||||
@ -9,7 +10,6 @@ import Head.Seo as Seo
|
||||
import Index
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Shared
|
||||
import SiteOld
|
||||
import Template exposing (DynamicContext, StaticPayload, TemplateWithState)
|
||||
@ -24,7 +24,7 @@ template =
|
||||
Template.withStaticData
|
||||
{ head = head
|
||||
, staticData = \_ -> staticData
|
||||
, staticRoutes = StaticHttp.succeed []
|
||||
, staticRoutes = DataSource.succeed []
|
||||
}
|
||||
|> Template.buildWithLocalState
|
||||
{ view = view
|
||||
@ -36,7 +36,7 @@ template =
|
||||
}
|
||||
|
||||
|
||||
staticData : StaticHttp.Request StaticData
|
||||
staticData : DataSource.Request StaticData
|
||||
staticData =
|
||||
--StaticFile.glob "content/blog/*.md"
|
||||
Article.allMetadata
|
||||
|
@ -3,6 +3,7 @@ module Template.Blog.Slug_ exposing (Model, Msg, StaticData, articlesRequest, ro
|
||||
import Article
|
||||
import Cloudinary
|
||||
import Data.Author as Author exposing (Author)
|
||||
import DataSource
|
||||
import Date exposing (Date)
|
||||
import Document exposing (Document)
|
||||
import Element exposing (Element)
|
||||
@ -16,7 +17,6 @@ import OptimizedDecoder
|
||||
import Pages.ImagePath as ImagePath exposing (ImagePath)
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.StaticFile as StaticFile
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Palette
|
||||
import Rss
|
||||
import Shared
|
||||
@ -37,10 +37,10 @@ type alias RouteParams =
|
||||
{ slug : String }
|
||||
|
||||
|
||||
routes : StaticHttp.Request (List RouteParams)
|
||||
routes : DataSource.Request (List RouteParams)
|
||||
routes =
|
||||
Article.blogPostsGlob
|
||||
|> StaticHttp.map
|
||||
|> DataSource.map
|
||||
(List.map
|
||||
(\globData ->
|
||||
{ slug = globData.slug }
|
||||
@ -183,7 +183,7 @@ type alias StaticData =
|
||||
}
|
||||
|
||||
|
||||
staticData : RouteParams -> StaticHttp.Request StaticData
|
||||
staticData : RouteParams -> DataSource.Request StaticData
|
||||
staticData route =
|
||||
StaticFile.request
|
||||
("content/blog/" ++ route.slug ++ ".md")
|
||||
@ -262,7 +262,7 @@ toRssItem article =
|
||||
}
|
||||
|
||||
|
||||
articlesRequest : StaticHttp.Request (List ArticleMetadata)
|
||||
articlesRequest : DataSource.Request (List ArticleMetadata)
|
||||
articlesRequest =
|
||||
Glob.succeed identity
|
||||
|> Glob.keep Glob.fullFilePath
|
||||
@ -270,7 +270,7 @@ articlesRequest =
|
||||
|> Glob.drop Glob.wildcard
|
||||
|> Glob.drop (Glob.literal ".md")
|
||||
|> Glob.toStaticHttp
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\articleFilePaths ->
|
||||
articleFilePaths
|
||||
|> List.filter (\filePath -> filePath |> String.contains "index" |> not)
|
||||
@ -279,5 +279,5 @@ articlesRequest =
|
||||
StaticFile.request articleFilePath
|
||||
(StaticFile.frontmatter frontmatterDecoder)
|
||||
)
|
||||
|> StaticHttp.combine
|
||||
|> DataSource.combine
|
||||
)
|
||||
|
@ -1,5 +1,6 @@
|
||||
module Template.Documentation exposing (Model, Msg, StaticData, template)
|
||||
|
||||
import DataSource
|
||||
import DocSidebar
|
||||
import Document exposing (Document)
|
||||
import Element exposing (Element)
|
||||
@ -11,7 +12,6 @@ import Json.Decode as Decode
|
||||
import MarkdownRenderer
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Palette
|
||||
import Shared
|
||||
import SiteOld
|
||||
@ -38,7 +38,7 @@ template : TemplateWithState {} StaticData Model Msg
|
||||
template =
|
||||
Template.noStaticData
|
||||
{ head = head
|
||||
, staticRoutes = StaticHttp.succeed []
|
||||
, staticRoutes = DataSource.succeed []
|
||||
}
|
||||
|> Template.buildWithSharedState
|
||||
{ view = view
|
||||
|
@ -1,11 +1,11 @@
|
||||
module Template.Hello.Name_ exposing (Model, Msg, StaticData, template)
|
||||
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Element
|
||||
import Head
|
||||
import Head.Seo as Seo
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Shared
|
||||
import SiteOld
|
||||
import Template exposing (StaticPayload, Template)
|
||||
@ -28,7 +28,7 @@ template : Template Route ()
|
||||
template =
|
||||
Template.noStaticData
|
||||
{ head = head
|
||||
, staticRoutes = StaticHttp.succeed [ { name = "world" } ]
|
||||
, staticRoutes = DataSource.succeed [ { name = "world" } ]
|
||||
}
|
||||
|> Template.buildNoState { view = view }
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
module Template.Index exposing (Model, Msg, StaticData, template)
|
||||
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Element
|
||||
import Element.Region
|
||||
@ -9,7 +10,6 @@ import MarkdownRenderer
|
||||
import OptimizedDecoder
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.StaticFile as StaticFile
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Shared
|
||||
import SiteOld
|
||||
import Template exposing (StaticPayload, Template)
|
||||
@ -35,7 +35,7 @@ template : Template Route StaticData
|
||||
template =
|
||||
Template.withStaticData
|
||||
{ head = head
|
||||
, staticRoutes = StaticHttp.succeed []
|
||||
, staticRoutes = DataSource.succeed []
|
||||
, staticData = staticData
|
||||
}
|
||||
|> Template.buildNoState { view = view }
|
||||
@ -81,7 +81,7 @@ view static =
|
||||
}
|
||||
|
||||
|
||||
staticData : Route -> StaticHttp.Request (List (Element.Element msg))
|
||||
staticData : Route -> DataSource.Request (List (Element.Element msg))
|
||||
staticData route =
|
||||
StaticFile.request
|
||||
"content/index.md"
|
||||
|
@ -1,11 +1,11 @@
|
||||
module Template.Showcase exposing (Model, Msg, StaticData, template)
|
||||
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Element exposing (Element)
|
||||
import Head
|
||||
import Head.Seo as Seo
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Shared
|
||||
import Showcase
|
||||
import Template exposing (StaticPayload, TemplateWithState)
|
||||
@ -23,13 +23,13 @@ template : TemplateWithState {} StaticData () Msg
|
||||
template =
|
||||
Template.withStaticData
|
||||
{ head = head
|
||||
, staticRoutes = StaticHttp.succeed []
|
||||
, staticRoutes = DataSource.succeed []
|
||||
, staticData = \_ -> staticData
|
||||
}
|
||||
|> Template.buildNoState { view = view }
|
||||
|
||||
|
||||
staticData : StaticHttp.Request StaticData
|
||||
staticData : DataSource.Request StaticData
|
||||
staticData =
|
||||
Showcase.staticRequest
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
module Template.Time exposing (Model, Msg, StaticData, template)
|
||||
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Element exposing (Element)
|
||||
import Head
|
||||
import Head.Seo as Seo
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Shared
|
||||
import Template exposing (StaticPayload, Template, TemplateWithState)
|
||||
|
||||
@ -26,14 +26,14 @@ template : Template {} StaticData
|
||||
template =
|
||||
Template.withStaticData
|
||||
{ head = head
|
||||
, staticRoutes = StaticHttp.succeed []
|
||||
, staticRoutes = DataSource.succeed []
|
||||
, staticData = staticData
|
||||
}
|
||||
|> Template.buildNoState { view = view }
|
||||
|
||||
|
||||
staticData routeParams =
|
||||
StaticHttp.succeed "TIME RESPONSE"
|
||||
DataSource.succeed "TIME RESPONSE"
|
||||
|
||||
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
module TemplateHardcoded exposing (..)
|
||||
|
||||
import DataSource
|
||||
import Head
|
||||
import Pages
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import TemplateType
|
||||
|
||||
|
||||
template :
|
||||
{ staticData :
|
||||
List ( PagePath, TemplateType.Metadata )
|
||||
-> StaticHttp.Request staticData
|
||||
-> DataSource.Request staticData
|
||||
, view :
|
||||
List ( PagePath, TemplateType.Metadata )
|
||||
-> staticData
|
||||
@ -34,7 +34,7 @@ template config =
|
||||
type alias Template metadata renderedTemplate staticData model view templateMsg =
|
||||
{ staticData :
|
||||
List ( PagePath, TemplateType.Metadata )
|
||||
-> StaticHttp.Request staticData
|
||||
-> DataSource.Request staticData
|
||||
, view :
|
||||
List ( PagePath, TemplateType.Metadata )
|
||||
-> staticData
|
||||
|
@ -2,12 +2,12 @@ module Shared exposing (Model, Msg(..), SharedMsg(..), StaticData, template)
|
||||
|
||||
import Browser.Navigation
|
||||
import Css.Global
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Html exposing (Html)
|
||||
import Html.Styled
|
||||
import OptimizedDecoder as D
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Secrets
|
||||
import SharedTemplate exposing (SharedTemplate)
|
||||
import Tailwind.Utilities
|
||||
@ -79,9 +79,9 @@ subscriptions _ _ =
|
||||
Sub.none
|
||||
|
||||
|
||||
staticData : StaticHttp.Request StaticData
|
||||
staticData : DataSource.Request StaticData
|
||||
staticData =
|
||||
StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||
DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||
(D.field "stargazers_count" D.int)
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
module SharedTemplate exposing (..)
|
||||
|
||||
import Browser.Navigation
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Html exposing (Html)
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Route exposing (Route)
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ type alias SharedTemplate sharedMsg sharedModel sharedStaticData mappedMsg =
|
||||
-> (sharedMsg -> mappedMsg)
|
||||
-> Document mappedMsg
|
||||
-> { body : Html mappedMsg, title : String }
|
||||
, staticData : StaticHttp.Request sharedStaticData
|
||||
, staticData : DataSource.Request sharedStaticData
|
||||
, subscriptions : PagePath -> sharedModel -> Sub sharedMsg
|
||||
, onPageChange :
|
||||
Maybe
|
||||
|
@ -2,13 +2,13 @@ module Site exposing (config)
|
||||
|
||||
import Cloudinary
|
||||
import Color
|
||||
import DataSource
|
||||
import Head
|
||||
import MimeType
|
||||
import Pages.ImagePath as ImagePath exposing (ImagePath)
|
||||
import Pages.Manifest as Manifest
|
||||
import Pages.Manifest.Category
|
||||
import Pages.PagePath as PagePath
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Route exposing (Route)
|
||||
import SiteConfig exposing (SiteConfig)
|
||||
import Sitemap
|
||||
@ -32,7 +32,7 @@ config =
|
||||
generateFiles :
|
||||
List (Maybe Route)
|
||||
->
|
||||
StaticHttp.Request
|
||||
DataSource.Request
|
||||
(List
|
||||
(Result
|
||||
String
|
||||
@ -42,7 +42,7 @@ generateFiles :
|
||||
)
|
||||
)
|
||||
generateFiles allRoutes =
|
||||
StaticHttp.succeed
|
||||
DataSource.succeed
|
||||
[ siteMap allRoutes |> Ok
|
||||
]
|
||||
|
||||
@ -52,11 +52,11 @@ type alias StaticData =
|
||||
}
|
||||
|
||||
|
||||
staticData : StaticHttp.Request StaticData
|
||||
staticData : DataSource.Request StaticData
|
||||
staticData =
|
||||
StaticHttp.map StaticData
|
||||
DataSource.map StaticData
|
||||
--(StaticFile.request "site-name.txt" StaticFile.body)
|
||||
(StaticHttp.succeed "site-name")
|
||||
(DataSource.succeed "site-name")
|
||||
|
||||
|
||||
head : StaticData -> List Head.Tag
|
||||
|
@ -2,6 +2,7 @@ module Template.Slide.Number_ exposing (Model, Msg, StaticData, template)
|
||||
|
||||
import Browser.Events
|
||||
import Browser.Navigation
|
||||
import DataSource
|
||||
import Document exposing (Document)
|
||||
import Head
|
||||
import Head.Seo as Seo
|
||||
@ -15,7 +16,6 @@ import MarkdownRenderer
|
||||
import OptimizedDecoder
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.StaticFile as StaticFile
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Shared
|
||||
import Tailwind.Utilities as Tw
|
||||
import Template exposing (StaticPayload, Template)
|
||||
@ -39,7 +39,7 @@ template =
|
||||
{ head = head
|
||||
, staticRoutes =
|
||||
slideCount
|
||||
|> StaticHttp.map
|
||||
|> DataSource.map
|
||||
(\count ->
|
||||
List.range 1 (count - 1)
|
||||
|> List.map String.fromInt
|
||||
@ -114,14 +114,14 @@ toDirection string =
|
||||
Nothing
|
||||
|
||||
|
||||
staticData : RouteParams -> StaticHttp.Request StaticData
|
||||
staticData : RouteParams -> DataSource.Request StaticData
|
||||
staticData routeParams =
|
||||
StaticHttp.map2 StaticData
|
||||
DataSource.map2 StaticData
|
||||
(slideBody routeParams)
|
||||
slideCount
|
||||
|
||||
|
||||
slideBody : RouteParams -> StaticHttp.Request (List (Html.Html Msg))
|
||||
slideBody : RouteParams -> DataSource.Request (List (Html.Html Msg))
|
||||
slideBody route =
|
||||
StaticFile.request
|
||||
"slides.md"
|
||||
@ -147,7 +147,7 @@ slideBody route =
|
||||
)
|
||||
|
||||
|
||||
slideCount : StaticHttp.Request Int
|
||||
slideCount : DataSource.Request Int
|
||||
slideCount =
|
||||
StaticFile.request "slides.md"
|
||||
(StaticFile.body
|
||||
|
@ -49,14 +49,14 @@ import Browser.Navigation
|
||||
import Document exposing (Document)
|
||||
import Head
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import DataSource
|
||||
import Shared
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias TemplateWithState routeParams templateStaticData templateModel templateMsg =
|
||||
{ staticData : routeParams -> StaticHttp.Request templateStaticData
|
||||
, staticRoutes : StaticHttp.Request (List routeParams)
|
||||
{ staticData : routeParams -> DataSource.Request templateStaticData
|
||||
, staticRoutes : DataSource.Request (List routeParams)
|
||||
, view :
|
||||
templateModel
|
||||
-> Shared.Model
|
||||
@ -88,8 +88,8 @@ type alias StaticPayload staticData routeParams =
|
||||
{-| -}
|
||||
type Builder routeParams templateStaticData
|
||||
= WithStaticData
|
||||
{ staticData : routeParams -> StaticHttp.Request templateStaticData
|
||||
, staticRoutes : StaticHttp.Request (List routeParams)
|
||||
{ staticData : routeParams -> DataSource.Request templateStaticData
|
||||
, staticRoutes : DataSource.Request (List routeParams)
|
||||
, head :
|
||||
StaticPayload templateStaticData routeParams
|
||||
-> List Head.Tag
|
||||
@ -202,8 +202,8 @@ buildWithSharedState config builderState =
|
||||
|
||||
{-| -}
|
||||
withStaticData :
|
||||
{ staticData : routeParams -> StaticHttp.Request templateStaticData
|
||||
, staticRoutes : StaticHttp.Request (List routeParams)
|
||||
{ staticData : routeParams -> DataSource.Request templateStaticData
|
||||
, staticRoutes : DataSource.Request (List routeParams)
|
||||
, head : StaticPayload templateStaticData routeParams -> List Head.Tag
|
||||
}
|
||||
-> Builder routeParams templateStaticData
|
||||
@ -218,12 +218,12 @@ withStaticData { staticData, head, staticRoutes } =
|
||||
{-| -}
|
||||
noStaticData :
|
||||
{ head : StaticPayload () routeParams -> List Head.Tag
|
||||
, staticRoutes : StaticHttp.Request (List routeParams)
|
||||
, staticRoutes : DataSource.Request (List routeParams)
|
||||
}
|
||||
-> Builder routeParams ()
|
||||
noStaticData { head, staticRoutes } =
|
||||
WithStaticData
|
||||
{ staticData = \_ -> StaticHttp.succeed ()
|
||||
{ staticData = \_ -> DataSource.succeed ()
|
||||
, staticRoutes = staticRoutes
|
||||
, head = head
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import Html exposing (Html)
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Url
|
||||
import Url.Parser as Parser exposing ((</>), Parser)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import DataSource
|
||||
|
||||
${templates.map((name) => `import Template.${name.join(".")}`).join("\n")}
|
||||
|
||||
@ -377,9 +377,9 @@ main =
|
||||
, sharedStaticData = Shared.template.staticData
|
||||
, generateFiles =
|
||||
getStaticRoutes
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\\resolvedStaticRoutes ->
|
||||
StaticHttp.map2 (::)
|
||||
DataSource.map2 (::)
|
||||
(manifestGenerator
|
||||
resolvedStaticRoutes
|
||||
)
|
||||
@ -390,11 +390,11 @@ main =
|
||||
)
|
||||
}
|
||||
|
||||
staticDataForRoute : Maybe Route -> StaticHttp.Request PageStaticData
|
||||
staticDataForRoute : Maybe Route -> DataSource.Request PageStaticData
|
||||
staticDataForRoute route =
|
||||
case route of
|
||||
Nothing ->
|
||||
StaticHttp.fail ""
|
||||
DataSource.fail ""
|
||||
${templates
|
||||
.map(
|
||||
(name) =>
|
||||
@ -402,17 +402,17 @@ staticDataForRoute route =
|
||||
name
|
||||
)} routeParams) ->\n Template.${name.join(
|
||||
"."
|
||||
)}.template.staticData routeParams |> StaticHttp.map Data${routeHelpers.routeVariant(
|
||||
)}.template.staticData routeParams |> DataSource.map Data${routeHelpers.routeVariant(
|
||||
name
|
||||
)}`
|
||||
)
|
||||
.join("\n ")}
|
||||
|
||||
|
||||
getStaticRoutes : StaticHttp.Request (List (Maybe Route))
|
||||
getStaticRoutes : DataSource.Request (List (Maybe Route))
|
||||
getStaticRoutes =
|
||||
StaticHttp.combine
|
||||
[ StaticHttp.succeed
|
||||
DataSource.combine
|
||||
[ DataSource.succeed
|
||||
[ ${templates
|
||||
.filter((name) => !isParameterizedRoute(name))
|
||||
.map((name) => `Route.${routeHelpers.routeVariant(name)} {}`)
|
||||
@ -424,21 +424,21 @@ getStaticRoutes =
|
||||
(name) =>
|
||||
`Template.${moduleName(
|
||||
name
|
||||
)}.template.staticRoutes |> StaticHttp.map (List.map Route.${pathNormalizedName(
|
||||
)}.template.staticRoutes |> DataSource.map (List.map Route.${pathNormalizedName(
|
||||
name
|
||||
)})`
|
||||
)
|
||||
.join("\n , ")}
|
||||
]
|
||||
|> StaticHttp.map List.concat
|
||||
|> StaticHttp.map (List.map Just)
|
||||
|> DataSource.map List.concat
|
||||
|> DataSource.map (List.map Just)
|
||||
|
||||
|
||||
manifestGenerator : List ( Maybe Route ) -> StaticHttp.Request (Result anyError { path : List String, content : String })
|
||||
manifestGenerator : List ( Maybe Route ) -> DataSource.Request (Result anyError { path : List String, content : String })
|
||||
manifestGenerator resolvedRoutes =
|
||||
Site.config resolvedRoutes
|
||||
|> .staticData
|
||||
|> StaticHttp.map
|
||||
|> DataSource.map
|
||||
(\\data ->
|
||||
(Site.config resolvedRoutes |> .manifest) data
|
||||
|> manifestToFile (Site.config resolvedRoutes |> .canonicalUrl)
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Pages.StaticHttp exposing
|
||||
module DataSource exposing
|
||||
( Request, RequestDetails
|
||||
, get, request
|
||||
, map, succeed, fail
|
||||
@ -134,8 +134,8 @@ step, but mapping allows you to change the resulting values by applying function
|
||||
|
||||
A common use for this is to map your data into your elm-pages view:
|
||||
|
||||
import DataSource
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
|
||||
view =
|
||||
StaticHttp.get
|
||||
@ -180,8 +180,8 @@ resolve =
|
||||
|
||||
{-| Turn a list of `StaticHttp.Request`s into a single one.
|
||||
|
||||
import DataSource
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
|
||||
type alias Pokemon =
|
||||
{ name : String
|
||||
@ -350,8 +350,8 @@ lookupUrls requestInfo =
|
||||
{-| Build off of the response from a previous `StaticHttp` request to build a follow-up request. You can use the data
|
||||
from the previous response to build up the URL, headers, etc. that you send to the subsequent request.
|
||||
|
||||
import DataSource
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
|
||||
licenseData : StaticHttp.Request String
|
||||
licenseData =
|
||||
@ -385,7 +385,7 @@ andThen fn requestInfo =
|
||||
|
||||
{-| This is useful for prototyping with some hardcoded data, or for having a view that doesn't have any StaticHttp data.
|
||||
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import DataSource
|
||||
|
||||
view :
|
||||
List ( PagePath, Metadata )
|
||||
@ -431,8 +431,8 @@ fail errorMessage =
|
||||
|
||||
{-| A simplified helper around [`StaticHttp.request`](#request), which builds up a StaticHttp GET request.
|
||||
|
||||
import DataSource
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
|
||||
getRequest : StaticHttp.Request Int
|
||||
getRequest =
|
16
src/Glob.elm
16
src/Glob.elm
@ -6,9 +6,9 @@ module Glob exposing (Glob, atLeastOne, drop, extractMatches, fullFilePath, keep
|
||||
|
||||
-}
|
||||
|
||||
import DataSource
|
||||
import List.Extra
|
||||
import OptimizedDecoder
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Secrets
|
||||
|
||||
|
||||
@ -298,9 +298,9 @@ type alias RawGlob =
|
||||
|
||||
|
||||
{-| -}
|
||||
toStaticHttp : Glob a -> StaticHttp.Request (List a)
|
||||
toStaticHttp : Glob a -> DataSource.Request (List a)
|
||||
toStaticHttp glob =
|
||||
StaticHttp.get (Secrets.succeed <| "glob://" ++ toPattern glob)
|
||||
DataSource.get (Secrets.succeed <| "glob://" ++ toPattern glob)
|
||||
(OptimizedDecoder.map2 RawGlob
|
||||
(OptimizedDecoder.string |> OptimizedDecoder.list |> OptimizedDecoder.field "captures")
|
||||
(OptimizedDecoder.field "fullPath" OptimizedDecoder.string)
|
||||
@ -311,21 +311,21 @@ toStaticHttp glob =
|
||||
|
||||
|
||||
{-| -}
|
||||
singleFile : String -> StaticHttp.Request (Maybe String)
|
||||
singleFile : String -> DataSource.Request (Maybe String)
|
||||
singleFile filePath =
|
||||
succeed identity
|
||||
|> drop (literal filePath)
|
||||
|> keep fullFilePath
|
||||
|> toStaticHttp
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\globResults ->
|
||||
case globResults of
|
||||
[] ->
|
||||
StaticHttp.succeed Nothing
|
||||
DataSource.succeed Nothing
|
||||
|
||||
[ single ] ->
|
||||
Just single |> StaticHttp.succeed
|
||||
Just single |> DataSource.succeed
|
||||
|
||||
multipleResults ->
|
||||
StaticHttp.fail <| "Unexpected - getSingleFile returned multiple results." ++ (multipleResults |> String.join ", ")
|
||||
DataSource.fail <| "Unexpected - getSingleFile returned multiple results." ++ (multipleResults |> String.join ", ")
|
||||
)
|
||||
|
@ -10,6 +10,7 @@ module Pages.Internal.Platform.Cli exposing
|
||||
|
||||
import BuildError exposing (BuildError)
|
||||
import Codec
|
||||
import DataSource exposing (RequestDetails)
|
||||
import Dict exposing (Dict)
|
||||
import Dict.Extra
|
||||
import ElmHtml.InternalTypes exposing (decodeElmHtml)
|
||||
@ -29,7 +30,6 @@ import Pages.Internal.Platform.ToJsPayload as ToJsPayload exposing (ToJsSuccessP
|
||||
import Pages.Internal.StaticHttpBody as StaticHttpBody
|
||||
import Pages.PagePath as PagePath exposing (PagePath)
|
||||
import Pages.ProgramConfig exposing (ProgramConfig)
|
||||
import Pages.StaticHttp as StaticHttp exposing (RequestDetails)
|
||||
import Pages.StaticHttpRequest as StaticHttpRequest
|
||||
import RenderRequest exposing (RenderRequest)
|
||||
import SecretsDict exposing (SecretsDict)
|
||||
@ -373,7 +373,7 @@ initLegacy renderRequest { secrets, mode, staticHttpCache } contentCache config
|
||||
RenderRequest.SinglePage _ serverRequestPayload _ ->
|
||||
StaticResponses.renderSingleRoute config
|
||||
serverRequestPayload
|
||||
(StaticHttp.map2 (\_ _ -> ())
|
||||
(DataSource.map2 (\_ _ -> ())
|
||||
(config.staticData serverRequestPayload.frontmatter)
|
||||
config.sharedStaticData
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
module Pages.Internal.Platform.Effect exposing (..)
|
||||
|
||||
import DataSource exposing (RequestDetails)
|
||||
import Pages.Internal.Platform.ToJsPayload exposing (ToJsPayload, ToJsSuccessPayloadNewCombined)
|
||||
import Pages.StaticHttp exposing (RequestDetails)
|
||||
|
||||
|
||||
type Effect
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), StaticResponses, error, init, nextStep, renderSingleRoute, update)
|
||||
|
||||
import BuildError exposing (BuildError)
|
||||
import DataSource exposing (RequestDetails)
|
||||
import Dict exposing (Dict)
|
||||
import Dict.Extra
|
||||
import Pages.Internal.ApplicationType as ApplicationType
|
||||
@ -8,7 +9,6 @@ import Pages.Internal.Platform.Mode as Mode exposing (Mode)
|
||||
import Pages.Internal.Platform.ToJsPayload as ToJsPayload exposing (ToJsPayload)
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.SiteConfig exposing (SiteConfig)
|
||||
import Pages.StaticHttp as StaticHttp exposing (RequestDetails)
|
||||
import Pages.StaticHttp.Request as HashRequest
|
||||
import Pages.StaticHttpRequest as StaticHttpRequest
|
||||
import RequestsAndPending exposing (RequestsAndPending)
|
||||
@ -24,7 +24,7 @@ type StaticResponses
|
||||
|
||||
|
||||
type StaticHttpResult
|
||||
= NotFetched (StaticHttp.Request ()) (Dict String (Result () String))
|
||||
= NotFetched (DataSource.Request ()) (Dict String (Result () String))
|
||||
|
||||
|
||||
error : StaticResponses
|
||||
@ -34,12 +34,12 @@ error =
|
||||
|
||||
init :
|
||||
{ config
|
||||
| getStaticRoutes : StaticHttp.Request (List route)
|
||||
| getStaticRoutes : DataSource.Request (List route)
|
||||
, site : SiteConfig route siteStaticData
|
||||
, staticData : route -> StaticHttp.Request pageStaticData
|
||||
, sharedStaticData : StaticHttp.Request sharedStaticData
|
||||
, staticData : route -> DataSource.Request pageStaticData
|
||||
, sharedStaticData : DataSource.Request sharedStaticData
|
||||
, generateFiles :
|
||||
StaticHttp.Request
|
||||
DataSource.Request
|
||||
(List
|
||||
(Result
|
||||
String
|
||||
@ -52,9 +52,9 @@ init :
|
||||
-> StaticResponses
|
||||
init config =
|
||||
NotFetched
|
||||
(StaticHttp.map3 (\_ _ _ -> ())
|
||||
(DataSource.map3 (\_ _ _ -> ())
|
||||
(config.getStaticRoutes
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\resolvedRoutes ->
|
||||
config.site resolvedRoutes |> .staticData
|
||||
)
|
||||
@ -71,7 +71,7 @@ renderSingleRoute :
|
||||
| routeToPath : route -> List String
|
||||
}
|
||||
-> { path : PagePath, frontmatter : route }
|
||||
-> StaticHttp.Request a
|
||||
-> DataSource.Request a
|
||||
-> StaticResponses
|
||||
renderSingleRoute config pathAndRoute request =
|
||||
[ pathAndRoute.frontmatter ]
|
||||
@ -79,7 +79,7 @@ renderSingleRoute config pathAndRoute request =
|
||||
(\route ->
|
||||
( config.routeToPath route |> String.join "/"
|
||||
, NotFetched
|
||||
(request |> StaticHttp.map (\_ -> ()))
|
||||
(request |> DataSource.map (\_ -> ()))
|
||||
Dict.empty
|
||||
)
|
||||
)
|
||||
@ -151,13 +151,13 @@ type NextStep route
|
||||
|
||||
nextStep :
|
||||
{ config
|
||||
| getStaticRoutes : StaticHttp.Request (List route)
|
||||
| getStaticRoutes : DataSource.Request (List route)
|
||||
, routeToPath : route -> List String
|
||||
, staticData : route -> StaticHttp.Request pageStaticData
|
||||
, sharedStaticData : StaticHttp.Request sharedStaticData
|
||||
, staticData : route -> DataSource.Request pageStaticData
|
||||
, sharedStaticData : DataSource.Request sharedStaticData
|
||||
, site : SiteConfig route siteStaticData
|
||||
, generateFiles :
|
||||
StaticHttp.Request
|
||||
DataSource.Request
|
||||
(List
|
||||
(Result
|
||||
String
|
||||
@ -319,7 +319,7 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
|
||||
in
|
||||
if pendingRequests then
|
||||
let
|
||||
requestContinuations : List ( String, StaticHttp.Request () )
|
||||
requestContinuations : List ( String, DataSource.Request () )
|
||||
requestContinuations =
|
||||
staticResponses
|
||||
|> Dict.toList
|
||||
@ -380,7 +380,7 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
|
||||
resolvedRoutes : Result StaticHttpRequest.Error (List route)
|
||||
resolvedRoutes =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
(StaticHttp.map3
|
||||
(DataSource.map3
|
||||
(\routes _ _ ->
|
||||
routes
|
||||
)
|
||||
@ -400,7 +400,7 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
|
||||
let
|
||||
entry =
|
||||
NotFetched
|
||||
(StaticHttp.map2 (\_ _ -> ())
|
||||
(DataSource.map2 (\_ _ -> ())
|
||||
config.sharedStaticData
|
||||
(config.staticData route)
|
||||
)
|
||||
@ -469,7 +469,7 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
|
||||
performStaticHttpRequests :
|
||||
Dict String (Maybe String)
|
||||
-> SecretsDict
|
||||
-> List ( String, StaticHttp.Request a )
|
||||
-> List ( String, DataSource.Request a )
|
||||
-> Result (List BuildError) (List { unmasked : RequestDetails, masked : RequestDetails })
|
||||
performStaticHttpRequests allRawResponses secrets staticRequests =
|
||||
staticRequests
|
||||
|
@ -1,13 +1,13 @@
|
||||
module Pages.ProgramConfig exposing (..)
|
||||
|
||||
import Browser.Navigation
|
||||
import DataSource
|
||||
import Head
|
||||
import Html exposing (Html)
|
||||
import Json.Decode as Decode
|
||||
import Json.Encode
|
||||
import Pages.PagePath exposing (PagePath)
|
||||
import Pages.SiteConfig exposing (SiteConfig)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Url exposing (Url)
|
||||
|
||||
|
||||
@ -27,8 +27,8 @@ type alias ProgramConfig userMsg userModel route siteStaticData pageStaticData s
|
||||
-> ( userModel, Cmd userMsg )
|
||||
, update : pageStaticData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, Cmd userMsg )
|
||||
, subscriptions : route -> PagePath -> userModel -> Sub userMsg
|
||||
, sharedStaticData : StaticHttp.Request sharedStaticData
|
||||
, staticData : route -> StaticHttp.Request pageStaticData
|
||||
, sharedStaticData : DataSource.Request sharedStaticData
|
||||
, staticData : route -> DataSource.Request pageStaticData
|
||||
, view :
|
||||
{ path : PagePath
|
||||
, frontmatter : route
|
||||
@ -39,14 +39,14 @@ type alias ProgramConfig userMsg userModel route siteStaticData pageStaticData s
|
||||
{ view : userModel -> { title : String, body : Html userMsg }
|
||||
, head : List Head.Tag
|
||||
}
|
||||
, getStaticRoutes : StaticHttp.Request (List route)
|
||||
, getStaticRoutes : DataSource.Request (List route)
|
||||
, urlToRoute : Url -> route
|
||||
, routeToPath : route -> List String
|
||||
, site : SiteConfig route siteStaticData
|
||||
, toJsPort : Json.Encode.Value -> Cmd Never
|
||||
, fromJsPort : Sub Decode.Value
|
||||
, generateFiles :
|
||||
StaticHttp.Request
|
||||
DataSource.Request
|
||||
(List
|
||||
(Result
|
||||
String
|
||||
|
@ -16,7 +16,7 @@ GITHUB_TOKEN=abcd1234 API_KEY=xyz789 elm-pages build
|
||||
And your StaticHttp request in your Elm code looks like this:
|
||||
|
||||
import Pages.Secrets as Secrets
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import DataSource
|
||||
|
||||
StaticHttp.request
|
||||
(Secrets.succeed
|
||||
|
@ -1,21 +1,21 @@
|
||||
module Pages.SiteConfig exposing (SiteConfig)
|
||||
|
||||
import DataSource
|
||||
import Head
|
||||
import Pages.Manifest
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
|
||||
|
||||
type alias SiteConfig route staticData =
|
||||
List route
|
||||
->
|
||||
{ staticData : StaticHttp.Request staticData
|
||||
{ staticData : DataSource.Request staticData
|
||||
, canonicalUrl : String
|
||||
, manifest : staticData -> Pages.Manifest.Config
|
||||
, head :
|
||||
staticData
|
||||
-> List Head.Tag
|
||||
, generateFiles :
|
||||
StaticHttp.Request
|
||||
DataSource.Request
|
||||
(List
|
||||
(Result
|
||||
String
|
||||
|
@ -6,8 +6,8 @@ module Pages.StaticFile exposing (body, frontmatter, glob, rawFile, request)
|
||||
|
||||
-}
|
||||
|
||||
import DataSource
|
||||
import OptimizedDecoder exposing (Decoder)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Secrets
|
||||
|
||||
|
||||
@ -30,13 +30,13 @@ body =
|
||||
|
||||
|
||||
{-| -}
|
||||
request : String -> Decoder a -> StaticHttp.Request a
|
||||
request : String -> Decoder a -> DataSource.Request a
|
||||
request filePath =
|
||||
StaticHttp.get (Secrets.succeed <| "file://" ++ filePath)
|
||||
DataSource.get (Secrets.succeed <| "file://" ++ filePath)
|
||||
|
||||
|
||||
{-| -}
|
||||
glob : String -> StaticHttp.Request (List String)
|
||||
glob : String -> DataSource.Request (List String)
|
||||
glob pattern =
|
||||
StaticHttp.get (Secrets.succeed <| "glob://" ++ pattern)
|
||||
DataSource.get (Secrets.succeed <| "glob://" ++ pattern)
|
||||
(OptimizedDecoder.list OptimizedDecoder.string)
|
||||
|
@ -67,7 +67,7 @@ toBuildError path error =
|
||||
UserCalledStaticHttpFail decodeErrorMessage ->
|
||||
{ title = "Called Static Http Fail"
|
||||
, message =
|
||||
[ Terminal.text <| "I ran into a call to `Pages.StaticHttp.fail` with message: " ++ decodeErrorMessage
|
||||
[ Terminal.text <| "I ran into a call to `DataSource.fail` with message: " ++ decodeErrorMessage
|
||||
]
|
||||
, path = path
|
||||
, fatal = True
|
||||
|
@ -1,6 +1,7 @@
|
||||
module StaticHttpRequestsTests exposing (all)
|
||||
|
||||
import Codec
|
||||
import DataSource
|
||||
import Dict
|
||||
import Expect
|
||||
import Html
|
||||
@ -16,7 +17,6 @@ import Pages.Internal.StaticHttpBody as StaticHttpBody
|
||||
import Pages.Manifest as Manifest
|
||||
import Pages.PagePath as PagePath
|
||||
import Pages.ProgramConfig exposing (ProgramConfig)
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Pages.StaticHttp.Request as Request
|
||||
import PagesHttp
|
||||
import ProgramTest exposing (ProgramTest)
|
||||
@ -38,7 +38,7 @@ all =
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
@ -57,7 +57,7 @@ all =
|
||||
\() ->
|
||||
start
|
||||
[ ( [ "post-1" ]
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
--, StaticHttp.succeed 86
|
||||
)
|
||||
]
|
||||
@ -81,10 +81,10 @@ all =
|
||||
\() ->
|
||||
start
|
||||
[ ( [ "elm-pages" ]
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.succeed ())
|
||||
|> StaticHttp.andThen
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.succeed ())
|
||||
|> DataSource.andThen
|
||||
(\_ ->
|
||||
StaticHttp.get (Secrets.succeed "NEXT-REQUEST") (Decode.succeed ())
|
||||
DataSource.get (Secrets.succeed "NEXT-REQUEST") (Decode.succeed ())
|
||||
)
|
||||
)
|
||||
]
|
||||
@ -111,11 +111,11 @@ all =
|
||||
\() ->
|
||||
let
|
||||
getReq url decoder =
|
||||
StaticHttp.request
|
||||
DataSource.request
|
||||
(Secrets.succeed (get url))
|
||||
decoder
|
||||
|
||||
pokemonDetailRequest : StaticHttp.Request ()
|
||||
pokemonDetailRequest : DataSource.Request ()
|
||||
pokemonDetailRequest =
|
||||
getReq
|
||||
"https://pokeapi.co/api/v2/pokemon/"
|
||||
@ -128,8 +128,8 @@ all =
|
||||
)
|
||||
)
|
||||
)
|
||||
|> StaticHttp.resolve
|
||||
|> StaticHttp.map (\_ -> ())
|
||||
|> DataSource.resolve
|
||||
|> DataSource.map (\_ -> ())
|
||||
in
|
||||
start
|
||||
[ ( [ "elm-pages" ], pokemonDetailRequest )
|
||||
@ -231,10 +231,10 @@ all =
|
||||
\() ->
|
||||
start
|
||||
[ ( [ "elm-pages" ]
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
)
|
||||
, ( [ "elm-pages-starter" ]
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages-starter") starDecoder
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages-starter") starDecoder
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
@ -263,7 +263,7 @@ all =
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.field "stargazer_count" Decode.int)
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.field "stargazer_count" Decode.int)
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
@ -282,15 +282,15 @@ all =
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.unoptimizedRequest
|
||||
, DataSource.unoptimizedRequest
|
||||
(Secrets.succeed
|
||||
{ url = "https://api.github.com/repos/dillonkearns/elm-pages"
|
||||
, method = "GET"
|
||||
, headers = []
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
)
|
||||
(StaticHttp.expectUnoptimizedJson
|
||||
(DataSource.expectUnoptimizedJson
|
||||
(JD.field "stargazer_count" JD.int)
|
||||
)
|
||||
)
|
||||
@ -311,15 +311,15 @@ all =
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.unoptimizedRequest
|
||||
, DataSource.unoptimizedRequest
|
||||
(Secrets.succeed
|
||||
{ url = "https://example.com/file.txt"
|
||||
, method = "GET"
|
||||
, headers = []
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
)
|
||||
(StaticHttp.expectString Ok)
|
||||
(DataSource.expectString Ok)
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
@ -338,15 +338,15 @@ all =
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.unoptimizedRequest
|
||||
, DataSource.unoptimizedRequest
|
||||
(Secrets.succeed
|
||||
{ url = "https://example.com/file.txt"
|
||||
, method = "GET"
|
||||
, headers = []
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
)
|
||||
(StaticHttp.expectString
|
||||
(DataSource.expectString
|
||||
(\string ->
|
||||
if String.toUpper string == string then
|
||||
Ok string
|
||||
@ -375,12 +375,12 @@ String was not uppercased"""
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.request
|
||||
, DataSource.request
|
||||
(Secrets.succeed
|
||||
{ method = "POST"
|
||||
, url = "https://api.github.com/repos/dillonkearns/elm-pages"
|
||||
, headers = []
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
)
|
||||
(Decode.field "stargazer_count" Decode.int)
|
||||
@ -395,7 +395,7 @@ String was not uppercased"""
|
||||
, [ ( { method = "POST"
|
||||
, url = "https://api.github.com/repos/dillonkearns/elm-pages"
|
||||
, headers = []
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
, """{"stargazer_count":86}"""
|
||||
)
|
||||
@ -406,10 +406,10 @@ String was not uppercased"""
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.field "stargazer_count" Decode.int)
|
||||
|> StaticHttp.andThen
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.field "stargazer_count" Decode.int)
|
||||
|> DataSource.andThen
|
||||
(\_ ->
|
||||
StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages-starter") (Decode.field "stargazer_count" Decode.int)
|
||||
DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages-starter") (Decode.field "stargazer_count" Decode.int)
|
||||
)
|
||||
)
|
||||
]
|
||||
@ -436,9 +436,9 @@ String was not uppercased"""
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.map2 (\_ _ -> ())
|
||||
(StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.field "stargazer_count" Decode.int))
|
||||
(StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages-starter") (Decode.field "stargazer_count" Decode.int))
|
||||
, DataSource.map2 (\_ _ -> ())
|
||||
(DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.field "stargazer_count" Decode.int))
|
||||
(DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages-starter") (Decode.field "stargazer_count" Decode.int))
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
@ -464,7 +464,7 @@ String was not uppercased"""
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.succeed ()
|
||||
, DataSource.succeed ()
|
||||
)
|
||||
]
|
||||
|> expectSuccess [ ( "", [] ) ]
|
||||
@ -472,9 +472,9 @@ String was not uppercased"""
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.map2 (\_ _ -> ())
|
||||
(StaticHttp.get (Secrets.succeed "http://example.com") (Decode.succeed ()))
|
||||
(StaticHttp.get (Secrets.succeed "http://example.com") (Decode.succeed ()))
|
||||
, DataSource.map2 (\_ _ -> ())
|
||||
(DataSource.get (Secrets.succeed "http://example.com") (Decode.succeed ()))
|
||||
(DataSource.get (Secrets.succeed "http://example.com") (Decode.succeed ()))
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
@ -493,7 +493,7 @@ String was not uppercased"""
|
||||
\() ->
|
||||
start
|
||||
[ ( [ "elm-pages" ]
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.fail "The user should get this message from the CLI.")
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.fail "The user should get this message from the CLI.")
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
@ -518,7 +518,7 @@ I encountered some errors while decoding this JSON:
|
||||
\() ->
|
||||
start
|
||||
[ ( [ "elm-pages" ]
|
||||
, StaticHttp.get
|
||||
, DataSource.get
|
||||
(Secrets.succeed
|
||||
(\apiKey ->
|
||||
"https://api.github.com/repos/dillonkearns/elm-pages?apiKey=" ++ apiKey
|
||||
@ -526,9 +526,9 @@ I encountered some errors while decoding this JSON:
|
||||
|> Secrets.with "API_KEY"
|
||||
)
|
||||
Decode.string
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\url ->
|
||||
StaticHttp.get
|
||||
DataSource.get
|
||||
(Secrets.succeed
|
||||
(\missingSecret ->
|
||||
url ++ "?apiKey=" ++ missingSecret
|
||||
@ -560,7 +560,7 @@ So maybe MISSING should be API_KEY"""
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.succeed ())
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") (Decode.succeed ())
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpResponse
|
||||
@ -592,13 +592,13 @@ Payload sent back invalid JSON""")
|
||||
\() ->
|
||||
start
|
||||
[ ( []
|
||||
, StaticHttp.request
|
||||
, DataSource.request
|
||||
(Secrets.succeed
|
||||
(\apiKey bearer ->
|
||||
{ url = "https://api.github.com/repos/dillonkearns/elm-pages?apiKey=" ++ apiKey
|
||||
, method = "GET"
|
||||
, headers = [ ( "Authorization", "Bearer " ++ bearer ) ]
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
)
|
||||
|> Secrets.with "API_KEY"
|
||||
@ -629,7 +629,7 @@ Payload sent back invalid JSON""")
|
||||
, headers =
|
||||
[ ( "Authorization", "Bearer <BEARER>" )
|
||||
]
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
, """{}"""
|
||||
)
|
||||
@ -649,7 +649,7 @@ Payload sent back invalid JSON""")
|
||||
)
|
||||
]
|
||||
[ ( []
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
)
|
||||
]
|
||||
|> expectSuccess
|
||||
@ -672,7 +672,7 @@ Payload sent back invalid JSON""")
|
||||
)
|
||||
]
|
||||
[ ( []
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
@ -692,7 +692,7 @@ Payload sent back invalid JSON""")
|
||||
[ test "initial requests are sent out" <|
|
||||
\() ->
|
||||
startLowLevel
|
||||
(StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||
(DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||
(starDecoder
|
||||
|> Decode.map
|
||||
(\starCount ->
|
||||
@ -724,7 +724,7 @@ Payload sent back invalid JSON""")
|
||||
, test "it sends success port when no HTTP requests are needed because they're all cached" <|
|
||||
\() ->
|
||||
startLowLevel
|
||||
(StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages-starter")
|
||||
(DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages-starter")
|
||||
(starDecoder
|
||||
|> Decode.map
|
||||
(\starCount ->
|
||||
@ -753,7 +753,7 @@ Payload sent back invalid JSON""")
|
||||
)
|
||||
]
|
||||
[ ( []
|
||||
, StaticHttp.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
, DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages") starDecoder
|
||||
)
|
||||
]
|
||||
|> expectSuccessNew
|
||||
@ -780,7 +780,7 @@ type Route
|
||||
= Route String
|
||||
|
||||
|
||||
start : List ( List String, StaticHttp.Request a ) -> ProgramTest (Model Route) Msg Effect
|
||||
start : List ( List String, DataSource.Request a ) -> ProgramTest (Model Route) Msg Effect
|
||||
start pages =
|
||||
startWithHttpCache (Ok ()) [] pages
|
||||
|
||||
@ -788,14 +788,14 @@ start pages =
|
||||
startWithHttpCache :
|
||||
Result String ()
|
||||
-> List ( Request.Request, String )
|
||||
-> List ( List String, StaticHttp.Request a )
|
||||
-> List ( List String, DataSource.Request a )
|
||||
-> ProgramTest (Model Route) Msg Effect
|
||||
startWithHttpCache =
|
||||
startLowLevel (StaticHttp.succeed [])
|
||||
startLowLevel (DataSource.succeed [])
|
||||
|
||||
|
||||
startLowLevel :
|
||||
StaticHttp.Request
|
||||
DataSource.Request
|
||||
(List
|
||||
(Result
|
||||
String
|
||||
@ -806,7 +806,7 @@ startLowLevel :
|
||||
)
|
||||
-> Result String ()
|
||||
-> List ( Request.Request, String )
|
||||
-> List ( List String, StaticHttp.Request a )
|
||||
-> List ( List String, DataSource.Request a )
|
||||
-> ProgramTest (Model Route) Msg Effect
|
||||
startLowLevel generateFiles documentBodyResult staticHttpCache pages =
|
||||
let
|
||||
@ -826,7 +826,7 @@ startLowLevel generateFiles documentBodyResult staticHttpCache pages =
|
||||
|> List.map Tuple.first
|
||||
|> List.map (String.join "/")
|
||||
|> List.map Route
|
||||
|> StaticHttp.succeed
|
||||
|> DataSource.succeed
|
||||
, urlToRoute = .path >> Route
|
||||
, update = \_ _ _ _ -> ( (), Cmd.none )
|
||||
, staticData =
|
||||
@ -844,13 +844,13 @@ startLowLevel generateFiles documentBodyResult staticHttpCache pages =
|
||||
case thing of
|
||||
Just request ->
|
||||
--\_ _ -> { view = \_ -> { title = "Title", body = Html.text "" }, head = [] }
|
||||
request |> StaticHttp.map (\_ -> ())
|
||||
request |> DataSource.map (\_ -> ())
|
||||
|
||||
Nothing ->
|
||||
Debug.todo <| "Couldn't find page: " ++ pageRoute ++ "\npages: " ++ Debug.toString pages
|
||||
, site =
|
||||
\_ ->
|
||||
{ staticData = StaticHttp.succeed ()
|
||||
{ staticData = DataSource.succeed ()
|
||||
, canonicalUrl = "canonical-site-url"
|
||||
, manifest = \_ -> manifest
|
||||
, head = \_ -> []
|
||||
@ -877,7 +877,7 @@ startLowLevel generateFiles documentBodyResult staticHttpCache pages =
|
||||
Debug.todo <| "Couldn't find page: " ++ Debug.toString page ++ "\npages: " ++ Debug.toString pages
|
||||
, subscriptions = \_ _ _ -> Sub.none
|
||||
, routeToPath = \(Route route) -> route |> String.split "/"
|
||||
, sharedStaticData = StaticHttp.succeed ()
|
||||
, sharedStaticData = DataSource.succeed ()
|
||||
|
||||
--, onPageChange = Just (\_ -> ())
|
||||
, onPageChange = Nothing
|
||||
@ -1121,5 +1121,5 @@ get url =
|
||||
{ method = "GET"
|
||||
, url = url
|
||||
, headers = []
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
module StaticHttpUnitTests exposing (all)
|
||||
|
||||
import DataSource
|
||||
import Dict
|
||||
import Expect
|
||||
import OptimizedDecoder as Decode
|
||||
import Pages.Internal.ApplicationType as ApplicationType
|
||||
import Pages.StaticHttp as StaticHttp
|
||||
import Pages.StaticHttp.Request as Request
|
||||
import Pages.StaticHttpRequest as StaticHttpRequest
|
||||
import Secrets
|
||||
@ -12,7 +12,7 @@ import Test exposing (Test, describe, test)
|
||||
|
||||
|
||||
getWithoutSecrets url =
|
||||
StaticHttp.get (Secrets.succeed url)
|
||||
DataSource.get (Secrets.succeed url)
|
||||
|
||||
|
||||
requestsDict requestMap =
|
||||
@ -31,7 +31,7 @@ get url =
|
||||
{ method = "GET"
|
||||
, url = url
|
||||
, headers = []
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
|
||||
|
||||
@ -40,8 +40,8 @@ all =
|
||||
describe "Static Http Requests unit tests"
|
||||
[ test "andThen" <|
|
||||
\() ->
|
||||
StaticHttp.get (Secrets.succeed "first") (Decode.succeed "NEXT")
|
||||
|> StaticHttp.andThen
|
||||
DataSource.get (Secrets.succeed "first") (Decode.succeed "NEXT")
|
||||
|> DataSource.andThen
|
||||
(\_ ->
|
||||
getWithoutSecrets "NEXT" (Decode.succeed ())
|
||||
)
|
||||
@ -58,8 +58,8 @@ all =
|
||||
)
|
||||
, test "andThen staring with done" <|
|
||||
\() ->
|
||||
StaticHttp.succeed ()
|
||||
|> StaticHttp.andThen
|
||||
DataSource.succeed ()
|
||||
|> DataSource.andThen
|
||||
(\_ ->
|
||||
getWithoutSecrets "NEXT" (Decode.succeed ())
|
||||
)
|
||||
@ -76,12 +76,12 @@ all =
|
||||
, test "map" <|
|
||||
\() ->
|
||||
getWithoutSecrets "first" (Decode.succeed "NEXT")
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\_ ->
|
||||
-- StaticHttp.get continueUrl (Decode.succeed ())
|
||||
getWithoutSecrets "NEXT" (Decode.succeed ())
|
||||
)
|
||||
|> StaticHttp.map (\_ -> ())
|
||||
|> DataSource.map (\_ -> ())
|
||||
|> (\request ->
|
||||
StaticHttpRequest.resolveUrls ApplicationType.Cli
|
||||
request
|
||||
@ -96,7 +96,7 @@ all =
|
||||
, test "andThen chain with 1 response available and 1 pending" <|
|
||||
\() ->
|
||||
getWithoutSecrets "first" (Decode.succeed "NEXT")
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\_ ->
|
||||
getWithoutSecrets "NEXT" (Decode.succeed ())
|
||||
)
|
||||
@ -113,10 +113,10 @@ all =
|
||||
, test "andThen chain with 1 response available and 2 pending" <|
|
||||
\() ->
|
||||
getWithoutSecrets "first" Decode.int
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\_ ->
|
||||
getWithoutSecrets "NEXT" Decode.string
|
||||
|> StaticHttp.andThen
|
||||
|> DataSource.andThen
|
||||
(\_ ->
|
||||
getWithoutSecrets "LAST"
|
||||
Decode.string
|
||||
@ -135,10 +135,10 @@ all =
|
||||
]
|
||||
|
||||
|
||||
getReq : String -> StaticHttp.RequestDetails
|
||||
getReq : String -> DataSource.RequestDetails
|
||||
getReq url =
|
||||
{ url = url
|
||||
, method = "GET"
|
||||
, headers = []
|
||||
, body = StaticHttp.emptyBody
|
||||
, body = DataSource.emptyBody
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user