Change Page.* modules to be Route.* modules.

This commit is contained in:
Dillon Kearns 2022-03-05 09:05:12 -08:00
parent a828ecee58
commit 0310152df4
35 changed files with 9541 additions and 287 deletions

View File

@ -1,4 +1,4 @@
module Page.Blog exposing (Data, Model, Msg, page)
module Route.Blog exposing (Data, Model, Msg, page)
import Article
import DataSource

View File

@ -1,4 +1,4 @@
module Page.Blog.Slug_ exposing (Data, Model, Msg, page)
module Route.Blog.Slug_ exposing (Data, Model, Msg, page)
import Article
import Cloudinary

View File

@ -1,4 +1,4 @@
module Page.Docs.Section__ exposing (Data, Model, Msg, page)
module Route.Docs.Section__ exposing (Data, Model, Msg, page)
import Css
import Css.Global

View File

@ -1,4 +1,4 @@
module Page.Index exposing (Data, Model, Msg, page)
module Route.Index exposing (Data, Model, Msg, page)
import Css
import DataSource exposing (DataSource)
@ -116,7 +116,7 @@ landingView =
, buttonLink = Route.Docs__Section__ { section = Nothing }
, svgIcon = "M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"
, code =
( "src/Page/Repo/Name_.elm", """module Page.Repo.Name_ exposing (Data, Model, Msg, page)
( "src/Page/Repo/Name_.elm", """module Route.Repo.Name_ exposing (Data, Model, Msg, page)
type alias Data = Int
type alias RouteParams = { name : String }

View File

@ -1,4 +1,4 @@
module Page.Showcase exposing (Data, Model, Msg, page)
module Route.Showcase exposing (Data, Model, Msg, page)
import Css
import DataSource

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
module Page.Blog.Slug_ exposing (Data, Model, Msg, page)
module Route.Blog.Slug_ exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Head

View File

@ -1,4 +1,4 @@
module Page.CookieTest exposing (Data, Model, Msg, page)
module Route.CookieTest exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Head

View File

@ -1,4 +1,4 @@
module Page.FileData exposing (Data, Model, Msg, page)
module Route.FileData exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import DataSource.File

View File

@ -1,4 +1,4 @@
module Page.Index exposing (Data, Model, Msg, page)
module Route.Index exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import DataSource.File

View File

@ -1,4 +1,4 @@
module Page.Links exposing (Data, Model, Msg, page)
module Route.Links exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Head

View File

@ -1,4 +1,4 @@
module Page.Test.BasicAuth exposing (Data, Model, Msg, page)
module Route.Test.BasicAuth exposing (Data, Model, Msg, page)
import Base64
import DataSource exposing (DataSource)

View File

@ -1,4 +1,4 @@
module Page.Test.ResponseHeaders exposing (Data, Model, Msg, page)
module Route.Test.ResponseHeaders exposing (Data, Model, Msg, page)
import Base64
import DataSource exposing (DataSource)

View File

@ -1,4 +1,4 @@
module Page.Blog.Slug_ exposing (Data, Model, Msg, page)
module Route.Blog.Slug_ exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Head

View File

@ -1,4 +1,4 @@
module Page.Index exposing (Data, Model, Msg, page)
module Route.Index exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Head

View File

@ -1,4 +1,4 @@
module Page.BasicAuth exposing (Data, Model, Msg, page)
module Route.BasicAuth exposing (Data, Model, Msg, page)
import Base64
import DataSource exposing (DataSource)

View File

@ -1,4 +1,4 @@
module Page.FileUpload exposing (Data, Model, Msg, page)
module Route.FileUpload exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Head

View File

@ -1,4 +1,4 @@
module Page.Form exposing (Data, Model, Msg, page)
module Route.Form exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Date exposing (Date)

View File

@ -1,4 +1,4 @@
module Page.FormEvent exposing (Data, Model, Msg, page)
module Route.FormEvent exposing (Data, Model, Msg, page)
import Browser.Navigation
import DataSource exposing (DataSource)

View File

@ -1,4 +1,4 @@
module Page.Greet exposing (Data, Model, Msg, page)
module Route.Greet exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Dict exposing (Dict)

View File

@ -1,4 +1,4 @@
module Page.Hex.Hex_ exposing (Data, Model, Msg, page)
module Route.Hex.Hex_ exposing (Data, Model, Msg, page)
import ColorHelpers
import DataSource exposing (DataSource)

View File

@ -1,4 +1,4 @@
module Page.Index exposing (Data, Model, Msg, page)
module Route.Index exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import DataSource.Env as Env

View File

@ -1,4 +1,4 @@
module Page.Login exposing (Data, Model, Msg, page)
module Route.Login exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Dict exposing (Dict)

View File

@ -1,4 +1,4 @@
module Page.Named.Color_ exposing (Data, Model, Msg, page)
module Route.Named.Color_ exposing (Data, Model, Msg, page)
import ColorHelpers
import DataSource exposing (DataSource)

View File

@ -1,4 +1,4 @@
module Page.PokedexNumber_ exposing (Data, Model, Msg, page)
module Route.PokedexNumber_ exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import DataSource.Http

View File

@ -1,4 +1,4 @@
module Page.PortTest exposing (Data, Model, Msg, page)
module Route.PortTest exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import DataSource.Port

View File

@ -1,4 +1,4 @@
module Page.RedirectLinks exposing (Data, Model, Msg, page)
module Route.RedirectLinks exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Head

View File

@ -1,4 +1,4 @@
module Page.Rgb.Red_.Green_.Blue_ exposing (Data, Model, Msg, page)
module Route.Rgb.Red_.Green_.Blue_ exposing (Data, Model, Msg, page)
import ColorHelpers
import DataSource exposing (DataSource)

View File

@ -1,4 +1,4 @@
module Page.Secret exposing (Data, Model, Msg, page)
module Route.Secret exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import DataSource.File

View File

@ -1,4 +1,4 @@
module Page.TailwindForm exposing (Data, Model, Msg, page)
module Route.TailwindForm exposing (Data, Model, Msg, page)
import Browser.Dom
import Css exposing (Color)

View File

@ -1,4 +1,4 @@
module Page.Time exposing (Data, Model, Msg, page)
module Route.Time exposing (Data, Model, Msg, page)
import DataSource exposing (DataSource)
import Dict exposing (Dict)

View File

@ -1,4 +1,4 @@
module Page.Todos exposing (Data, Model, Msg, page)
module Route.Todos exposing (Data, Model, Msg, page)
import Api.InputObject
import Api.Mutation

View File

@ -14,7 +14,7 @@ async function run({ moduleName, withState, serverRender, withFallback }) {
withFallback
);
const fullFilePath = path.join(
`app/Page/`,
`app/Route/`,
moduleName.replace(/\./g, "/") + ".elm"
);
await fs.tryMkdir(path.dirname(fullFilePath));

View File

@ -8,8 +8,8 @@ const routeHelpers = require("./route-codegen-helpers");
* @param {'browser' | 'cli'} phase
*/
function generateTemplateModuleConnector(basePath, phase) {
const templates = globby.sync(["app/Page/**/*.elm"], {}).map((file) => {
const captures = mm.capture("app/Page/**/*.elm", file);
const templates = globby.sync(["app/Route/**/*.elm"], {}).map((file) => {
const captures = mm.capture("app/Route/**/*.elm", file);
if (captures) {
return path.join(captures[0], captures[1]).split(path.sep);
} else {
@ -76,7 +76,7 @@ import Task exposing (Task)
import Url exposing (Url)
import View
${templates.map((name) => `import Page.${name.join(".")}`).join("\n")}
${templates.map((name) => `import Route.${name.join(".")}`).join("\n")}
type alias Model =
@ -99,7 +99,7 @@ type PageModel
= ${templates
.map(
(name) =>
`Model${pathNormalizedName(name)} Page.${moduleName(name)}.Model\n`
`Model${pathNormalizedName(name)} Route.${moduleName(name)}.Model\n`
)
.join(" | ")}
| NotFound
@ -121,7 +121,7 @@ type Msg
| ${templates
.map(
(name) =>
`Msg${pathNormalizedName(name)} Page.${moduleName(name)}.Msg\n`
`Msg${pathNormalizedName(name)} Route.${moduleName(name)}.Msg\n`
)
.join(" | ")}
@ -131,7 +131,7 @@ type PageData
| ${templates
.map(
(name) =>
`Data${pathNormalizedName(name)} Page.${moduleName(name)}.Data\n`
`Data${pathNormalizedName(name)} Route.${moduleName(name)}.Data\n`
)
.join(" | ")}
@ -162,7 +162,7 @@ view page maybePageUrl globalData pageData =
\\model ->
case model.page of
Model${pathNormalizedName(name)} subModel ->
Page.${moduleName(name)}.page.view
Route.${moduleName(name)}.page.view
maybePageUrl
model.global
subModel
@ -181,7 +181,7 @@ view page maybePageUrl globalData pageData =
, head = ${
phase === "browser"
? "[]"
: `Page.${moduleName(name)}.page.head
: `Route.${moduleName(name)}.page.head
{ data = data
, sharedData = globalData
, routeParams = ${emptyRouteParams(name) ? "{}" : "s"}
@ -243,7 +243,7 @@ init currentGlobalModel userFlags sharedData pageData navigationKey maybePagePat
}, justPath ), Data${pathNormalizedName(
name
)} thisPageData ) ->
Page.${moduleName(name)}.page.init
Route.${moduleName(name)}.page.init
(Maybe.andThen .pageUrl maybePagePath)
sharedModel
{ data = thisPageData
@ -346,7 +346,7 @@ update sharedData pageData navigationKey msg model =
name,
"routeParams"
)}, pageUrl, justPage ) ) ->
Page.${moduleName(name)}.page.update
Route.${moduleName(name)}.page.update
pageUrl
{ data = thisPageData
, sharedData = sharedData
@ -395,7 +395,7 @@ templateSubscriptions route path model =
name,
"routeParams"
)} ) ->
Page.${moduleName(name)}.page.subscriptions
Route.${moduleName(name)}.page.subscriptions
Nothing -- TODO wire through value
${routeHelpers.referenceRouteParams(name, "routeParams")}
path
@ -504,7 +504,7 @@ byteEncodePageData pageData =
${templates
.map(
(name) => ` Data${pathNormalizedName(name)} thisPageData ->
Page.${name.join(".")}.w3_encode_Data thisPageData
Route.${name.join(".")}.w3_encode_Data thisPageData
`
)
.join("\n")}
@ -573,7 +573,7 @@ ${templates
emptyRouteParams(name)
? `Route.${routeHelpers.routeVariant(name)}`
: `(Route.${routeHelpers.routeVariant(name)} _)`
}) ->\n Page.${name.join(
}) ->\n Route.${name.join(
"."
)}.w3_decode_Data |> Bytes.Decode.map Data${routeHelpers.routeVariant(
name
@ -594,7 +594,7 @@ dataForRoute route =
emptyRouteParams(name)
? `Route.${routeHelpers.routeVariant(name)}`
: `(Route.${routeHelpers.routeVariant(name)} routeParams)`
} ->\n Page.${name.join(
} ->\n Route.${name.join(
"."
)}.page.data ${routeHelpers.referenceRouteParams(
name,
@ -620,7 +620,7 @@ handleRoute maybeRoute =
routeHelpers.parseRouteParams(name).length === 0
? ""
: " routeParams"
}) ->\n Page.${name.join(
}) ->\n Route.${name.join(
"."
)}.page.handleRoute { moduleName = [ ${name
.map((part) => `"${part}"`)
@ -693,7 +693,7 @@ routePatterns =
)
[ ${sortTemplates(templates)
.map((name) => {
return `{ kind = Page.${moduleName(
return `{ kind = Route.${moduleName(
name
)}.page.kind, pathPattern = "${routeHelpers.toPathPattern(
name
@ -747,7 +747,7 @@ getStaticRoutes =
DataSource.combine
[ ${templates
.map((name) => {
return `Page.${moduleName(
return `Route.${moduleName(
name
)}.page.staticRoutes |> DataSource.map (List.map ${
emptyRouteParams(name)

View File

@ -211,7 +211,11 @@ function toElmPathPattern(name) {
.flatMap((param) => {
switch (param.kind) {
case "static": {
return [`Pages.Internal.RoutePattern.StaticSegment "${camelToKebab(param.name)}"`];
return [
`Pages.Internal.RoutePattern.StaticSegment "${camelToKebab(
param.name
)}"`,
];
}
case "dynamic": {
return [`Pages.Internal.RoutePattern.DynamicSegment "${param.name}"`];