Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
gentee committed Dec 5, 2021
2 parents 16fc5fd + 493bbad commit 2473a2e
Show file tree
Hide file tree
Showing 16 changed files with 217 additions and 125 deletions.
19 changes: 19 additions & 0 deletions assets/assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,22 @@ packages:
options:
required: true

veracrypt:
version: 1.0
info:
title: VeraCrypt
desc: '#_desc#'
help: veracrypt
helplang: ru
langs:
en:
_desc: Scripts for working with the VeraCrypt program
ru:
_desc: Скрипты для работы с программой VeraCrypt
params:
- name: app
title: '#.appfile#'
type: 2
options:
required: true

Binary file modified assets/packages.tar.gz
Binary file not shown.
Binary file modified assets/stdlib.tar.gz
Binary file not shown.
Binary file modified assets/web.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion const.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package main

const (
// Version of the application
Version = "1.23.0"
Version = "1.24.0"
// DefPort is the default web-server port
DefPort = 3234
// DefTheme is the default web-server theme
Expand Down
50 changes: 29 additions & 21 deletions gensource.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type Param struct {
Name string
}

type Advanced struct {
LogLevel int
}

func (src *Source) Tree(tree []scriptTree) (string, error) {
var (
body, tmp string
Expand Down Expand Up @@ -113,10 +117,14 @@ func (src *Source) getTypeValue(script *Script, par es.ScriptParam, value string
return ptype, value
}

func (src *Source) ScriptValues(script *Script, node scriptTree) ([]Param, []Param, error) {
func (src *Source) ScriptValues(script *Script, node scriptTree) ([]Param, []Param, Advanced, error) {
values := make([]Param, 0, len(script.Params))
var optvalues []Param

more := Advanced{
LogLevel: script.Settings.LogLevel,
}

errField := func(field string) error {
glob := langRes[langsId[src.Header.Lang]]
return fmt.Errorf(langRes[langsId[src.Header.Lang]][`errfield`],
Expand All @@ -130,15 +138,15 @@ func (src *Source) ScriptValues(script *Script, node scriptTree) ([]Param, []Par
if optional, ok := node.Values[`_optional`]; ok {
if v, ok := optional.(string); ok {
if err := yaml.Unmarshal([]byte(v), &opt); err != nil {
return nil, nil, err
return nil, nil, more, err
}
}
}
if adv, ok := node.Values[`_advanced`]; ok {
var advanced map[string]interface{}
if v, ok := adv.(string); ok {
if err := yaml.Unmarshal([]byte(v), &advanced); err != nil {
return nil, nil, err
return nil, nil, more, err
}
retypeValues(advanced)
}
Expand All @@ -147,6 +155,11 @@ func (src *Source) ScriptValues(script *Script, node scriptTree) ([]Param, []Par
params = pars
}
}
if v, ok := advanced[`log`]; ok {
if level, ok := es.Logs[strings.ToUpper(fmt.Sprint(v))]; ok {
more.LogLevel = level
}
}
}
for _, par := range script.Params {
var (
Expand Down Expand Up @@ -198,19 +211,19 @@ func (src *Source) ScriptValues(script *Script, node scriptTree) ([]Param, []Par
switch par.Type {
case es.PTextarea, es.PSingleText, es.PNumber, es.PPassword:
if isEmpty && par.Options.Required && len(node.Name) != 0 {
return nil, nil, errField(par.Title)
return nil, nil, more, errField(par.Title)
}
case es.PList:
if val != nil && reflect.TypeOf(val).Kind() == reflect.Slice &&
reflect.ValueOf(val).Len() > 0 {
out, err := json.Marshal(val)
if err != nil {
return nil, nil, err
return nil, nil, more, err
}
value = src.FindStrConst(string(out))
} else {
if par.Options.Required {
return nil, nil, errField(par.Title)
return nil, nil, more, errField(par.Title)
}
value = src.FindStrConst(`[]`)
}
Expand All @@ -226,7 +239,7 @@ func (src *Source) ScriptValues(script *Script, node scriptTree) ([]Param, []Par
values = append(values, param)
}
}
return values, optvalues, nil
return values, optvalues, more, nil
}

func (src *Source) Predefined(script *Script) (ret string, err error) {
Expand Down Expand Up @@ -303,12 +316,12 @@ func (src *Source) Script(node scriptTree) (string, error) {
var (
ifcond string
)
script := getScript(node.Name)
script := getRunScript(node.Name)
if script == nil {
return ``, fmt.Errorf(Lang(DefLang, `erropen`), node.Name)
}
idname := lib.IdName(script.Settings.Name)
values, optvalues, err := src.ScriptValues(script, node)
values, optvalues, advanced, err := src.ScriptValues(script, node)
if err != nil {
return ``, err
}
Expand Down Expand Up @@ -352,7 +365,7 @@ func (src *Source) Script(node scriptTree) (string, error) {
var vars []string
for i, par := range values {
params = append(params, fmt.Sprintf("%s %s", par.Type, par.Name))
if script.Params[i].Options.Flags == "password" {
if strings.Contains(script.Params[i].Options.Flags, "password") {
parNames += `,"***"`
} else {
parNames += `,` + par.Name
Expand Down Expand Up @@ -391,15 +404,9 @@ func (src *Source) Script(node scriptTree) (string, error) {
deinit()`
}
}
if script.Settings.LogLevel < es.LOG_INHERIT {
prefix += fmt.Sprintf("int prevLog = SetLogLevel(%d)\r\n", script.Settings.LogLevel)
suffix = "\r\nSetLogLevel(prevLog)"
}
name := script.Settings.Name
if script.Settings.LogLevel == es.LOG_INFO {
name = `*` + name
}
initcmd = fmt.Sprintf("initcmd(`%s`%s)\r\n", name, parNames)
suffix = "\r\nSetLogLevel(prevLog)"
initcmd = fmt.Sprintf("int prevLog = initcmd(%d, `%s`%s)\r\n", advanced.LogLevel,
script.Settings.Name, parNames)
if len(predef) > 0 {
initcmd += "\r\n" + predef
}
Expand Down Expand Up @@ -448,7 +455,7 @@ func GenSource(script *Script, header *es.Header) (string, error) {
Header: header,
}
level := storage.Settings.LogLevel
if script.Settings.LogLevel < es.LOG_INHERIT {
if script.Settings.LogLevel != es.LOG_INHERIT {
level = script.Settings.LogLevel
}
params = append(params, fmt.Sprintf("SetLogLevel(%d)\r\ninit()", level))
Expand Down Expand Up @@ -500,7 +507,8 @@ func GenSource(script *Script, header *es.Header) (string, error) {
if err != nil {
return ``, err
}
params = append(params, fmt.Sprintf("initcmd(`form`, %s)\r\nForm( %[1]s )", src.Value(string(outForm), false)))
params = append(params, fmt.Sprintf("initcmd(%d,`form`, %s)\r\nForm( %[2]s )", level,
src.Value(string(outForm), false)))
}
for _, par := range script.Params {
var ptype string
Expand Down
25 changes: 10 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,32 @@ module eonza
go 1.16

require (
github.com/PuerkitoBio/goquery v1.7.1
github.com/alecthomas/chroma v0.9.2
github.com/alecthomas/colour v0.1.0 // indirect
github.com/alecthomas/repr v0.0.0-20210301060118-828286944d6a // indirect
github.com/PuerkitoBio/goquery v1.8.0
github.com/alecthomas/chroma v0.9.4
github.com/atotto/clipboard v0.1.4
github.com/boombuler/barcode v1.0.1 // indirect
github.com/gentee/eonza-pro v0.0.0-00010101000000-000000000000
github.com/gentee/gentee v1.20.0
github.com/gentee/gentee v1.21.0
github.com/gentee/systray v1.3.1
github.com/go-sql-driver/mysql v1.6.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/gorilla/websocket v1.4.2
github.com/kataras/golog v0.1.7
github.com/kr/text v0.2.0 // indirect
github.com/labstack/echo/v4 v4.4.0
github.com/lib/pq v1.10.2
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/labstack/echo/v4 v4.6.1
github.com/lib/pq v1.10.4
github.com/pquerna/otp v1.3.0 // indirect
github.com/robfig/cron/v3 v3.0.1
github.com/sergi/go-diff v1.2.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/xhit/go-simple-mail/v2 v2.10.0
github.com/xuri/excelize/v2 v2.4.1
github.com/yuin/goldmark v1.4.0
github.com/yuin/goldmark v1.4.4
github.com/yuin/goldmark-highlighting v0.0.0-20210516132338-9216f9c5aa01
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
golang.org/x/text v0.3.6
golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8
golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.62.0
gopkg.in/ini.v1 v1.64.0
gopkg.in/yaml.v2 v2.4.0
)

Expand Down
Loading

0 comments on commit 2473a2e

Please sign in to comment.