Skip to content

Commit

Permalink
Merge pull request #16 from webability-go/late-night
Browse files Browse the repository at this point in the history
patch v0.0.15
  • Loading branch information
metalwolf committed Apr 26, 2020
2 parents 86627c8 + 5260aa5 commit 546ef86
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -20,6 +20,10 @@ TO DO:
Version Changes Control
=======================

v0.0.15 - 2020-04-26
------------------------
- JS code is now embedded into GO code in resources directory. embed.go is added to generate embedded code, but is not compilable with the libraries.

v0.0.14 - 2020-04-13
------------------------
- Correction on node: HELP as messages, not help children
Expand Down
3 changes: 3 additions & 0 deletions js/README.md
@@ -0,0 +1,3 @@
Here are the javascript sources files. They are not directly used but embeded in the ../resources/resources.go file

Apply go run embed.go before posting on github or before compiling if there are changes in the javascript.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions resources/README.md
@@ -0,0 +1,3 @@
Here are the compiled resources in the resources.go file. The source is in ../js directory.

Apply go run embed.go before posting on github or before compiling if there are changes in the javascript.
17 changes: 17 additions & 0 deletions resources/container.go
@@ -0,0 +1,17 @@
package resources

type Container map[string][]byte

var ResourcesContainer = NewContainer()

func NewContainer() *Container {
return &Container{}
}

func (c *Container) Set(name string, data []byte) {
(*c)[name] = data
}

func (c *Container) Get(name string) []byte {
return (*c)[name]
}
58 changes: 58 additions & 0 deletions resources/embed.go
@@ -0,0 +1,58 @@
//+build ignore

package main

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)

// Will read all .js files in ../js repository and add them to resources.go in this directory
func main() {
wd, _ := os.Getwd()

xpath := strings.Split(wd, "/")
lpath := len(xpath)

postdir := ""
if xpath[lpath-1] == "resources" {
postdir = "/../js"
} else {
postdir = "/js"
}

newpath := wd + postdir
newpath = filepath.Clean(newpath)
lnewpath := len(newpath)

fmt.Println("New path:", newpath)

dataresource := "package resources\n\nfunc init() {\n"

filepath.Walk(newpath, func(path string, info os.FileInfo, err error) error {
ext := filepath.Ext(path)
if ext != ".js" {
return nil
}
oficialpath := path[lnewpath+1:]
data, err := ioutil.ReadFile(path)
if err != nil {
return err
}
sdata := fmt.Sprint(data)
if len(sdata) <= 2 {
return nil
}
xdata := strings.Split(sdata[1:len(sdata)-1], " ")
dataresource += " ResourcesContainer.Set(\"" + oficialpath + "\", []byte{" + strings.Join(xdata, ",") + "})\n"
fmt.Println(oficialpath)
return nil
})

dataresource += "}\n"

ioutil.WriteFile("resources.go", []byte(dataresource), 0644)
}
41 changes: 41 additions & 0 deletions resources/resources.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion wajaf.go
Expand Up @@ -7,7 +7,7 @@
package wajaf

// VERSION is the used version nombre of the XCore library.
const VERSION = "0.0.14"
const VERSION = "0.0.15"

// LOG is the flag to activate logging on the library.
// if LOG is set to TRUE, LOG indicates to the XCore libraries to log a trace of functions called, with most important parameters.
Expand Down

0 comments on commit 546ef86

Please sign in to comment.