Skip to content

Commit

Permalink
Merge pull request #29 from webability-go/late-night
Browse files Browse the repository at this point in the history
patch v2022.06.09
  • Loading branch information
metalwolf authored Jun 9, 2022
2 parents 095cb26 + 3b5799e commit c68b43e
Show file tree
Hide file tree
Showing 117 changed files with 5,238 additions and 1,676 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ import "github.com/webability-go/xmodules/ingredient"

import "github.com/webability-go/xmodules/material"

v2022-06-09:
- Go 1.17 and Xamboo 1.6 compatibility: Now uses embed FS, languages, and functions entry table, not anymore a bridge

v2021-03-12:
- Go 1.16.1 compatibility: modified global variables assignment to be sure they are set correctly, now into init()

v2021-02-16:
- All the modules have been changed to meet new Xamboo applications interfaces

Expand Down
23 changes: 23 additions & 0 deletions adminmenu/assets/moduleentries.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ import (
"github.com/webability-go/xdominion"

"github.com/webability-go/xamboo/applications"
"github.com/webability-go/xamboo/cms/context"

"github.com/webability-go/xmodules/base"
)

const (
MODULEID = "adminmenu"
VERSION = "0.0.1"
DATASOURCE = "adminmenudatasource"
)

var Needs = []string{"base", "user"}

type ModuleEntries struct {
AddGroup func(ds applications.Datasource, key string, name string) error
GetGroup func(ds applications.Datasource, key string) (*xdominion.XRecord, error)
Expand All @@ -14,3 +25,15 @@ type ModuleEntries struct {

GetMenu func(ds applications.Datasource, group string, father string) (*xdominion.XRecords, error)
}

func GetEntries(ctx *context.Context) *ModuleEntries {
me := base.GetEntries(ctx, MODULEID)
if me == nil {
return nil
}
lme, ok := me.(*ModuleEntries)
if !ok {
return nil
}
return lme
}
30 changes: 0 additions & 30 deletions adminmenu/bridge/link.go

This file was deleted.

46 changes: 23 additions & 23 deletions adminmenu/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
package adminmenu

import (
"embed"

"golang.org/x/text/language"

"github.com/webability-go/xcore/v2"

"github.com/webability-go/xamboo/applications"
"github.com/webability-go/xamboo/cms/context"

Expand All @@ -14,35 +18,31 @@ import (
"github.com/webability-go/xmodules/tools"
)

const (
MODULEID = "adminmenu"
VERSION = "0.0.1"
DATASOURCE = "adminmenudatasource"
)

var Needs = []string{"base", "user"}
var ModuleAdminMenu = assets.ModuleEntries{
AddGroup: AddGroup,
GetGroup: GetGroup,
AddOption: AddOption,
GetOption: GetOption,
GetMenu: GetMenu,
}
//go:embed languages/*.language
var fsmessages embed.FS
var messages *map[language.Tag]*xcore.XLanguage

func init() {
messages = tools.BuildMessages(smessages)
messages = tools.BuildMessagesFS(fsmessages, "languages")
m := &base.Module{
ID: MODULEID,
Version: VERSION,
ID: assets.MODULEID,
Version: assets.VERSION,
Languages: map[language.Tag]string{
language.English: tools.Message(messages, "MODULENAME", language.English),
language.Spanish: tools.Message(messages, "MODULENAME", language.Spanish),
language.French: tools.Message(messages, "MODULENAME", language.French),
},
Needs: Needs,
Needs: assets.Needs,
FSetup: Setup, // Called once at the main system startup, once PER CREATED xmodule CONTEXT (if set)
FSynchronize: Synchronize, // Called only to create/rebuild database objects and others on demand (if set)
FStartContext: StartContext, // Called each time a new Server context is created (if set)
Entries: &assets.ModuleEntries{
AddGroup: AddGroup,
GetGroup: GetGroup,
AddOption: AddOption,
GetOption: GetOption,
GetMenu: GetMenu,
},
}
base.ModulesList.Register(m)
}
Expand All @@ -52,7 +52,7 @@ func init() {
func Setup(ds applications.Datasource, prefix string) ([]string, error) {

linkTables(ds)
ds.SetModule(MODULEID, VERSION)
ds.SetModule(assets.MODULEID, assets.VERSION)

return []string{}, nil
}
Expand All @@ -61,13 +61,13 @@ func Synchronize(ds applications.Datasource, prefix string) ([]string, error) {

result := []string{}

ok, res := base.VerifyNeeds(ds, Needs)
ok, res := base.VerifyNeeds(ds, assets.Needs)
result = append(result, res...)
if !ok {
return result, nil
}

installed := base.ModuleInstalledVersion(ds, MODULEID)
installed := base.ModuleInstalledVersion(ds, assets.MODULEID)

// synchro tables
err, r := synchroTables(ds, installed)
Expand All @@ -93,9 +93,9 @@ func Synchronize(ds applications.Datasource, prefix string) ([]string, error) {
}
result = append(result, r...)
if err == nil {
err = base.AddModule(cds, MODULEID, tools.Message(messages, "MODULENAME"), VERSION)
err = base.AddModule(cds, assets.MODULEID, tools.Message(messages, "MODULENAME"), assets.VERSION)
if err == nil {
result = append(result, tools.Message(messages, "modulemodified", MODULEID))
result = append(result, tools.Message(messages, "modulemodified", assets.MODULEID))
result = append(result, tools.Message(messages, "commit"))
err = cds.Commit()
if err != nil {
Expand Down
31 changes: 31 additions & 0 deletions adminmenu/languages/adminmenu.en.language
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<language id="adminmenu" lang="en">

<!-- Module installation messages -->
<!-- init.go -->
<entry id="MODULENAME">Administration menu</entry>
<entry id="modulemodified">The entry %s was modified successfully in the base_module table.</entry>
<entry id="commit">Installation successfull.</entry>
<entry id="rollback">Installation aborted with error: %s</entry>

<!-- util.go -->
<entry id="MAINMENU">Default Administration menu</entry>
<entry id="accessgroup.name">Access group for menu administration</entry>
<entry id="accessgroup.description">Group of all accesses for menu administration</entry>
<entry id="access.name">Access for menu administration</entry>
<entry id="access.description">Access for menu administration</entry>
<entry id="menufolder.name">Menu constructor</entry>
<entry id="menufolder.description1">Click on this line to see the different options for the administration of menus</entry>
<entry id="adminmenugroup.name">Menu groups and options</entry>
<entry id="adminmenugroup.description1">Menu groups and options</entry>

<entry id="moduleerror">Error modifying the entry %s in the base_module table: %s</entry>
<!-- Datasources transactions -->
<entry id="transaction.exist">Error creating a transaction: There is already a started transaction.</entry>
<entry id="transaction.none">Error searching the transaction: There is no available transaction.</entry>
<entry id="transaction.commitnone">Error searching the transaction to commit: There is no available transaction.</entry>
<entry id="transaction.rollbacknone">Error searching the transaction to rollback: There is no available transaction.</entry>
<entry id="transaction.error">Error in the transaction: %s</entry>
<!-- Containers -->
<entry id="database.none">There is no available database in the datasource</entry>
</language>
31 changes: 31 additions & 0 deletions adminmenu/languages/adminmenu.es.language
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<language id="adminmenu" lang="es">

<!-- Module installation messages -->
<!-- init.go -->
<entry id="MODULENAME">Menu de administración</entry>
<entry id="modulemodified">La entrada %s fue modificada con exito en la tabla base_module.</entry>
<entry id="commit">Instalación exitosa.</entry>
<entry id="rollback">Instalación con error: %s</entry>

<!-- util.go -->
<entry id="MAINMENU">Menú de administración por defecto</entry>
<entry id="accessgroup.name">Grupos de accesos de la administración de menús</entry>
<entry id="accessgroup.description">Grupos de accesos de la administración de menús</entry>
<entry id="access.name">Acceso de la administración de menús</entry>
<entry id="access.description">Acceso de la administración de menús</entry>
<entry id="menufolder.name">Constructor de menús</entry>
<entry id="menufolder.description1">Haz clic sobre esta linea para ver las diferentes opciones para la administración de menús.</entry>
<entry id="adminmenugroup.name">Grupos y opciones de menús</entry>
<entry id="adminmenugroup.description1">Grupos y opciones de menús</entry>

<entry id="moduleerror">Error modificando la entrada %s en la tabla base_module: %s</entry>
<!-- Datasources transactions -->
<entry id="transaction.exist">Error creating a transaction: There is already a started transaction.</entry>
<entry id="transaction.none">Error searching the transaction: There is no available transaction.</entry>
<entry id="transaction.commitnone">Error searching the transaction to commit: There is no available transaction.</entry>
<entry id="transaction.rollbacknone">Error searching the transaction to rollback: There is no available transaction.</entry>
<entry id="transaction.error">Error in the transaction: %s</entry>
<!-- Containers -->
<entry id="database.none">There is no available database in the datasource</entry>
</language>
31 changes: 31 additions & 0 deletions adminmenu/languages/adminmenu.fr.language
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<language id="adminmenu" lang="fr">

<!-- Module installation messages -->
<!-- init.go -->
<entry id="MODULENAME">Menu pour l'administration</entry>
<entry id="modulemodified">L'entrée %s a été modifiée avec succès dans la table base_module.</entry>
<entry id="commit">Instalation réussie.</entry>
<entry id="rollback">Instalation avec erreur: %s</entry>

<!-- util.go -->
<entry id="MAINMENU">Menu d'administration par défaut</entry>
<entry id="accessgroup.name">Groupe des accès d'administration de menus</entry>
<entry id="accessgroup.description">Groupe des accès d'administration de menus</entry>
<entry id="access.name">Accès d'administration de menus</entry>
<entry id="access.description">Accès d'administration de menus</entry>
<entry id="menufolder.name">Constructeur de menus</entry>
<entry id="menufolder.description1">Constructeur de menus</entry>
<entry id="adminmenugroup.name">Groupes et options de menus</entry>
<entry id="adminmenugroup.description1">Groupes et options de menus</entry>

<entry id="moduleerror">Erreur en modifiant l'entrée %s dans la table base_module: %s</entry>
<!-- Datasources transactions -->
<entry id="transaction.exist">Error creating a transaction: There is already a started transaction.</entry>
<entry id="transaction.none">Error searching the transaction: There is no available transaction.</entry>
<entry id="transaction.commitnone">Error searching the transaction to commit: There is no available transaction.</entry>
<entry id="transaction.rollbacknone">Error searching the transaction to rollback: There is no available transaction.</entry>
<entry id="transaction.error">Error in the transaction: %s</entry>
<!-- Containers -->
<entry id="database.none">There is no available database in the datasource</entry>
</language>
106 changes: 0 additions & 106 deletions adminmenu/messages.go

This file was deleted.

Loading

0 comments on commit c68b43e

Please sign in to comment.