elm-pages 2.1.10 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolationsTest.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolationsTest.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Reporter.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Reporter.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Runner.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Runner.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/{template/public/style.css → review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/lock} +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +6795 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +27617 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +110 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +187 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/package.json +1 -0
- package/generator/review/elm-stuff/tests-0.19.1/src/Reporter.elm +26 -0
- package/generator/review/elm-stuff/tests-0.19.1/src/Runner.elm +62 -0
- package/generator/review/elm.json +13 -4
- package/{src → generator/review/src}/Pages/Review/NoContractViolations.elm +148 -148
- package/generator/review/tests/Pages/Review/NoContractViolationsTest.elm +331 -0
- package/generator/src/RouteBuilder.elm +420 -0
- package/generator/src/SharedTemplate.elm +4 -5
- package/generator/src/SiteConfig.elm +3 -9
- package/generator/src/build.js +308 -95
- package/generator/src/cli.js +103 -8
- package/generator/src/codegen.js +192 -35
- package/generator/src/compile-elm.js +183 -31
- package/generator/src/dev-server.js +353 -96
- package/generator/src/elm-application.json +3 -1
- package/generator/src/elm-codegen.js +34 -0
- package/generator/src/elm-file-constants.js +2 -0
- package/generator/src/error-formatter.js +20 -1
- package/generator/src/generate-template-module-connector.js +120 -924
- package/generator/src/hello.ts +5 -0
- package/generator/src/pre-render-html.js +58 -104
- package/generator/src/render-worker.js +27 -13
- package/generator/src/render.js +252 -197
- package/generator/src/request-cache-fs.js +18 -0
- package/generator/src/request-cache.js +128 -56
- package/generator/src/rewrite-client-elm-json.js +49 -0
- package/generator/src/route-codegen-helpers.js +62 -1
- package/generator/static-code/dev-style.css +22 -0
- package/generator/static-code/elm-pages.js +43 -39
- package/generator/static-code/hmr.js +98 -88
- package/generator/template/app/Api.elm +25 -0
- package/generator/template/app/ErrorPage.elm +38 -0
- package/generator/template/app/Route/Index.elm +87 -0
- package/generator/template/{src → app}/Shared.elm +34 -13
- package/generator/template/app/Site.elm +19 -0
- package/generator/template/{src → app}/View.elm +0 -0
- package/generator/template/elm-pages.config.mjs +5 -0
- package/generator/template/elm.json +14 -5
- package/generator/template/{public/index.js → index.ts} +7 -3
- package/generator/template/package.json +5 -5
- package/generator/template/public/favicon.ico +0 -0
- package/generator/template/public/images/icon-png.png +0 -0
- package/generator/template/src/.gitkeep +0 -0
- package/generator/template/style.css +4 -0
- package/package.json +30 -23
- package/src/ApiRoute.elm +176 -43
- package/src/BuildError.elm +10 -1
- package/src/CookieParser.elm +84 -0
- package/src/DataSource/Env.elm +38 -0
- package/src/DataSource/File.elm +27 -16
- package/src/DataSource/Glob.elm +126 -80
- package/src/DataSource/Http.elm +283 -304
- package/src/DataSource/Internal/Glob.elm +5 -21
- package/src/DataSource/Internal/Request.elm +25 -0
- package/src/DataSource/Port.elm +17 -14
- package/src/DataSource.elm +55 -318
- package/src/Form/Field.elm +717 -0
- package/src/Form/FieldStatus.elm +36 -0
- package/src/Form/FieldView.elm +417 -0
- package/src/Form/FormData.elm +22 -0
- package/src/Form/Validation.elm +391 -0
- package/src/Form/Value.elm +118 -0
- package/src/Form.elm +1683 -0
- package/src/FormData.elm +58 -0
- package/src/FormDecoder.elm +102 -0
- package/src/Head/Seo.elm +12 -4
- package/src/Head.elm +12 -2
- package/src/HtmlPrinter.elm +1 -1
- package/src/Internal/ApiRoute.elm +17 -4
- package/src/Internal/Request.elm +7 -0
- package/src/PageServerResponse.elm +68 -0
- package/src/Pages/ContentCache.elm +1 -229
- package/src/Pages/Fetcher.elm +58 -0
- package/src/Pages/FormState.elm +256 -0
- package/src/Pages/Generate.elm +800 -0
- package/src/Pages/Internal/Form.elm +17 -0
- package/src/Pages/Internal/NotFoundReason.elm +3 -55
- package/src/Pages/Internal/Platform/Cli.elm +777 -579
- package/src/Pages/Internal/Platform/Effect.elm +5 -5
- package/src/Pages/Internal/Platform/StaticResponses.elm +178 -394
- package/src/Pages/Internal/Platform/ToJsPayload.elm +24 -23
- package/src/Pages/Internal/Platform.elm +1244 -504
- package/src/Pages/Internal/ResponseSketch.elm +19 -0
- package/src/Pages/Internal/RoutePattern.elm +596 -45
- package/src/Pages/Manifest.elm +26 -0
- package/src/Pages/Msg.elm +79 -0
- package/src/Pages/ProgramConfig.elm +67 -14
- package/src/Pages/SiteConfig.elm +3 -6
- package/src/Pages/StaticHttp/Request.elm +4 -2
- package/src/Pages/StaticHttpRequest.elm +50 -215
- package/src/Pages/Transition.elm +70 -0
- package/src/Path.elm +1 -0
- package/src/Pattern.elm +98 -0
- package/src/RenderRequest.elm +2 -2
- package/src/RequestsAndPending.elm +111 -9
- package/src/Server/Request.elm +1253 -0
- package/src/Server/Response.elm +292 -0
- package/src/Server/Session.elm +316 -0
- package/src/Server/SetCookie.elm +169 -0
- package/src/TerminalText.elm +1 -1
- package/src/Test/Html/Internal/ElmHtml/Markdown.elm +0 -1
- package/src/Test/Html/Internal/ElmHtml/ToString.elm +1 -1
- package/generator/src/Page.elm +0 -359
- package/generator/src/codegen-template-module.js +0 -183
- package/generator/src/elm-pages-js-minified.js +0 -1
- package/generator/template/src/Api.elm +0 -14
- package/generator/template/src/Page/Index.elm +0 -69
- package/generator/template/src/Site.elm +0 -41
- package/src/DataSource/ServerRequest.elm +0 -60
- package/src/Internal/OptimizedDecoder.elm +0 -18
- package/src/KeepOrDiscard.elm +0 -6
- package/src/OptimizedDecoder/Pipeline.elm +0 -335
- package/src/OptimizedDecoder.elm +0 -818
- package/src/Pages/Internal/ApplicationType.elm +0 -6
- package/src/Pages/Secrets.elm +0 -83
- package/src/Secrets.elm +0 -111
- package/src/SecretsDict.elm +0 -45
|
@@ -9,7 +9,7 @@ function connect(sendContentJsonPort, initialErrorPage) {
|
|
|
9
9
|
eventSource = new EventSource("/stream");
|
|
10
10
|
window.reloadOnOk = initialErrorPage;
|
|
11
11
|
if (initialErrorPage) {
|
|
12
|
-
handleEvent(sendContentJsonPort, { data: "content.
|
|
12
|
+
handleEvent(sendContentJsonPort, { data: "content.dat" });
|
|
13
13
|
}
|
|
14
14
|
eventSource.onmessage = async function (evt) {
|
|
15
15
|
handleEvent(sendContentJsonPort, evt);
|
|
@@ -17,7 +17,7 @@ function connect(sendContentJsonPort, initialErrorPage) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async function handleEvent(sendContentJsonPort, evt) {
|
|
20
|
-
if (evt.data === "content.
|
|
20
|
+
if (evt.data === "content.dat") {
|
|
21
21
|
showCompiling("");
|
|
22
22
|
const elmJsRequest = elmJsFetch();
|
|
23
23
|
const fetchContentJson = fetchContentJsonForCurrentPage();
|
|
@@ -32,7 +32,7 @@ async function handleEvent(sendContentJsonPort, evt) {
|
|
|
32
32
|
thenApplyHmr(elmJsResponse);
|
|
33
33
|
} catch (errorJson) {
|
|
34
34
|
if (typeof errorJson === "string") {
|
|
35
|
-
errorJson = JSON.parse(errorJson)
|
|
35
|
+
errorJson = JSON.parse(errorJson);
|
|
36
36
|
}
|
|
37
37
|
if (errorJson.type) {
|
|
38
38
|
showError(errorJson);
|
|
@@ -42,21 +42,12 @@ async function handleEvent(sendContentJsonPort, evt) {
|
|
|
42
42
|
errors: errorJson,
|
|
43
43
|
});
|
|
44
44
|
} else {
|
|
45
|
-
|
|
45
|
+
showError(JSON.parse(errorJson.errorsJson.errors));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
} else if (evt.data === "elm.js") {
|
|
49
49
|
showCompiling("");
|
|
50
50
|
elmJsFetch().then(thenApplyHmr);
|
|
51
|
-
} else if (evt.data === "style.css") {
|
|
52
|
-
// https://stackoverflow.com/a/43161591
|
|
53
|
-
const links = document.getElementsByTagName("link");
|
|
54
|
-
for (var i = 0; i < links.length; i++) {
|
|
55
|
-
const link = links[i];
|
|
56
|
-
if (link.rel === "stylesheet") {
|
|
57
|
-
link.href += "";
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
51
|
} else {
|
|
61
52
|
console.log("Unhandled", evt.data);
|
|
62
53
|
}
|
|
@@ -84,7 +75,7 @@ async function updateContentJsonWith(
|
|
|
84
75
|
} catch (errorJson) {
|
|
85
76
|
if (errorJson.type) {
|
|
86
77
|
showError(errorJson);
|
|
87
|
-
} else if (typeof errorJson ===
|
|
78
|
+
} else if (typeof errorJson === "string") {
|
|
88
79
|
showError(JSON.parse(errorJson));
|
|
89
80
|
} else {
|
|
90
81
|
showError(errorJson);
|
|
@@ -98,10 +89,12 @@ function fetchContentJsonForCurrentPage() {
|
|
|
98
89
|
let currentPath = window.location.pathname.replace(/(\w)$/, "$1/");
|
|
99
90
|
|
|
100
91
|
const contentJsonForPage = await fetch(
|
|
101
|
-
`${window.location.origin}${currentPath}content.
|
|
92
|
+
`${window.location.origin}${currentPath}content.dat`
|
|
102
93
|
);
|
|
103
94
|
if (contentJsonForPage.ok || contentJsonForPage.status === 404) {
|
|
104
|
-
resolve(
|
|
95
|
+
resolve(
|
|
96
|
+
new DataView(await (await contentJsonForPage.blob()).arrayBuffer())
|
|
97
|
+
);
|
|
105
98
|
} else {
|
|
106
99
|
try {
|
|
107
100
|
reject(await contentJsonForPage.json());
|
|
@@ -146,11 +139,13 @@ var module = {
|
|
|
146
139
|
// Thanks to the elm-live maintainers and contributors for this code for rendering errors as an HTML overlay
|
|
147
140
|
// https://github.com/wking-io/elm-live/blob/e317b4914c471addea7243c47f28dcebe27a5d36/lib/src/websocket.js
|
|
148
141
|
|
|
149
|
-
const pipe =
|
|
142
|
+
const pipe =
|
|
143
|
+
(...fns) =>
|
|
144
|
+
(x) =>
|
|
145
|
+
fns.reduce((y, f) => f(y), x);
|
|
150
146
|
|
|
151
147
|
function elmJsFetch() {
|
|
152
|
-
var elmJsRequest = new Request("/elm.js");
|
|
153
|
-
elmJsRequest.cache = "no-cache";
|
|
148
|
+
var elmJsRequest = new Request("/elm.js", { cache: "no-cache" });
|
|
154
149
|
return fetch(elmJsRequest);
|
|
155
150
|
}
|
|
156
151
|
|
|
@@ -167,7 +162,7 @@ async function thenApplyHmr(response) {
|
|
|
167
162
|
} else {
|
|
168
163
|
response.text().then(function (value) {
|
|
169
164
|
module.hot.apply();
|
|
170
|
-
delete Elm;
|
|
165
|
+
delete window.Elm;
|
|
171
166
|
eval(value);
|
|
172
167
|
});
|
|
173
168
|
}
|
|
@@ -251,51 +246,51 @@ const consoleMsg = ({ error, style }, msg) => ({
|
|
|
251
246
|
|
|
252
247
|
const joinMessage = ({ error, style }) => [error.join("")].concat(style);
|
|
253
248
|
|
|
254
|
-
const parseConsoleErrors =
|
|
255
|
-
|
|
256
|
-
* @param {{ title: string; message: Message[]}} info
|
|
257
|
-
* */
|
|
258
|
-
(info) => {
|
|
259
|
-
if (info.rule) {
|
|
260
|
-
return joinMessage(
|
|
261
|
-
info.formatted.reduce(consoleMsg, {
|
|
262
|
-
error: [consoleHeader(info.rule, path)],
|
|
263
|
-
style: [styleColor("blue")],
|
|
264
|
-
})
|
|
265
|
-
);
|
|
266
|
-
} else {
|
|
267
|
-
return joinMessage(
|
|
268
|
-
info.message.reduce(consoleMsg, {
|
|
269
|
-
error: [consoleHeader(info.title, path)],
|
|
270
|
-
style: [styleColor("blue")],
|
|
271
|
-
})
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
249
|
+
const parseConsoleErrors =
|
|
250
|
+
(path) =>
|
|
276
251
|
/**
|
|
277
|
-
* @param {
|
|
252
|
+
* @param {{ title: string; message: Message[]}} info
|
|
278
253
|
* */
|
|
279
|
-
|
|
254
|
+
(info) => {
|
|
255
|
+
if (info.rule) {
|
|
256
|
+
return joinMessage(
|
|
257
|
+
info.formatted.reduce(consoleMsg, {
|
|
258
|
+
error: [consoleHeader(info.rule, path)],
|
|
259
|
+
style: [styleColor("blue")],
|
|
260
|
+
})
|
|
261
|
+
);
|
|
262
|
+
} else {
|
|
263
|
+
return joinMessage(
|
|
264
|
+
info.message.reduce(consoleMsg, {
|
|
265
|
+
error: [consoleHeader(info.title, path)],
|
|
266
|
+
style: [styleColor("blue")],
|
|
267
|
+
})
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
280
271
|
|
|
281
|
-
|
|
272
|
+
/**
|
|
273
|
+
* @param {RootObject} error
|
|
274
|
+
* */
|
|
275
|
+
const restoreColorConsole = (error) => {
|
|
276
|
+
if (error.type === "compile-errors" && error.errors) {
|
|
282
277
|
return error.errors.reduce(
|
|
283
278
|
(acc, { problems, path }) =>
|
|
284
279
|
acc.concat(problems.map(parseConsoleErrors(path))),
|
|
285
280
|
[]
|
|
286
281
|
);
|
|
287
|
-
} else if (error.type ===
|
|
282
|
+
} else if (error.type === "review-errors" && error.errors) {
|
|
288
283
|
return error.errors.reduce(
|
|
289
284
|
(acc, { errors, path }) =>
|
|
290
285
|
acc.concat(errors.map(parseConsoleErrors(path))),
|
|
291
286
|
[]
|
|
292
287
|
);
|
|
293
|
-
} else if (error.type ===
|
|
294
|
-
|
|
288
|
+
} else if (error.type === "error") {
|
|
289
|
+
return parseConsoleErrors(error.path)(error);
|
|
295
290
|
} else {
|
|
296
291
|
console.error(`Unknown error type ${error}`);
|
|
297
292
|
}
|
|
298
|
-
}
|
|
293
|
+
};
|
|
299
294
|
|
|
300
295
|
/*
|
|
301
296
|
|-------------------------------------------------------------------------------
|
|
@@ -316,36 +311,35 @@ const htmlMsg = (acc, msg) =>
|
|
|
316
311
|
|
|
317
312
|
const parseHtmlErrors = (path) => (info) => {
|
|
318
313
|
if (info.rule) {
|
|
319
|
-
|
|
314
|
+
return info.formatted.reduce(htmlMsg, htmlHeader(info.rule, path));
|
|
320
315
|
} else {
|
|
321
|
-
|
|
322
|
-
return info.message.reduce(htmlMsg, htmlHeader(info.title, path));
|
|
316
|
+
return info.message.reduce(htmlMsg, htmlHeader(info.title, path));
|
|
323
317
|
}
|
|
324
|
-
}
|
|
318
|
+
};
|
|
325
319
|
|
|
326
|
-
const restoreColorHtml =
|
|
327
|
-
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
(error) => {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
} else if (error.type ===
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
320
|
+
const restoreColorHtml =
|
|
321
|
+
/**
|
|
322
|
+
* @param {RootObject} error
|
|
323
|
+
* */
|
|
324
|
+
(error) => {
|
|
325
|
+
if (error.type === "compile-errors") {
|
|
326
|
+
return error.errors.reduce(
|
|
327
|
+
(acc, { problems, path }) =>
|
|
328
|
+
acc.concat(problems.map(parseHtmlErrors(path))),
|
|
329
|
+
[]
|
|
330
|
+
);
|
|
331
|
+
} else if (error.type === "review-errors") {
|
|
332
|
+
return error.errors.reduce(
|
|
333
|
+
(acc, { errors, path }) =>
|
|
334
|
+
acc.concat(errors.map(parseHtmlErrors(path))),
|
|
335
|
+
[]
|
|
336
|
+
);
|
|
337
|
+
} else if (error.type === "error") {
|
|
338
|
+
return parseHtmlErrors(error.path)(error);
|
|
339
|
+
} else {
|
|
340
|
+
throw new Error(`Unknown error type ${error}`);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
349
343
|
|
|
350
344
|
/*
|
|
351
345
|
|-------------------------------------------------------------------------------
|
|
@@ -360,9 +354,13 @@ var delay = 20;
|
|
|
360
354
|
* @param {RootObject} error
|
|
361
355
|
*/
|
|
362
356
|
function showError(error) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
357
|
+
try {
|
|
358
|
+
restoreColorConsole(error).forEach((error) => {
|
|
359
|
+
console.log.apply(this, error);
|
|
360
|
+
});
|
|
361
|
+
} catch (e) {
|
|
362
|
+
console.log("Error", error);
|
|
363
|
+
}
|
|
366
364
|
hideCompiling("fast");
|
|
367
365
|
setTimeout(function () {
|
|
368
366
|
showError_(restoreColorHtml(error));
|
|
@@ -429,9 +427,11 @@ function showError_(error) {
|
|
|
429
427
|
`;
|
|
430
428
|
|
|
431
429
|
setTimeout(function () {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
"
|
|
430
|
+
try {
|
|
431
|
+
document.getElementById("elm-live:elmErrorBackground").style.opacity = 1;
|
|
432
|
+
document.getElementById("elm-live:elmError").style.transform =
|
|
433
|
+
"rotateX(0deg)";
|
|
434
|
+
} catch (error) {}
|
|
435
435
|
}, delay);
|
|
436
436
|
}
|
|
437
437
|
|
|
@@ -439,13 +439,21 @@ function hideError(velocity) {
|
|
|
439
439
|
var node = document.getElementById("elm-live:elmErrorContainer");
|
|
440
440
|
if (node) {
|
|
441
441
|
if (velocity === "fast") {
|
|
442
|
-
|
|
442
|
+
try {
|
|
443
|
+
document.getElementById("elm-live:elmErrorContainer").remove();
|
|
444
|
+
} catch (error) {}
|
|
443
445
|
} else {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
try {
|
|
447
|
+
document.getElementById(
|
|
448
|
+
"elm-live:elmErrorBackground"
|
|
449
|
+
).style.opacity = 0;
|
|
450
|
+
document.getElementById("elm-live:elmError").style.transform =
|
|
451
|
+
"rotateX(90deg)";
|
|
452
|
+
} catch (error) {}
|
|
447
453
|
setTimeout(function () {
|
|
448
|
-
|
|
454
|
+
try {
|
|
455
|
+
document.getElementById("elm-live:elmErrorContainer").remove();
|
|
456
|
+
} catch (error) {}
|
|
449
457
|
}, speed);
|
|
450
458
|
}
|
|
451
459
|
}
|
|
@@ -626,7 +634,7 @@ function showCompiling_(message) {
|
|
|
626
634
|
></div>
|
|
627
635
|
`;
|
|
628
636
|
setTimeout(function () {
|
|
629
|
-
|
|
637
|
+
nodeContainer && (nodeContainer.style.opacity = "1");
|
|
630
638
|
}, delay);
|
|
631
639
|
}
|
|
632
640
|
|
|
@@ -665,3 +673,5 @@ function hideCompiling(velocity) {
|
|
|
665
673
|
|
|
666
674
|
/** @typedef { { start: IPosition; end: IPosition; } } IRegion */
|
|
667
675
|
/** @typedef { { line: number; column: number; } } IPosition */
|
|
676
|
+
|
|
677
|
+
window.connect = connect;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Api exposing (routes)
|
|
2
|
+
|
|
3
|
+
import ApiRoute exposing (ApiRoute)
|
|
4
|
+
import DataSource exposing (DataSource)
|
|
5
|
+
import Html exposing (Html)
|
|
6
|
+
import Pages.Manifest as Manifest
|
|
7
|
+
import Route exposing (Route)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
routes :
|
|
11
|
+
DataSource (List Route)
|
|
12
|
+
-> (Html Never -> String)
|
|
13
|
+
-> List (ApiRoute ApiRoute.Response)
|
|
14
|
+
routes getStaticRoutes htmlToString =
|
|
15
|
+
[]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
manifest : Manifest.Config
|
|
19
|
+
manifest =
|
|
20
|
+
Manifest.init
|
|
21
|
+
{ name = "Site Name"
|
|
22
|
+
, description = "Description"
|
|
23
|
+
, startUrl = Route.Index |> Route.toPath
|
|
24
|
+
, icons = []
|
|
25
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module ErrorPage exposing (ErrorPage(..), internalError, notFound, statusCode, view)
|
|
2
|
+
|
|
3
|
+
import Html exposing (Html)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type ErrorPage
|
|
7
|
+
= NotFound
|
|
8
|
+
| InternalError String
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
notFound : ErrorPage
|
|
12
|
+
notFound =
|
|
13
|
+
NotFound
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
internalError : String -> ErrorPage
|
|
17
|
+
internalError =
|
|
18
|
+
InternalError
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
view : ErrorPage -> { body : Html msg, title : String }
|
|
22
|
+
view error =
|
|
23
|
+
{ body =
|
|
24
|
+
Html.div []
|
|
25
|
+
[ Html.text "Hi! This is a NotFound error"
|
|
26
|
+
]
|
|
27
|
+
, title = "Error"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
statusCode : ErrorPage -> number
|
|
32
|
+
statusCode error =
|
|
33
|
+
case error of
|
|
34
|
+
NotFound ->
|
|
35
|
+
404
|
|
36
|
+
|
|
37
|
+
InternalError _ ->
|
|
38
|
+
500
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module Route.Index exposing (Data, Model, Msg, route)
|
|
2
|
+
|
|
3
|
+
import DataSource exposing (DataSource)
|
|
4
|
+
import Head
|
|
5
|
+
import Head.Seo as Seo
|
|
6
|
+
import Html
|
|
7
|
+
import Html.Attributes as Attr
|
|
8
|
+
import Pages.PageUrl exposing (PageUrl)
|
|
9
|
+
import Pages.Url
|
|
10
|
+
import Path
|
|
11
|
+
import RouteBuilder exposing (StatelessRoute, StaticPayload)
|
|
12
|
+
import Shared
|
|
13
|
+
import View exposing (View)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
type alias Model =
|
|
17
|
+
{}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
type alias Msg =
|
|
21
|
+
()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
type alias RouteParams =
|
|
25
|
+
{}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
type alias Data =
|
|
29
|
+
{}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
route : StatelessRoute RouteParams Data ActionData
|
|
33
|
+
route =
|
|
34
|
+
RouteBuilder.single
|
|
35
|
+
{ head = head
|
|
36
|
+
, data = data
|
|
37
|
+
}
|
|
38
|
+
|> RouteBuilder.buildNoState { view = view }
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
data : DataSource Data
|
|
42
|
+
data =
|
|
43
|
+
DataSource.succeed Data
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
head :
|
|
47
|
+
StaticPayload Data ActionData RouteParams
|
|
48
|
+
-> List Head.Tag
|
|
49
|
+
head static =
|
|
50
|
+
Seo.summary
|
|
51
|
+
{ canonicalUrlOverride = Nothing
|
|
52
|
+
, siteName = "elm-pages"
|
|
53
|
+
, image =
|
|
54
|
+
{ url = [ "images", "icon-png.png" ] |> Path.join |> Pages.Url.fromPath
|
|
55
|
+
, alt = "elm-pages logo"
|
|
56
|
+
, dimensions = Nothing
|
|
57
|
+
, mimeType = Nothing
|
|
58
|
+
}
|
|
59
|
+
, description = "Welcome to elm-pages!"
|
|
60
|
+
, locale = Nothing
|
|
61
|
+
, title = "elm-pages is running"
|
|
62
|
+
}
|
|
63
|
+
|> Seo.website
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
view :
|
|
67
|
+
Maybe PageUrl
|
|
68
|
+
-> Shared.Model
|
|
69
|
+
-> StaticPayload Data ActionData RouteParams
|
|
70
|
+
-> View Msg
|
|
71
|
+
view maybeUrl sharedModel static =
|
|
72
|
+
{ title = "elm-pages is running"
|
|
73
|
+
, body =
|
|
74
|
+
[ Html.h1 [] [ Html.text "elm-pages is up and running!" ]
|
|
75
|
+
, Html.h2 [] [ Html.text "Learn more" ]
|
|
76
|
+
, Html.ul
|
|
77
|
+
[]
|
|
78
|
+
[ Html.li []
|
|
79
|
+
[ Html.a [ Attr.href "https://elm-pages.com/docs/" ] [ Html.text "Framework documentation" ]
|
|
80
|
+
]
|
|
81
|
+
, Html.li
|
|
82
|
+
[]
|
|
83
|
+
[ Html.a [ Attr.href "https://package.elm-lang.org/packages/dillonkearns/elm-pages/latest/" ] [ Html.text "Elm package documentation" ]
|
|
84
|
+
]
|
|
85
|
+
]
|
|
86
|
+
]
|
|
87
|
+
}
|
|
@@ -3,6 +3,7 @@ module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
|
|
|
3
3
|
import Browser.Navigation
|
|
4
4
|
import DataSource
|
|
5
5
|
import Html exposing (Html)
|
|
6
|
+
import Html.Events
|
|
6
7
|
import Pages.Flags
|
|
7
8
|
import Pages.PageUrl exposing (PageUrl)
|
|
8
9
|
import Path exposing (Path)
|
|
@@ -18,17 +19,13 @@ template =
|
|
|
18
19
|
, view = view
|
|
19
20
|
, data = data
|
|
20
21
|
, subscriptions = subscriptions
|
|
21
|
-
, onPageChange =
|
|
22
|
+
, onPageChange = Nothing
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
type Msg
|
|
26
|
-
=
|
|
27
|
-
|
|
28
|
-
, query : Maybe String
|
|
29
|
-
, fragment : Maybe String
|
|
30
|
-
}
|
|
31
|
-
| SharedMsg SharedMsg
|
|
27
|
+
= SharedMsg SharedMsg
|
|
28
|
+
| MenuClicked
|
|
32
29
|
|
|
33
30
|
|
|
34
31
|
type alias Data =
|
|
@@ -40,7 +37,7 @@ type SharedMsg
|
|
|
40
37
|
|
|
41
38
|
|
|
42
39
|
type alias Model =
|
|
43
|
-
{
|
|
40
|
+
{ showMenu : Bool
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
|
|
@@ -59,7 +56,7 @@ init :
|
|
|
59
56
|
}
|
|
60
57
|
-> ( Model, Cmd Msg )
|
|
61
58
|
init navigationKey flags maybePagePath =
|
|
62
|
-
( {
|
|
59
|
+
( { showMenu = False }
|
|
63
60
|
, Cmd.none
|
|
64
61
|
)
|
|
65
62
|
|
|
@@ -67,12 +64,12 @@ init navigationKey flags maybePagePath =
|
|
|
67
64
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
|
68
65
|
update msg model =
|
|
69
66
|
case msg of
|
|
70
|
-
OnPageChange _ ->
|
|
71
|
-
( { model | showMobileMenu = False }, Cmd.none )
|
|
72
|
-
|
|
73
67
|
SharedMsg globalMsg ->
|
|
74
68
|
( model, Cmd.none )
|
|
75
69
|
|
|
70
|
+
MenuClicked ->
|
|
71
|
+
( { model | showMenu = not model.showMenu }, Cmd.none )
|
|
72
|
+
|
|
76
73
|
|
|
77
74
|
subscriptions : Path -> Model -> Sub Msg
|
|
78
75
|
subscriptions _ _ =
|
|
@@ -95,6 +92,30 @@ view :
|
|
|
95
92
|
-> View msg
|
|
96
93
|
-> { body : Html msg, title : String }
|
|
97
94
|
view sharedData page model toMsg pageView =
|
|
98
|
-
{ body =
|
|
95
|
+
{ body =
|
|
96
|
+
Html.div []
|
|
97
|
+
[ Html.nav []
|
|
98
|
+
[ Html.button
|
|
99
|
+
[ Html.Events.onClick MenuClicked ]
|
|
100
|
+
[ Html.text
|
|
101
|
+
(if model.showMenu then
|
|
102
|
+
"Close Menu"
|
|
103
|
+
|
|
104
|
+
else
|
|
105
|
+
"Open Menu"
|
|
106
|
+
)
|
|
107
|
+
]
|
|
108
|
+
, if model.showMenu then
|
|
109
|
+
Html.ul []
|
|
110
|
+
[ Html.li [] [ Html.text "Menu item 1" ]
|
|
111
|
+
, Html.li [] [ Html.text "Menu item 2" ]
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
else
|
|
115
|
+
Html.text ""
|
|
116
|
+
]
|
|
117
|
+
|> Html.map toMsg
|
|
118
|
+
, Html.main_ [] pageView.body
|
|
119
|
+
]
|
|
99
120
|
, title = pageView.title
|
|
100
121
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Site exposing (config)
|
|
2
|
+
|
|
3
|
+
import DataSource exposing (DataSource)
|
|
4
|
+
import Head
|
|
5
|
+
import SiteConfig exposing (SiteConfig)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
config : SiteConfig
|
|
9
|
+
config =
|
|
10
|
+
{ canonicalUrl = "https://elm-pages.com"
|
|
11
|
+
, head = head
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
head : DataSource (List Head.Tag)
|
|
16
|
+
head =
|
|
17
|
+
[ Head.sitemapLink "/sitemap.xml"
|
|
18
|
+
]
|
|
19
|
+
|> DataSource.succeed
|
|
File without changes
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "application",
|
|
3
3
|
"source-directories": [
|
|
4
|
+
"app",
|
|
4
5
|
"src",
|
|
5
6
|
".elm-pages"
|
|
6
7
|
],
|
|
7
8
|
"elm-version": "0.19.1",
|
|
8
9
|
"dependencies": {
|
|
9
10
|
"direct": {
|
|
10
|
-
"dillonkearns/elm-pages": "
|
|
11
|
+
"dillonkearns/elm-pages": "9.0.0",
|
|
11
12
|
"elm/browser": "1.0.2",
|
|
12
13
|
"elm/core": "1.0.5",
|
|
13
14
|
"elm/html": "1.0.0",
|
|
@@ -15,26 +16,34 @@
|
|
|
15
16
|
"elm/url": "1.0.0"
|
|
16
17
|
},
|
|
17
18
|
"indirect": {
|
|
18
|
-
"MartinSStewart/elm-serialize": "1.2.
|
|
19
|
+
"MartinSStewart/elm-serialize": "1.2.6",
|
|
19
20
|
"avh4/elm-color": "1.0.0",
|
|
20
|
-
"bburdette/toop": "1.0
|
|
21
|
+
"bburdette/toop": "1.2.0",
|
|
21
22
|
"danfishgold/base64-bytes": "1.1.0",
|
|
22
23
|
"danyx23/elm-mimetype": "4.0.1",
|
|
23
24
|
"dillonkearns/elm-bcp47-language-tag": "1.0.1",
|
|
24
25
|
"elm/bytes": "1.0.8",
|
|
25
26
|
"elm/file": "1.0.5",
|
|
26
27
|
"elm/http": "2.0.0",
|
|
28
|
+
"elm/parser": "1.1.0",
|
|
29
|
+
"elm/project-metadata-utils": "1.0.2",
|
|
27
30
|
"elm/random": "1.0.0",
|
|
28
31
|
"elm/regex": "1.0.0",
|
|
29
32
|
"elm/time": "1.0.0",
|
|
30
33
|
"elm/virtual-dom": "1.0.2",
|
|
31
34
|
"elm-community/dict-extra": "2.4.0",
|
|
32
|
-
"elm-community/list-extra": "8.
|
|
35
|
+
"elm-community/list-extra": "8.5.1",
|
|
36
|
+
"elm-explorations/test": "1.2.2",
|
|
33
37
|
"fredcy/elm-parseint": "2.0.1",
|
|
34
|
-
"
|
|
38
|
+
"jfmengels/elm-review": "2.6.1",
|
|
39
|
+
"mgold/elm-nonempty-list": "4.2.0",
|
|
35
40
|
"miniBill/elm-codec": "2.0.0",
|
|
41
|
+
"miniBill/elm-unicode": "1.0.2",
|
|
36
42
|
"noahzgordon/elm-color-extra": "1.0.2",
|
|
37
43
|
"robinheghan/murmur3": "1.0.0",
|
|
44
|
+
"rtfeldman/elm-hex": "1.0.0",
|
|
45
|
+
"stil4m/elm-syntax": "7.2.8",
|
|
46
|
+
"stil4m/structured-writer": "1.0.3",
|
|
38
47
|
"tripokey/elm-fuzzy": "5.2.1",
|
|
39
48
|
"vito/elm-ansi": "10.0.1",
|
|
40
49
|
"zwilias/json-decode-exploration": "6.0.0"
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
type ElmPagesInit = {
|
|
2
|
+
load: (elmLoaded: Promise<unknown>) => Promise<void>;
|
|
3
|
+
flags: unknown;
|
|
4
|
+
};
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
export default {
|
|
6
|
+
const config: ElmPagesInit = {
|
|
5
7
|
load: async function (elmLoaded) {
|
|
6
8
|
const app = await elmLoaded;
|
|
7
9
|
console.log("App loaded", app);
|
|
@@ -10,3 +12,5 @@ export default {
|
|
|
10
12
|
return "You can decode this in Shared.elm using Json.Decode.string!";
|
|
11
13
|
},
|
|
12
14
|
};
|
|
15
|
+
|
|
16
|
+
export default config;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"build": "elm-pages build"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"elm-optimize-level-2": "
|
|
10
|
-
"elm-pages": "2.1.
|
|
11
|
-
"elm-review": "^2.
|
|
12
|
-
"elm-tooling": "^1.
|
|
9
|
+
"elm-optimize-level-2": "0.3.4",
|
|
10
|
+
"elm-pages": "2.1.10",
|
|
11
|
+
"elm-review": "^2.7.0",
|
|
12
|
+
"elm-tooling": "^1.7.0"
|
|
13
13
|
}
|
|
14
|
-
}
|
|
14
|
+
}
|
|
Binary file
|
|
Binary file
|
|
File without changes
|