Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
gentee committed Feb 4, 2021
2 parents 2e3947b + 50048db commit b29dba2
Show file tree
Hide file tree
Showing 16 changed files with 1,192 additions and 454 deletions.
40 changes: 40 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ func runHandle(c echo.Context) error {
if err != nil {
return jsonError(c, err)
}
if storage.Trial.Mode == TrialOn {
now := time.Now()
if storage.Trial.Last.Day() != now.Day() {
storage.Trial.Count++
storage.Trial.Last = now
if storage.Trial.Count > TrialDays {
storage.Trial.Mode = TrialDisabled
SetActive(false)
}
if err = SaveStorage(); err != nil {
return jsonError(c, err)
}
}
}
if err = NewTask(header); err != nil {
return jsonError(c, err)
}
Expand Down Expand Up @@ -306,3 +320,29 @@ func removeTaskHandle(c echo.Context) error {
RemoveTask(uint32(idTask))
return tasksHandle(c)
}

func trialHandle(c echo.Context) error {
var (
err error
mode int
)
mode = storage.Trial.Mode
if c.Param("id") == `1` {
if storage.Trial.Mode == TrialOff && storage.Trial.Count < TrialDays {
storage.Trial.Mode = TrialOn
}
} else {
if storage.Trial.Mode == TrialOn {
storage.Trial.Mode = TrialOff
}
}
if mode != storage.Trial.Mode {
if err = SetActive(storage.Trial.Mode == TrialOn); err != nil {
return jsonError(c, err)
}
if err = SaveStorage(); err != nil {
return jsonError(c, err)
}
}
return proSettingsHandle(c)
}
1,069 changes: 656 additions & 413 deletions assets.go

Large diffs are not rendered by default.

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.11.0"
Version = "1.12.0"
// DefPort is the default web-server port
DefPort = 3234
// DefTheme is the default web-server theme
Expand Down
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ require (
github.com/atotto/clipboard v0.1.2
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/gentee/eonza-pro v0.0.0-00010101000000-000000000000
github.com/gentee/gentee v1.20.0
github.com/gentee/systray v1.3.1
github.com/go-sql-driver/mysql v1.5.0
github.com/gorilla/websocket v1.4.2
github.com/kataras/golog v0.1.6
github.com/kr/text v0.2.0 // indirect
github.com/labstack/echo/v4 v4.1.17
github.com/lib/pq v1.9.0
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/robfig/cron/v3 v3.0.1
github.com/sergi/go-diff v1.1.0 // indirect
github.com/stretchr/testify v1.6.1 // indirect
github.com/xhit/go-simple-mail/v2 v2.7.0
github.com/yuin/goldmark v1.3.0
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
golang.org/x/crypto v0.0.0-20201217014255-9d1352758620
golang.org/x/net v0.0.0-20201216054612-986b41b23924 // indirect
golang.org/x/text v0.3.4 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
)

replace github.com/gentee/eonza-pro => ../eonza-pro
18 changes: 6 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/gentee/gentee v1.19.0 h1:REr9QHbOdPhV2mSYiGgVsmtgyJUrXD4K4ouuPQp8CQ8=
github.com/gentee/gentee v1.19.0/go.mod h1:Qyf1jQ8a/yUyPEHrl1RTHKNSTJ923lsPnghIawrdDN4=
github.com/gentee/gentee v1.20.0 h1:t2UMhmKeNPsJSKxFAj3G6MnJ3D4H0Nhao8vRbwoiPZo=
github.com/gentee/gentee v1.20.0/go.mod h1:Qyf1jQ8a/yUyPEHrl1RTHKNSTJ923lsPnghIawrdDN4=
github.com/gentee/systray v1.3.0 h1:LQAgBqmPn8d7R97LDtCjjXBbxzaJuDqXWpzaZvQmAH0=
github.com/gentee/systray v1.3.0/go.mod h1:kRYUt6YMFVPJdzpimbAH6dkLuZfQSzdcCQUhBiT5auA=
github.com/gentee/systray v1.3.1 h1:yLHp4v3WYXhdqlfeG32qzNNtqsO5YODwJwTefW4yewk=
github.com/gentee/systray v1.3.1/go.mod h1:vj38v/It1PQHccJKl+18Fh0T0Eitrij3ASRSkte6LWQ=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/gorilla/csrf v1.6.0/go.mod h1:7tSf8kmjNYr7IWDCYhd3U8Ck34iQ/Yw5CJu7bAkHEGI=
Expand All @@ -70,6 +68,8 @@ github.com/labstack/echo/v4 v4.1.17 h1:PQIBaRplyRy3OjwILGkPg89JRtH2x5bssi59G2EL3
github.com/labstack/echo/v4 v4.1.17/go.mod h1:Tn2yRQL/UclUalpb5rPdXDevbkJ+lp/2svdyFBg6CHQ=
github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
Expand All @@ -90,7 +90,6 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
Expand All @@ -100,15 +99,14 @@ github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/xhit/go-simple-mail/v2 v2.7.0 h1:nOF6n3uVuw80SSVugR9Mm9pju+sKSwhZRoDXCMteb24=
github.com/xhit/go-simple-mail/v2 v2.7.0/go.mod h1:kA1XbQfCI4JxQ9ccSN6VFyIEkkugOm7YiPkA5hKiQn4=
github.com/yuin/goldmark v1.1.22 h1:0e0f6Zee9SAQ5yOZGNMWaOxqVvcc/9/kUWu/Kl91Jk8=
github.com/yuin/goldmark v1.1.22/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.0 h1:DRvEHivhJ1fQhZbpmttnonfC674RycyZGE/5IJzDKgg=
Expand Down Expand Up @@ -161,7 +159,3 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func main() {
LoadNotifications()
InitScripts()
CreateSysTray()
ProInit()
RunCron()
e = RunServer(WebSettings{
Port: cfg.HTTP.Port,
Expand Down
2 changes: 1 addition & 1 deletion make.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ run {

$ /home/ak/go/bin/esc -ignore "\.git|LICENSE|README.md" -o assets.go ../eonza-assets
// $ go install -ldflags "-s -w" -tags "eonza standard"
$ go install -tags tray -ldflags "-s -w -X main.VerType=%{vertype} -X main.CompileDate=%{Format(`YYYY-MM-DD`,Now())}"
$ go install -tags "tray" -ldflags "-s -w -X main.VerType=%{vertype} -X main.CompileDate=%{Format(`YYYY-MM-DD`,Now())}"
// $ go install -ldflags "-s -w -X main.VerType=%{vertype} -X main.CompileDate=%{Format(`YYYY-MM-DD`,Now())}"
$ cp ${GOPATH}/bin/eonza /home/ak/app/eonza-dev/eonza
$ cp ${GOPATH}/bin/eonza /home/ak/app/eonza/eonza
Expand Down
17 changes: 17 additions & 0 deletions notpro.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,21 @@

package main

import (
"fmt"

"github.com/labstack/echo/v4"
)

const Pro = false

func ProInit() {
}

func SetActive(active bool) error {
return nil
}

func proSettingsHandle(c echo.Context) error {
return jsonError(c, fmt.Errorf(`Unsupported`))
}
33 changes: 32 additions & 1 deletion pro.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,35 @@

package main

const Pro = true
import (
"net/http"

pro "github.com/gentee/eonza-pro"
"github.com/labstack/echo/v4"
)

type ProOptions struct {
Active bool `json:"active"`
Settings pro.Settings `json:"settings"`
Trial Trial `json:"trial"`
}

const (
Pro = true
)

func SetActive(active bool) error {
return pro.SetActive(active)
}

func ProInit() {
pro.LoadPro(storage.Trial.Mode > 0)
}

func proSettingsHandle(c echo.Context) error {
var response ProOptions

response.Active = pro.Active
response.Trial = storage.Trial
return c.JSON(http.StatusOK, &response)
}
3 changes: 3 additions & 0 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type Render struct {
Favs []Fav
Nfy *NfyResponse
Update VerUpdate
Pro bool
// ProSettings ProSettings
// Port int
/* Params map[string]string
Url string
Expand Down Expand Up @@ -179,6 +181,7 @@ func RenderPage(c echo.Context, url string) (string, error) {
render.Nfy = NfyList(false)
render.Update = nfyData.Update
render.Update.Notify = GetNewVersion(GetLangCode(c.(*Auth).User))
render.Pro = Pro
data = render
}

Expand Down
31 changes: 8 additions & 23 deletions script/embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
package script

import (
"bytes"
"encoding/json"
"eonza/lib"
"fmt"
"net/http"
"os"
"strconv"
"strings"
Expand All @@ -19,7 +17,6 @@ import (
"github.com/atotto/clipboard"
"github.com/gentee/gentee"
"github.com/gentee/gentee/vm"
"github.com/kataras/golog"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -69,6 +66,7 @@ type ScriptOptions struct {
Default string `json:"default,omitempty" yaml:"default,omitempty"`
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
Optional bool `json:"optional,omitempty" yaml:"optional,omitempty"`
Flags string `json:"flags,omitempty" yaml:"flags,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Items []ScriptItem `json:"items,omitempty" yaml:"items,omitempty"`
List []ScriptParam `json:"list,omitempty" yaml:"list,omitempty"`
Expand Down Expand Up @@ -152,6 +150,13 @@ var (
{Prototype: `GetVarInt(str) int`, Object: GetVarInt},
{Prototype: `GetVarObj(str) obj`, Object: GetVarObj},
{Prototype: `SendNotification(str)`, Object: SendNotification},
{Prototype: `SendEmail(obj, obj)`, Object: SendEmail},
{Prototype: `SQLClose(str)`, Object: SQLClose},
{Prototype: `SQLConnection(map.str, str)`, Object: SQLConnection},
{Prototype: `SQLExec(str,str,arr.str)`, Object: SQLExec},
{Prototype: `SQLQuery(str,str,arr.str,str)`, Object: SQLQuery},
{Prototype: `SQLRow(str,str,arr.str,str)`, Object: SQLRow},
{Prototype: `SQLValue(str,str,arr.str,str)`, Object: SQLValue},
// For gentee
{Prototype: `YamlToMap(str) map`, Object: YamlToMap},
// {Prototype: `Subbuf(buf,int,int) buf`, Object: Subbuf},
Expand Down Expand Up @@ -669,26 +674,6 @@ func InitEngine() error {
})
}

func SendNotification(msg string) error {
jsonValue, err := json.Marshal(PostNfy{
TaskID: scriptTask.Header.TaskID,
Text: msg,
Script: scriptTask.Header.Name,
})
if err == nil {
resp, err := http.Post(fmt.Sprintf("http://localhost:%d/api/notification",
scriptTask.Header.ServerPort), "application/json", bytes.NewBuffer(jsonValue))
if err != nil {
golog.Error(err)
} else {
resp.Body.Close()
}
} else {
return err
}
return nil
}

func CopyClipboard(data string) error {
return clipboard.WriteAll(data)
}
Expand Down
Loading

0 comments on commit b29dba2

Please sign in to comment.