this repo has no description
lustre frontent oat-ui gleam
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

:construction: add sidebar and navbar

+129 -6
+34
.dockerignore
··· 1 + # vcs 2 + .git 3 + .jj 4 + 5 + # secrets 6 + .envrc 7 + .env.example 8 + 9 + # cache 10 + .rumdl_cache/ 11 + 12 + # dev 13 + Containerfile 14 + justfile 15 + .sqruff 16 + 17 + # client 18 + client/build 19 + client/dev 20 + cliend/test 21 + client/justfile 22 + 23 + # server 24 + server/build 25 + server/dev 26 + server/test 27 + server/justfile 28 + server/priv/static/ 29 + 30 + # shared 31 + shared/build 32 + shared/dev 33 + shared/test 34 + shared/justfile
+2
.envrc
··· 1 + export API_URL="http://0.0.0.0:8080" 2 + export SECRET_KEY="senac"
+1 -1
Containerfile
··· 1 - ARG GLEAM_VERSION=v1.15.4 1 + ARG GLEAM_VERSION=v1.16.0 2 2 ARG ERLANG_VERSION=28.4.2 3 3 4 4 # builder stage ----------------------------------------------------------------
+14 -3
client/src/client.gleam
··· 1 1 import client/page 2 2 import client/page/home 3 3 import client/page/login 4 + import client/page/navbar 4 5 import client/page/not_found 6 + import client/page/sidebar 5 7 import envoy 6 8 import gleam/bool 7 9 import gleam/http/response ··· 49 51 use value <- result.try(envoy.get("API_URL")) 50 52 uri.parse(value) 51 53 } 54 + as "Missing `API_URL` enviroment variable" 52 55 53 56 let opts = InitOpts(api:) 54 57 let app = lustre.application(init:, update:, view:) ··· 69 72 // PAGES --- 70 73 LoginMsg(msg: login.Msg) 71 74 HomeMsg(msg: home.Msg) 75 + 76 + SidebarMsg(msg: sidebar.Msg) 77 + NavbarMsg(msg: navbar.Msg) 72 78 } 73 79 74 80 // INIT ------------------------------------------------------------------------ ··· 124 130 // VIEW ------------------------------------------------------------------------ 125 131 126 132 fn layout( 133 + model: Model, 127 134 element_view: element.Element(a), 128 135 f: fn(a) -> Msg, 129 136 ) -> element.Element(Msg) { 130 - element_view |> element.map(f) 137 + element.fragment([ 138 + navbar.view(model.session) |> element.map(NavbarMsg), 139 + sidebar.view(model.session) |> element.map(SidebarMsg), 140 + element_view |> element.map(f), 141 + ]) 131 142 } 132 143 133 144 /// Render page HTML ··· 135 146 case model { 136 147 // HOME PAGE --------------------------------------------------------------- 137 148 Model(session:, route: route.Home, page: page.Home, ..) -> 138 - layout(home.view(session), HomeMsg) 149 + layout(model, home.view(session), HomeMsg) 139 150 140 151 // LOGIN PAGE -------------------------------------------------------------- 141 152 Model(session:, route: route.Login, page: page.Login(page), ..) -> 142 - layout(login.view(session, page), LoginMsg) 153 + layout(model, login.view(session, page), LoginMsg) 143 154 144 155 _ -> not_found.view() 145 156 }
+2 -1
client/src/client/page/login.gleam
··· 2 2 import gleam/uri 3 3 import lustre/effect 4 4 import lustre/element 5 + import lustre/element/html 5 6 import rsvp 6 7 import shared/session 7 8 ··· 82 83 } 83 84 84 85 pub fn view(_session: session.Session, _model: Model) -> element.Element(Msg) { 85 - element.none() 86 + html.main([], [element.none()]) 86 87 }
+10
client/src/client/page/navbar.gleam
··· 1 + import lustre/attribute 2 + import lustre/element 3 + import lustre/element/html 4 + import shared/session 5 + 6 + pub type Msg 7 + 8 + pub fn view(_session: session.Session) -> element.Element(Msg) { 9 + html.aside([attribute.data("topnav", "")], []) 10 + }
+10
client/src/client/page/sidebar.gleam
··· 1 + import lustre/attribute 2 + import lustre/element 3 + import lustre/element/html 4 + import shared/session 5 + 6 + pub type Msg 7 + 8 + pub fn view(_session: session.Session) -> element.Element(Msg) { 9 + html.aside([attribute.data("sidebar", "")], []) 10 + }
+21
justfile
··· 3 3 mod shared 4 4 5 5 set quiet 6 + pod_name := "bfd-pod" 6 7 7 8 # List available recipes 8 9 _default: 9 10 just --list 11 + 12 + # Build project abd start server 13 + dev: 14 + just client::build 15 + just server::run 16 + 17 + create-pod: 18 + podman pod exists {{ pod_name }} \ 19 + || podman pod create --name {{ pod_name }} -p 8000:8000 20 + 21 + # Build and run app container 22 + up: create-pod 23 + just server::build-container 24 + just server::run-container {{ pod_name }} 25 + 26 + # Remove container 27 + down: 28 + podman pod exists {{ pod_name }} || (echo "Pod does not exist" && exit 1) 29 + podman pod stop {{ pod_name }} 30 + podman pod rm {{ pod_name }}
+21
server/justfile
··· 1 + @_default: 2 + just --list 3 + 4 + container_name := "bfd-app" 5 + 6 + #  Start HTTP server 7 + run: 8 + gleam run 9 + 10 + # Build container 11 + [no-cd] 12 + build-container: 13 + podman build -t {{ container_name }} . 14 + 15 + # Run server container 16 + run-container pod_name: 17 + podman run -d \ 18 + --pod {{ pod_name }} \ 19 + --name {{ container_name }} \ 20 + -e SECRET_KEY -e API_URL \ 21 + {{ container_name }}
+1
server/src/server.gleam
··· 12 12 13 13 let assert Ok(static_directory) = static_directory() 14 14 let assert Ok(secret_key) = envoy.get("SECRET_KEY") 15 + as "Missing `SECRET_KEY` enviroment variable" 15 16 16 17 let ctx = Context(static_directory:, secret_key:) 17 18 let handler = router.handle_request(_, ctx)
+11 -1
server/src/server/root.gleam
··· 11 11 attr.content("width=device-width, initial-scale=1"), 12 12 ]) 13 13 14 + let oat_ui = [ 15 + html.script([attr.src("/static/client.js")], ""), 16 + html.link([ 17 + attr.rel("stylesheet"), 18 + attr.href("https://unpkg.com/@knadh/oat/oat.min.css"), 19 + ]), 20 + ] 21 + 14 22 let html_head = 15 23 html.head([], [ 16 24 html.title([], "BFD"), 17 25 viewport_meta, 18 26 html.script([attr.type_("module"), attr.src("/static/client.js")], ""), 19 27 html.link([attr.rel("stylesheet"), attr.href("/static/client.css")]), 28 + ..oat_ui 20 29 ]) 21 30 22 - let html_body = html.body([attr.id("app")], []) 31 + let html_body = 32 + html.body([attr.id("app"), attr.data("sidebar-layout", "")], []) 23 33 24 34 html.html([], [html_head, html_body]) 25 35 |> element.to_document_string()
+2
shared/justfile
··· 1 + _default: 2 + just --list