···11+# homepage
22+33+[](https://hex.pm/packages/homepage)
44+[](https://hexdocs.pm/homepage/)
55+66+```sh
77+gleam add homepage@1
88+```
99+```gleam
1010+import homepage
1111+1212+pub fn main() -> Nil {
1313+ // TODO: An example of the project in use
1414+}
1515+```
1616+1717+Further documentation can be found at <https://hexdocs.pm/homepage>.
1818+1919+## Development
2020+2121+```sh
2222+gleam run # Run the project
2323+gleam test # Run the tests
2424+```
+126
dev/homepage/prepare.gleam
···11+//// Most of this file was borrowed from the project that was replaced by this:
22+//// https://forge.strawmelonjuice.com/CynthiaWebsiteEngine/ByYou/src/branch/main/by-you/src/byyou/cli.gleam
33+44+import gleam/erlang/application
55+import gleam/io
66+import gleam/json
77+import gleam/list
88+import gleam/result
99+import gleam/string
1010+import simplifile
1111+1212+@external(javascript, "./nonexistent.js", "okay")
1313+fn assertive_priv_file_read(file: String) -> String {
1414+ case
1515+ result.flatten({
1616+ use path <- result.map(
1717+ result.map(
1818+ application.priv_directory("homepage")
1919+ |> result.replace_error(
2020+ "The package did not exist. This should be impossible.",
2121+ ),
2222+ string.append(_, "/"),
2323+ ),
2424+ )
2525+ simplifile.read(path <> file)
2626+ |> result.replace_error("Could not read '" <> path <> file <> "'.")
2727+ })
2828+ {
2929+ Ok(z) -> z
3030+ Error(error) -> {
3131+ panic as error
3232+ }
3333+ }
3434+}
3535+3636+pub fn main() {
3737+ use files <- result.try(list_files())
3838+3939+ use dir <- result.try(
4040+ result.map(
4141+ simplifile.is_directory("./src/homepage/from_prebuild/")
4242+ |> result.replace_error(
4343+ "❌\tCouldn't check for the existence of directory `src/homepage/from_prebuild/`.",
4444+ ),
4545+ fn(exists) {
4646+ case exists {
4747+ False -> {
4848+ simplifile.create_directory_all("./src/homepage/from_prebuild/")
4949+ |> result.replace_error(
5050+ "❌\tSomething went wrong creating directory `src/homepage/from_prebuild/`.",
5151+ )
5252+ |> result.replace("✅\tCreated: `src/homepage/from_prebuild/`")
5353+ }
5454+ True -> {
5555+ Ok("🆗\tAlready exists: `src/homepage/from_prebuild/`")
5656+ }
5757+ }
5858+ },
5959+ )
6060+ |> result.flatten,
6161+ )
6262+ io.println(dir)
6363+ use _ <- result.try(
6464+ simplifile.write(
6565+ "./src/homepage/from_prebuild/data.gleam",
6666+ assertive_priv_file_read("codegen-templates/data.gleam")
6767+ |> string.replace("todo as \"templated:files\"", files),
6868+ )
6969+ |> result.replace_error(
7070+ "❌\tSomething went wrong writing `src/homepage/from_prebuild/data.gleam`.",
7171+ ),
7272+ )
7373+ io.println("✅\tWrote: `src/homepage/from_prebuild/data.gleam`")
7474+ |> Ok
7575+}
7676+7777+fn list_files() {
7878+ use dir <- result.try(
7979+ result.map(
8080+ simplifile.is_directory("./written-contents/")
8181+ |> result.replace_error(
8282+ "❌\tCouldn't check for the existence of directory `./written-contents/`.",
8383+ ),
8484+ fn(exists) {
8585+ case exists {
8686+ False -> {
8787+ simplifile.create_directory_all("./written-contents/")
8888+ |> result.replace_error(
8989+ "❌\tSomething went wrong creating directory `written-contents/`.",
9090+ )
9191+ |> result.replace("✅\tCreated: `written-contents/`")
9292+ }
9393+ True -> {
9494+ Ok("🆗\tExists: `written-contents/`")
9595+ }
9696+ }
9797+ },
9898+ )
9999+ |> result.flatten,
100100+ )
101101+ io.println(dir)
102102+ use files <- result.try(
103103+ simplifile.get_files("./written-contents/")
104104+ |> result.replace_error(
105105+ "❌\tSomething went wrong reading directory `written-contents/`.",
106106+ ),
107107+ )
108108+109109+ list.try_map(files, fn(file) {
110110+ use contents <- result.try(
111111+ simplifile.read(file)
112112+ |> result.replace_error(
113113+ "❌\tSomething went wrong reading file `" <> file <> "`.",
114114+ ),
115115+ )
116116+ Ok(
117117+ "#("
118118+ <> json.to_string(json.string(file))
119119+ <> ", "
120120+ <> json.to_string(json.string(contents))
121121+ <> ")",
122122+ )
123123+ })
124124+ |> result.map(string.join(_, ","))
125125+ |> result.map(fn(series) { "[" <> series <> "]" })
126126+}
···11+name = "homepage"
22+version = "1.0.0"
33+44+# Fill out these fields if you intend to generate HTML documentation or publish
55+# your project to the Hex package manager.
66+#
77+# description = ""
88+# licences = ["Apache-2.0"]
99+# repository = { type = "github", user = "", repo = "" }
1010+# links = [{ title = "Website", href = "" }]
1111+#
1212+# For a full reference of all the available options, you can have a look at
1313+# https://gleam.run/writing-gleam/gleam-toml/.
1414+1515+[dependencies]
1616+gleam_stdlib = ">= 0.44.0 and < 2.0.0"
1717+lustre = ">= 5.6.0 and < 6.0.0"
1818+modem = ">= 2.1.2 and < 3.0.0"
1919+jot = ">= 10.1.1 and < 11.0.0"
2020+2121+[dev-dependencies]
2222+lustre_dev_tools = ">= 2.3.4 and < 3.0.0"
2323+simplifile = ">= 2.3.2 and < 3.0.0"
2424+gleam_erlang = ">= 1.3.0 and < 2.0.0"
2525+gleam_json = ">= 3.1.0 and < 4.0.0"