2017-06-16 16:12:18 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2017-06-16 16:19:32 +00:00
|
|
|
var svgIcons = make(map[string]string)
|
|
|
|
|
|
|
|
func init() {
|
2017-06-17 13:14:15 +00:00
|
|
|
files, _ := ioutil.ReadDir("images/icons/")
|
2017-06-16 16:19:32 +00:00
|
|
|
|
|
|
|
for _, file := range files {
|
|
|
|
name := strings.Replace(file.Name(), ".svg", "", 1)
|
2017-06-17 13:14:15 +00:00
|
|
|
data, _ := ioutil.ReadFile("images/icons/" + name + ".svg")
|
2017-06-16 16:19:32 +00:00
|
|
|
svgIcons[name] = strings.Replace(string(data), "<svg ", "<svg class='icon' ", 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-16 16:12:18 +00:00
|
|
|
// Icon ...
|
|
|
|
func Icon(name string) string {
|
2017-06-16 16:19:32 +00:00
|
|
|
return svgIcons[name]
|
2017-06-16 16:12:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RawIcon ...
|
|
|
|
func RawIcon(name string) string {
|
2017-06-16 16:19:32 +00:00
|
|
|
return strings.Replace(svgIcons[name], "class='icon'", "class='raw-icon'", 1)
|
2017-06-16 16:12:18 +00:00
|
|
|
}
|