Skip to content

Commit

Permalink
Merge pull request #54 from webability-go/late-night
Browse files Browse the repository at this point in the history
patch v1.4.1
  • Loading branch information
metalwolf authored Aug 18, 2020
2 parents 8b83f2e + 3fd08bf commit 7a41dfc
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 8 deletions.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============================
Expand All @@ -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
Expand All @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -295,15 +295,15 @@ 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() {
// This engine does not need more than the .page itself.
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
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xamboo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xamboo

// VERSION oficial of the xamboo
const VERSION = "1.4.0"
const VERSION = "1.4.1"

0 comments on commit 7a41dfc

Please sign in to comment.