diff --git a/lib/develop/heroprompt/heroprompt_factory_.v b/lib/develop/heroprompt/heroprompt_factory_.v index e5b9f4fd..4f0d6a33 100644 --- a/lib/develop/heroprompt/heroprompt_factory_.v +++ b/lib/develop/heroprompt/heroprompt_factory_.v @@ -4,8 +4,6 @@ import freeflowuniverse.herolib.core.base import freeflowuniverse.herolib.core.playbook { PlayBook } import freeflowuniverse.herolib.ui.console import json -import os -import time __global ( heroprompt_global map[string]&Workspace @@ -18,32 +16,13 @@ __global ( pub struct ArgsGet { pub mut: name string = 'default' - path string fromdb bool // will load from filesystem create bool // default will not create if not exist } pub fn new(args ArgsGet) !&Workspace { - // validate - if args.name.len == 0 { - return error('workspace name is required') - } - mut base_path := '' - if args.path.len > 0 { - if !os.exists(args.path) { - return error('workspace path does not exist: ${args.path}') - } - if !os.is_dir(args.path) { - return error('workspace path is not a directory: ${args.path}') - } - base_path = os.real_path(args.path) - } mut obj := Workspace{ - name: args.name - base_path: base_path - created: time.now() - updated: time.now() - is_saved: false + name: args.name } set(obj)! return get(name: args.name)! @@ -57,7 +36,7 @@ pub fn get(args ArgsGet) !&Workspace { if r.hexists('context:heroprompt', args.name)! { data := r.hget('context:heroprompt', args.name)! if data.len == 0 { - return error('Workspace with name: ${args.name} does not exist, prob bug.') + return error('Workspace with name: heroprompt does not exist, prob bug.') } mut obj := json.decode(Workspace, data)! set_in_mem(obj)! @@ -65,7 +44,7 @@ pub fn get(args ArgsGet) !&Workspace { if args.create { new(args)! } else { - return error("Workspace with name '${args.name}' does not exist") + return error("Workspace with name 'heroprompt' does not exist") } } return get(name: args.name)! // no longer from db nor create diff --git a/lib/develop/heroprompt/heroprompt_model.v b/lib/develop/heroprompt/heroprompt_model.v index e306dadd..8fea0e31 100644 --- a/lib/develop/heroprompt/heroprompt_model.v +++ b/lib/develop/heroprompt/heroprompt_model.v @@ -28,6 +28,7 @@ fn obj_init(mycfg_ Workspace) !Workspace { /////////////NORMALLY NO NEED TO TOUCH pub fn heroscript_loads(heroscript string) !Workspace { - mut obj := encoderhero.decode[Workspace](heroscript)! + // TODO: go from heroscript to object + $dbg; return obj } diff --git a/lib/web/ui/factory.v b/lib/web/ui/factory.v index 9ef29602..cb1b5481 100644 --- a/lib/web/ui/factory.v +++ b/lib/web/ui/factory.v @@ -4,6 +4,7 @@ import veb import os import net.http + // Public Context type for veb pub struct Context { veb.Context @@ -38,41 +39,6 @@ pub mut: port int } -// Global registry (multi-instance support by name) -__global ( - uireg map[string]&App -) - -// Create a new app (does not start the server) -pub fn new(args FactoryArgs) !&App { - name := if args.name.len == 0 { 'default' } else { args.name } - if app := uireg[name] { - return app - } - mut app := &App{ - title: args.title - menu: if args.menu.len > 0 { args.menu } else { default_menu() } - port: args.port - } - uireg[name] = app - return app -} - -// Get a named app -pub fn get(name string) !&App { - mut app := uireg[name] or { - return error('ui: app "${name}" not found, call ui.new(...) first') - } - return app -} - -// Get default app (creates if not existing) -pub fn default() !&App { - if uireg.len == 0 { - return new(port: 8080)! - } - return get('default')! -} // Start the webserver (blocking) pub fn start(args FactoryArgs) ! {