mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
use embed for http page
This commit is contained in:
71
build_web.go
71
build_web.go
@@ -1,13 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,40 +14,40 @@ func main() {
|
|||||||
run("npm", "run", "build-js")
|
run("npm", "run", "build-js")
|
||||||
os.Chdir(dir)
|
os.Chdir(dir)
|
||||||
|
|
||||||
compileHtml := "web/dest/"
|
run("cp", "web/dest/index.html", "server/web/pages/template/pages/")
|
||||||
|
// compileHtml := "web/dest/"
|
||||||
fs, _ := ioutil.ReadDir(compileHtml)
|
// fs, _ := ioutil.ReadDir(compileHtml)
|
||||||
for _, f := range fs {
|
// for _, f := range fs {
|
||||||
if strings.HasSuffix(f.Name(), ".html") {
|
// if strings.HasSuffix(f.Name(), ".html") {
|
||||||
name := filenameWithoutExtension(f.Name())
|
// name := filenameWithoutExtension(f.Name())
|
||||||
fmt.Println("Create template go:", "server/web/pages/template/"+name+"_html.go")
|
// fmt.Println("Create template go:", "server/web/pages/template/"+name+"_html.go")
|
||||||
out, err := os.Create("server/web/pages/template/" + name + "_html.go")
|
// out, err := os.Create("server/web/pages/template/" + name + "_html.go")
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
fmt.Println("Error create file", err)
|
// fmt.Println("Error create file", err)
|
||||||
os.Exit(1)
|
// os.Exit(1)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
fmt.Println("Read html:", compileHtml+f.Name())
|
// fmt.Println("Read html:", compileHtml+f.Name())
|
||||||
buf, err := ioutil.ReadFile(compileHtml + f.Name())
|
// buf, err := ioutil.ReadFile(compileHtml + f.Name())
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
fmt.Println("Error read file", err)
|
// fmt.Println("Error read file", err)
|
||||||
os.Exit(1)
|
// os.Exit(1)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
fmt.Println("Write template...")
|
// fmt.Println("Write template...")
|
||||||
out.Write([]byte("package template \n\nvar " + strings.Title(name) + "Html = []byte{"))
|
// out.Write([]byte("package template \n\nvar " + strings.Title(name) + "Html = []byte{"))
|
||||||
for _, b := range buf {
|
// for _, b := range buf {
|
||||||
out.Write([]byte(strconv.Itoa(int(b)) + ", "))
|
// out.Write([]byte(strconv.Itoa(int(b)) + ", "))
|
||||||
}
|
// }
|
||||||
out.Write([]byte("}"))
|
// out.Write([]byte("}"))
|
||||||
out.Close()
|
// out.Close()
|
||||||
|
//
|
||||||
fmt.Println("go fmt template...")
|
// fmt.Println("go fmt template...")
|
||||||
run("go", "fmt", "server/web/pages/template/"+name+"_html.go")
|
// run("go", "fmt", "server/web/pages/template/"+name+"_html.go")
|
||||||
fmt.Println("Complete OK")
|
// fmt.Println("Complete OK")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(name string, args ...string) {
|
func run(name string, args ...string) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
6
server/web/pages/template/pages/index.html
Normal file
6
server/web/pages/template/pages/index.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user