Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from webability-go/late-night
patch v0.0.15
- Loading branch information
Showing
21 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters