From 3fd08bf51cfb2991a40de1c04e0fd2ecba33171d Mon Sep 17 00:00:00 2001 From: metalwolf Date: Tue, 18 Aug 2020 10:47:04 -0500 Subject: [PATCH] patch v1.4.1 --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ server.go | 14 +++++------ xamboo.go | 2 +- 3 files changed, 77 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4307246..70297ee 100644 --- a/README.md +++ b/README.md @@ -302,6 +302,31 @@ When you want to add a hand made engine, the syntax is: { "name": "myengine", "source": "extern", "library": "./path/to/your/myengine.so" }, ``` +PAGES +============================= + +1. What is a page + +2. Page resolution + +3. .page file, type, status, template and others + +4. Instances of a page + +5. Type of pages + + 3.1 Redirect page + + 3.2 Simple Page + + 3.3 Library Page + + 3.4 WajafApp Page + + 3.5 Template Page + + 3.6 Language Page + ENGINES ============================= @@ -320,6 +345,45 @@ ENGINES 7. User made Engines +An Engine must meet the assets.Engine and assets.EngineInstance interfaces to be used by the Xamboo. + +An Engine is a plugin (go --buildmode=plugin) loadable by the Server. + +When the system loads the engine, it will check the existence of the exported variable Engine, that must meet the assets.Engine interface. + +The engine will work in 2 step. + a. When the xamboo detect a page with the type of the engine, it will call the Engine.NeedInstance() function to know if the engines needs to build an instance to work (returns true/false). + a.1 If the engine does not need an instance, the server will call Engine.Run() function to get the result of the calculated page. + a.2 If the engine needs an instance, the server will call Engine.GetInstance() function to get the instance. + + +APPLICATION +============================= + +An Application must meet the assets.Application interface to be used by the Xamboo. + +An Application is a plugin (go --buildmode=plugin) loadable by the Server, called by a Host. + +A Host can load more than one Application. +An Application can be called by more than one Host. + +When the system loads the Application, it will check the existence of the exported variable Application, that must meet the assets.Application interface. + +The Application is the entry point to load the XModules. + +1. Datasource + +2. Compiled Module + +3. Context + + +XMODULES +============================= + + + + TO DO @@ -345,6 +409,11 @@ Extras: Version Changes Control ======================= +v1.4.1 - 2020-08-18 +----------------------- +- Some bugs corrected to use the innerPage parameter correctly to pass the return Code. +- Manual enchanced (APPLICATION, MANUAL ENGINE) + v1.4.0 - 2020-08-12 ----------------------- - The context now have a Code attribute to pass the return code from an engine to the writer. diff --git a/server.go b/server.go index 0d5510a..7919124 100644 --- a/server.go +++ b/server.go @@ -241,7 +241,7 @@ func (s *Server) Run(page string, innerpage bool, params interface{}, version st ctx := &assets.Context{ Request: s.reader, Writer: s.writer, - Code: http.StatusOK, + Code: s.Code, LocalPage: page, LocalPageUsed: P, LocalURLparams: xParams, @@ -295,7 +295,7 @@ func (s *Server) Run(page string, innerpage bool, params interface{}, version st // =========================================================== engine, ok := Engines[tp] if !ok { - return s.launchError(page, http.StatusNotFound, innerpage, "Error: Server "+tp+" does not exist") + return s.launchError(page, http.StatusNotFound, !ctx.IsMainPage, "Error: Server "+tp+" does not exist") } if !engine.NeedInstance() { @@ -303,7 +303,7 @@ func (s *Server) Run(page string, innerpage bool, params interface{}, version st data := engine.Run(ctx, s) dataerror, okerr := data.(error) if okerr { - return s.launchError(page, ctx.Code, innerpage, dataerror.Error()) + return s.launchError(page, ctx.Code, !ctx.IsMainPage, dataerror.Error()) } return data } @@ -351,12 +351,12 @@ func (s *Server) Run(page string, innerpage bool, params interface{}, version st } if instancedata == nil { - return s.launchError(page, http.StatusInternalServerError, innerpage, "Error: the page/block has no instance") + return s.launchError(page, http.StatusInternalServerError, !ctx.IsMainPage, "Error: the page/block has no instance") } // verify the possible recursion if r, c := s.verifyRecursion(P, ctx.LocalPageparams); r { - return s.launchError(page, http.StatusInternalServerError, innerpage, "Error: the page/block is recursive: "+P+" after "+strconv.Itoa(c)+" times") + return s.launchError(page, http.StatusInternalServerError, !ctx.IsMainPage, "Error: the page/block is recursive: "+P+" after "+strconv.Itoa(c)+" times") } // s.pushContext(innerpage, page, P, instancedata, params, version, language) @@ -376,7 +376,7 @@ func (s *Server) Run(page string, innerpage bool, params interface{}, version st } if engineinstance == nil { - return s.launchError(page, http.StatusInternalServerError, innerpage, "Error: the engine could not find an instance to Run. Please verify the available instances.") + return s.launchError(page, http.StatusInternalServerError, !ctx.IsMainPage, "Error: the engine could not find an instance to Run. Please verify the available instances.") } var templatedata *xcore.XTemplate = nil @@ -417,7 +417,7 @@ func (s *Server) Run(page string, innerpage bool, params interface{}, version st // if data is an error, launch the error page (the error has already been generated and handled) dataerror, okerr := data.(error) if okerr { - return s.launchError(page, ctx.Code, innerpage, dataerror.Error()) + return s.launchError(page, ctx.Code, !ctx.IsMainPage, dataerror.Error()) } _, okstr := data.(string) if innerpage && !okstr { // If Data is not string so it may be any type of data for the caller. We will not incapsulate it into a template, even if asked diff --git a/xamboo.go b/xamboo.go index bd4e317..4ebb2fb 100644 --- a/xamboo.go +++ b/xamboo.go @@ -1,4 +1,4 @@ package xamboo // VERSION oficial of the xamboo -const VERSION = "1.4.0" +const VERSION = "1.4.1"