mirror of
https://github.com/Luzifer/mondash.git
synced 2024-12-23 12:31:18 +00:00
Knut Ahlers
f3c31476b4
* Update dependencies * Improve code quality * Apply linter advices * Add gzip compression to all requests * Rework frontend * Apply bootswatch theme * Hide historic details when not requested * Remove debugging header * Apply auto-migration of meta fields * Fix broken "last update" time * Pre-sort metrics for frontend / API * Add tooltip with absolute time * Some design fixes * Add tooltip with absolute date to last ok * Implement filters * Apply eslint --fix * Remove unused var * Remove remains of old template engine * Update baked in assets * Update Dockerfile for new version Signed-off-by: Knut Ahlers <knut@ahlers.me>
71 lines
1.4 KiB
Go
71 lines
1.4 KiB
Go
// +build none
|
|
|
|
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/zlib"
|
|
"encoding/binary"
|
|
"fmt"
|
|
"go/format"
|
|
"io/ioutil"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
data, err := ioutil.ReadFile("table.txt")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
var buf bytes.Buffer
|
|
for _, line := range strings.Split(string(data), "\n") {
|
|
if strings.HasPrefix(line, "/*") || line == "" {
|
|
continue
|
|
}
|
|
sep := strings.IndexByte(line, ':')
|
|
if sep == -1 {
|
|
panic(line)
|
|
}
|
|
val, err := strconv.ParseInt(line[:sep], 0, 32)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
s, err := strconv.Unquote(line[sep+2:])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if s == "" {
|
|
continue
|
|
}
|
|
if err := binary.Write(&buf, binary.LittleEndian, uint16(val)); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := binary.Write(&buf, binary.LittleEndian, uint8(len(s))); err != nil {
|
|
panic(err)
|
|
}
|
|
buf.WriteString(s)
|
|
}
|
|
var cbuf bytes.Buffer
|
|
w, err := zlib.NewWriterLevel(&cbuf, zlib.BestCompression)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if _, err := w.Write(buf.Bytes()); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := w.Close(); err != nil {
|
|
panic(err)
|
|
}
|
|
buf.Reset()
|
|
buf.WriteString("package unidecode\n")
|
|
buf.WriteString("// AUTOGENERATED - DO NOT EDIT!\n\n")
|
|
fmt.Fprintf(&buf, "var tableData = %q;\n", cbuf.String())
|
|
dst, err := format.Source(buf.Bytes())
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if err := ioutil.WriteFile("table.go", dst, 0644); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|