mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 09:55:36 +00:00
inline svg
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/nkanaev/yarr/storage"
|
||||
"github.com/mmcdole/gofeed"
|
||||
"net/http"
|
||||
"html/template"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"os"
|
||||
@@ -20,15 +21,14 @@ import (
|
||||
)
|
||||
|
||||
func IndexHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
f, err := os.Open("template/index.html")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
t := template.Must(template.New("index.html").Delims("{%", "%}").Funcs(template.FuncMap{
|
||||
"inline": func(svg string) template.HTML {
|
||||
content, _ := ioutil.ReadFile("template/static/images/" + svg)
|
||||
return template.HTML(content)
|
||||
},
|
||||
}).ParseFiles("template/index.html"))
|
||||
rw.Header().Set("Content-Type", "text/html")
|
||||
io.Copy(rw, f)
|
||||
|
||||
t.Execute(rw, nil)
|
||||
}
|
||||
|
||||
func StaticHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
|
@@ -148,6 +148,6 @@ func New() *http.Server {
|
||||
counter: make(chan int),
|
||||
}
|
||||
s := &http.Server{Addr: "127.0.0.1:8000", Handler: h}
|
||||
h.startJobs()
|
||||
//h.startJobs()
|
||||
return s
|
||||
}
|
||||
|
Reference in New Issue
Block a user