From 6fd66dbe269faf92e54f637436d6dc9d0e82c4c9 Mon Sep 17 00:00:00 2001 From: danoloan Date: Fri, 11 Feb 2022 19:52:56 +0100 Subject: [PATCH] =?UTF-8?q?Arreglado=20fallo=20a=C3=B1adiendo=20im=C3=A1ge?= =?UTF-8?q?nes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Las imágenes añadidas no aparecían sin reiniciar el servidor. --- main.go | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index 7d8be2d..d2d550a 100644 --- a/main.go +++ b/main.go @@ -1,12 +1,14 @@ package main import ( + "crypto/sha512" + "encoding/hex" "encoding/json" "fmt" "html/template" - "crypto/sha512" "io" "io/ioutil" + "mime" "net/http" "os" "os/exec" @@ -15,13 +17,11 @@ import ( "strings" "sync" "time" - "encoding/hex" - "mime" + "github.com/google/uuid" + "github.com/gorilla/feeds" "github.com/labstack/echo" "github.com/labstack/echo/middleware" - "github.com/gorilla/feeds" - "github.com/google/uuid" //"github.com/labstack/echo/middleware" ) @@ -36,7 +36,7 @@ type ( } Entry struct { - Date JSTime `json:"date"` + Date JSTime `json:"date"` Description string `json:"description"` Post string `json:"post"` Likes int `json:"likes"` @@ -146,9 +146,6 @@ func (list *entryMap) write() (err error) { if err == nil { err = ioutil.WriteFile(list.filename, data, 0644) } - if err == nil { - list.modtime = time.Now() - } return } @@ -162,7 +159,7 @@ func (list *entryMap) read() (err error) { // sort list list.sorted = make([]*Entry, 0, len(list.mapped)) - for _, entry:= range list.mapped { + for _, entry := range list.mapped { list.sorted = append(list.sorted, entry) } sort.Sort(entryList(list.sorted)) @@ -239,20 +236,20 @@ func (list *entryMap) getEntry(uuid string) (result *Entry, err error) { } func (list *entryMap) getFeed() (feed *feeds.Feed) { - feed = &feeds.Feed { - Title: "danoloan.es igar", - Link: &feeds.Link { Href: "https://danoloan.es/igar/" }, + feed = &feeds.Feed{ + Title: "danoloan.es igar", + Link: &feeds.Link{Href: "https://danoloan.es/igar/"}, Description: "bitácora fotográfica de danoloan", - Author: &feeds.Author { Name: "danoloan", Email: "danolo@danoloan.es" }, + Author: &feeds.Author{Name: "danoloan", Email: "danolo@danoloan.es"}, } feed.Items = make([]*feeds.Item, 0, list.Len()) for _, elem := range list.getSortedEntries() { - item := &feeds.Item { - Title: elem.Description, - Link: &feeds.Link{ Href: fmt.Sprintf("https://danoloan.es/igar/view?uuid=%s", elem.Post) }, + item := &feeds.Item{ + Title: elem.Description, + Link: &feeds.Link{Href: fmt.Sprintf("https://danoloan.es/igar/view?uuid=%s", elem.Post)}, Description: fmt.Sprintf("

%s

\n
\n", elem.Description), - Created: time.Time(elem.Date), + Created: time.Time(elem.Date), } for _, media := range elem.Media { @@ -344,9 +341,9 @@ func PostController(c echo.Context) (err error) { file, err := c.FormFile("file") - entry := &Entry { + entry := &Entry{ Description: desc, - Post: genName(), + Post: genName(), } if date != "" { @@ -360,7 +357,7 @@ func PostController(c echo.Context) (err error) { return } - media := Media { + media := Media{ Type: "GraphImage", File: genName(), } @@ -422,7 +419,7 @@ func main() { e.GET("/list", ListController) e.GET("/view", ViewController) - e.GET("/rss", RSSController) + e.GET("/rss", RSSController) e.GET("/json", JSONController) e.GET("/atom", AtomController) @@ -432,7 +429,7 @@ func main() { admin := e.Group("/admin", middleware.BasicAuth(auth)) admin.GET("/", func(c echo.Context) error { - return c.Render(http.StatusOK, "admin.html", struct { List entryList }{ + return c.Render(http.StatusOK, "admin.html", struct{ List entryList }{ List: list.getSortedEntries(), }) })