Arreglado fallo añadiendo imágenes
Las imágenes añadidas no aparecían sin reiniciar el servidor.
This commit is contained in:
parent
4233703c50
commit
6fd66dbe26
43
main.go
43
main.go
|
@ -1,12 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha512"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"crypto/sha512"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -15,13 +17,11 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"encoding/hex"
|
|
||||||
"mime"
|
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/gorilla/feeds"
|
||||||
"github.com/labstack/echo"
|
"github.com/labstack/echo"
|
||||||
"github.com/labstack/echo/middleware"
|
"github.com/labstack/echo/middleware"
|
||||||
"github.com/gorilla/feeds"
|
|
||||||
"github.com/google/uuid"
|
|
||||||
//"github.com/labstack/echo/middleware"
|
//"github.com/labstack/echo/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry struct {
|
Entry struct {
|
||||||
Date JSTime `json:"date"`
|
Date JSTime `json:"date"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Post string `json:"post"`
|
Post string `json:"post"`
|
||||||
Likes int `json:"likes"`
|
Likes int `json:"likes"`
|
||||||
|
@ -146,9 +146,6 @@ func (list *entryMap) write() (err error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = ioutil.WriteFile(list.filename, data, 0644)
|
err = ioutil.WriteFile(list.filename, data, 0644)
|
||||||
}
|
}
|
||||||
if err == nil {
|
|
||||||
list.modtime = time.Now()
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +159,7 @@ func (list *entryMap) read() (err error) {
|
||||||
|
|
||||||
// sort list
|
// sort list
|
||||||
list.sorted = make([]*Entry, 0, len(list.mapped))
|
list.sorted = make([]*Entry, 0, len(list.mapped))
|
||||||
for _, entry:= range list.mapped {
|
for _, entry := range list.mapped {
|
||||||
list.sorted = append(list.sorted, entry)
|
list.sorted = append(list.sorted, entry)
|
||||||
}
|
}
|
||||||
sort.Sort(entryList(list.sorted))
|
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) {
|
func (list *entryMap) getFeed() (feed *feeds.Feed) {
|
||||||
feed = &feeds.Feed {
|
feed = &feeds.Feed{
|
||||||
Title: "danoloan.es igar",
|
Title: "danoloan.es igar",
|
||||||
Link: &feeds.Link { Href: "https://danoloan.es/igar/" },
|
Link: &feeds.Link{Href: "https://danoloan.es/igar/"},
|
||||||
Description: "bitácora fotográfica de danoloan",
|
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())
|
feed.Items = make([]*feeds.Item, 0, list.Len())
|
||||||
for _, elem := range list.getSortedEntries() {
|
for _, elem := range list.getSortedEntries() {
|
||||||
item := &feeds.Item {
|
item := &feeds.Item{
|
||||||
Title: elem.Description,
|
Title: elem.Description,
|
||||||
Link: &feeds.Link{ Href: fmt.Sprintf("https://danoloan.es/igar/view?uuid=%s", elem.Post) },
|
Link: &feeds.Link{Href: fmt.Sprintf("https://danoloan.es/igar/view?uuid=%s", elem.Post)},
|
||||||
Description: fmt.Sprintf("<p>%s</p>\n<div>\n", elem.Description),
|
Description: fmt.Sprintf("<p>%s</p>\n<div>\n", elem.Description),
|
||||||
Created: time.Time(elem.Date),
|
Created: time.Time(elem.Date),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, media := range elem.Media {
|
for _, media := range elem.Media {
|
||||||
|
@ -344,9 +341,9 @@ func PostController(c echo.Context) (err error) {
|
||||||
|
|
||||||
file, err := c.FormFile("file")
|
file, err := c.FormFile("file")
|
||||||
|
|
||||||
entry := &Entry {
|
entry := &Entry{
|
||||||
Description: desc,
|
Description: desc,
|
||||||
Post: genName(),
|
Post: genName(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if date != "" {
|
if date != "" {
|
||||||
|
@ -360,7 +357,7 @@ func PostController(c echo.Context) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
media := Media {
|
media := Media{
|
||||||
Type: "GraphImage",
|
Type: "GraphImage",
|
||||||
File: genName(),
|
File: genName(),
|
||||||
}
|
}
|
||||||
|
@ -422,7 +419,7 @@ func main() {
|
||||||
e.GET("/list", ListController)
|
e.GET("/list", ListController)
|
||||||
e.GET("/view", ViewController)
|
e.GET("/view", ViewController)
|
||||||
|
|
||||||
e.GET("/rss", RSSController)
|
e.GET("/rss", RSSController)
|
||||||
e.GET("/json", JSONController)
|
e.GET("/json", JSONController)
|
||||||
e.GET("/atom", AtomController)
|
e.GET("/atom", AtomController)
|
||||||
|
|
||||||
|
@ -432,7 +429,7 @@ func main() {
|
||||||
admin := e.Group("/admin", middleware.BasicAuth(auth))
|
admin := e.Group("/admin", middleware.BasicAuth(auth))
|
||||||
|
|
||||||
admin.GET("/", func(c echo.Context) error {
|
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(),
|
List: list.getSortedEntries(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue