...
This commit is contained in:
@@ -30,8 +30,8 @@ pub mut:
|
||||
pub fn new(args FactoryArgs) !&App {
|
||||
base := os.dir(@FILE)
|
||||
mut app := App{
|
||||
title: args.title
|
||||
port: args.port
|
||||
title: args.title
|
||||
port: args.port
|
||||
base_path: base
|
||||
}
|
||||
// Serve static assets from this module at /static
|
||||
@@ -62,10 +62,10 @@ fn render_index(app &App) string {
|
||||
}
|
||||
|
||||
fn render_index_fallback(app &App) string {
|
||||
return '<!doctype html>\n<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>'
|
||||
+ html_escape(app.title)
|
||||
+ '</title><link rel="stylesheet" href="/static/css/main.css"></head><body><div class="container"><h1>'
|
||||
+ html_escape(app.title)
|
||||
+ '</h1><p>Heroprompt server is running.</p></div><script src="/static/js/main.js"></script></body></html>'
|
||||
return
|
||||
'<!doctype html>\n<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>' +
|
||||
html_escape(app.title) +
|
||||
'</title><link rel="stylesheet" href="/static/css/main.css"></head><body><div class="container"><h1>' +
|
||||
html_escape(app.title) +
|
||||
'</h1><p>Heroprompt server is running.</p></div><script src="/static/js/main.js"></script></body></html>'
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ module ui
|
||||
import veb
|
||||
import os
|
||||
|
||||
|
||||
// Public Context type for veb
|
||||
pub struct Context {
|
||||
veb.Context
|
||||
@@ -33,18 +32,17 @@ pub mut:
|
||||
pub struct App {
|
||||
veb.StaticHandler
|
||||
pub mut:
|
||||
title string = "default"
|
||||
title string = 'default'
|
||||
menu []MenuItem
|
||||
port int = 7711
|
||||
}
|
||||
|
||||
|
||||
// Start the webserver (blocking)
|
||||
pub fn start(args WebArgs) !{
|
||||
pub fn start(args WebArgs) ! {
|
||||
mut app := App{
|
||||
title: args.title,
|
||||
menu: args.menu,
|
||||
port: args.port
|
||||
title: args.title
|
||||
menu: args.menu
|
||||
port: args.port
|
||||
}
|
||||
veb.run[App, Context](mut app, app.port)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,11 @@ fn menu_html(items []MenuItem, depth int, prefix string) string {
|
||||
if it.children.len > 0 {
|
||||
// expandable group
|
||||
out << '<div class="item">'
|
||||
out << '<a class="list-group-item list-group-item-action d-flex justify-content-between align-items-center" data-bs-toggle="collapse" href="#${id}" role="button" aria-expanded="${if depth == 0 { 'true' } else { 'false' }}" aria-controls="${id}">'
|
||||
out << '<a class="list-group-item list-group-item-action d-flex justify-content-between align-items-center" data-bs-toggle="collapse" href="#${id}" role="button" aria-expanded="${if depth == 0 {
|
||||
'true'
|
||||
} else {
|
||||
'false'
|
||||
}}" aria-controls="${id}">'
|
||||
out << '<span>${it.title}</span><span class="chev">›</span>'
|
||||
out << '</a>'
|
||||
out << '<div class="collapse ${if depth == 0 { 'show' } else { '' }}" id="${id}">'
|
||||
@@ -24,4 +28,3 @@ fn menu_html(items []MenuItem, depth int, prefix string) string {
|
||||
}
|
||||
return out.join('\n')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user