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>
41 lines
771 B
Go
41 lines
771 B
Go
package unidecode
|
|
|
|
import (
|
|
"compress/zlib"
|
|
"encoding/binary"
|
|
"io"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
transliterations [65536][]rune
|
|
transCount = rune(len(transliterations))
|
|
getUint16 = binary.LittleEndian.Uint16
|
|
)
|
|
|
|
func decodeTransliterations() {
|
|
r, err := zlib.NewReader(strings.NewReader(tableData))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer r.Close()
|
|
tmp1 := make([]byte, 2)
|
|
tmp2 := tmp1[:1]
|
|
for {
|
|
if _, err := io.ReadAtLeast(r, tmp1, 2); err != nil {
|
|
if err == io.EOF {
|
|
break
|
|
}
|
|
panic(err)
|
|
}
|
|
chr := getUint16(tmp1)
|
|
if _, err := io.ReadAtLeast(r, tmp2, 1); err != nil {
|
|
panic(err)
|
|
}
|
|
b := make([]byte, int(tmp2[0]))
|
|
if _, err := io.ReadFull(r, b); err != nil {
|
|
panic(err)
|
|
}
|
|
transliterations[int(chr)] = []rune(string(b))
|
|
}
|
|
}
|