···11+# Gleam frontend!
22+33+This is the Lumina frontend, written in Gleam.
44+55+## Why the externals?
66+77+The Gleam frontend is written in Gleam, but it uses a lot of JavaScript. This is because the Gleam ecosystem is still young and the existing libraries do not cover all the functionality we need. We hope that in the future we can replace the JavaScript with Gleam code.
88+99+(Also, I was kinda lazy and didn't want to be translating JavaScript to Gleam all day.)
1010+1111+1212+Anyways: If you want to help reduce the amount of JavaScript in the frontend, please do!
+3-3
frontend/TODO.md
···77 - [ ] Verify compile moment thru FEJSON
88 - [ ] User action reporting
99 - [ ] New post creation
1010- - [ ] Log out
1010+ - [x] Log out
1111- [ ] Sub page loading
1212 - [x] Loading sub pages (main, side)
1313 - [ ] Migrating to Handlebars parsing on the client side, instead of server-leveraged strings.
1414 - [ ] Loading special sub pages (editor, settings)
1515- - [ ] Sub page logic
1515+ - [x] Sub page logic
1616- [ ] Editor
1717- - [ ] Editor UI
1717+ - [x] Editor UI
1818 - [ ] Editor tab switching
1919 - [ ] Editor Markdown parsing
2020- [x] Sign in
+1
frontend/gleam.toml
···2323gleam_javascript = ">= 0.13.0 and < 1.0.0"
2424gleam_json = ">= 2.0.0 and < 3.0.0"
2525pprint = ">= 1.0.4 and < 2.0.0"
2626+gleam_regexp = ">= 1.0.0 and < 2.0.0"
26272728[dev-dependencies]
2829gleeunit = ">= 1.0.0 and < 2.0.0"
+37
frontend/manifest.toml
···11+# This file was generated by Gleam
22+# You typically do not need to edit this file
33+44+packages = [
55+ { name = "conversation", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], otp_app = "conversation", source = "hex", outer_checksum = "908B46F60444442785A495197D482558AD8B849C3714A38FAA1940358CC8CCCD" },
66+ { name = "envoy", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "95FD059345AA982E89A0B6E2A3BF1CF43E17A7048DCD85B5B65D3B9E4E39D359" },
77+ { name = "glam", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glam", source = "hex", outer_checksum = "66EC3BCD632E51EED029678F8DF419659C1E57B1A93D874C5131FE220DFAD2B2" },
88+ { name = "gleam_community_colour", version = "1.4.1", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "386CB9B01B33371538672EEA8A6375A0A0ADEF41F17C86DDCB81C92AD00DA610" },
99+ { name = "gleam_erlang", version = "0.33.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "A1D26B80F01901B59AABEE3475DD4C18D27D58FA5C897D922FCB9B099749C064" },
1010+ { name = "gleam_fetch", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "2FCFC0A85A6D5A83076889EEDD02D6779C02FEF6FDE0263C4D3B46D0785EAB7A" },
1111+ { name = "gleam_http", version = "3.7.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "8A70D2F70BB7CFEB5DF048A2183FFBA91AF6D4CF5798504841744A16999E33D2" },
1212+ { name = "gleam_javascript", version = "0.13.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "F98328FCF573DA6F3A35D7F6CB3F9FF19FD5224CCBA9151FCBEAA0B983AF2F58" },
1313+ { name = "gleam_json", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C55C5C2B318533A8072D221C5E06E5A75711C129E420DD1CE463342106012E5D" },
1414+ { name = "gleam_otp", version = "0.16.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "FA0EB761339749B4E82D63016C6A18C4E6662DA05BAB6F1346F9AF2E679E301A" },
1515+ { name = "gleam_regexp", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "A3655FDD288571E90EE9C4009B719FEF59FA16AFCDF3952A76A125AF23CF1592" },
1616+ { name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
1717+ { name = "gleamy_lights", version = "2.3.0", build_tools = ["gleam"], requirements = ["envoy", "gleam_community_colour", "gleam_stdlib"], otp_app = "gleamy_lights", source = "hex", outer_checksum = "8A3D43BCA0D935F7CC787F4D0D1771F822B3366114C08B93CC8D00747618499A" },
1818+ { name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
1919+ { name = "lustre", version = "4.6.3", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "BDF833368F6C8F152F948D5B6A79866E9881CB80CB66C0685B3327E7DCBFB12F" },
2020+ { name = "plinth", version = "0.5.6", build_tools = ["gleam"], requirements = ["conversation", "gleam_javascript", "gleam_json", "gleam_stdlib"], otp_app = "plinth", source = "hex", outer_checksum = "7A9BEAB98F4BC6859803D5ABCD0F3B4C3578A747F12BF32F9E234F8325F5F0E0" },
2121+ { name = "pprint", version = "1.0.4", build_tools = ["gleam"], requirements = ["glam", "gleam_stdlib"], otp_app = "pprint", source = "hex", outer_checksum = "C310A98BDC0995644847C3C8702DE19656D6BCD638B2A8A358B97824379ECAA1" },
2222+ { name = "shared", version = "1.0.0", build_tools = ["gleam"], requirements = [], source = "local", path = "../shared" },
2323+]
2424+2525+[requirements]
2626+gleam_fetch = { version = ">= 1.0.1 and < 2.0.0" }
2727+gleam_http = { version = ">= 3.7.0 and < 4.0.0" }
2828+gleam_javascript = { version = ">= 0.13.0 and < 1.0.0" }
2929+gleam_json = { version = ">= 2.0.0 and < 3.0.0" }
3030+gleam_regexp = { version = ">= 1.0.0 and < 2.0.0" }
3131+gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
3232+gleamy_lights = { version = ">= 2.3.0 and < 3.0.0" }
3333+gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
3434+lustre = { version = ">= 4.5.0 and < 5.0.0" }
3535+plinth = { version = ">= 0.5.0 and < 1.0.0" }
3636+pprint = { version = ">= 1.0.4 and < 2.0.0" }
3737+shared = { path = "../shared/" }
···11+import plinth/javascript/console
22+33+/// Be bad!
44+/// This is a bad way to unwrap a Result. It will panic if the Result is an Error.
55+/// However, we know what's in the HTML, so we can safely unwrap it.
66+pub fn unwrap(p: Result(a, e)) -> a {
77+ case p {
88+ Ok(a) -> a
99+ Error(e) -> {
1010+ console.error(e)
1111+ panic as "Failed to unwrap Result"
1212+ }
1313+ }
1414+}