mirror of https://github.com/jlelse/GoBlog
Update dependencies
This commit is contained in:
parent
222c792908
commit
957b0f2bfc
18
blogroll.go
18
blogroll.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"sort"
|
||||
|
@ -12,6 +13,7 @@ import (
|
|||
"github.com/carlmjohnson/requests"
|
||||
"github.com/kaorimatz/go-opml"
|
||||
"github.com/thoas/go-funk"
|
||||
"go.goblog.app/app/pkgs/bufferpool"
|
||||
"go.goblog.app/app/pkgs/contenttype"
|
||||
)
|
||||
|
||||
|
@ -50,14 +52,22 @@ func (a *goBlog) serveBlogrollExport(w http.ResponseWriter, r *http.Request) {
|
|||
a.serveError(w, r, "", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set(contentType, contenttype.XMLUTF8)
|
||||
var opmlBuffer bytes.Buffer
|
||||
_ = opml.Render(&opmlBuffer, &opml.OPML{
|
||||
opmlBuf := bufferpool.Get()
|
||||
defer bufferpool.Put(opmlBuf)
|
||||
mw := a.min.Writer(contenttype.XML, opmlBuf)
|
||||
err = opml.Render(mw, &opml.OPML{
|
||||
Version: "2.0",
|
||||
DateCreated: time.Now().UTC(),
|
||||
Outlines: outlines.([]*opml.Outline),
|
||||
})
|
||||
_ = a.min.Minify(contenttype.XML, w, &opmlBuffer)
|
||||
_ = mw.Close()
|
||||
if err != nil {
|
||||
log.Printf("Failed to render OPML: %v", err)
|
||||
a.serveError(w, r, "", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set(contentType, contenttype.XMLUTF8)
|
||||
_, _ = io.Copy(w, opmlBuf)
|
||||
}
|
||||
|
||||
func (a *goBlog) getBlogrollOutlines(blog string) ([]*opml.Outline, error) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"log"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"github.com/tkrajina/gpxgo/gpx"
|
||||
"golang.org/x/text/language"
|
||||
|
@ -101,7 +102,7 @@ func trackParseGPX(gpxString string) (result *trackParseResult, err error) {
|
|||
points []*trackPoint
|
||||
}
|
||||
|
||||
result.gpxData, err = gpx.ParseString(gpxString)
|
||||
result.gpxData, err = gpx.Parse(strings.NewReader(gpxString))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
6
go.mod
6
go.mod
|
@ -26,7 +26,7 @@ require (
|
|||
github.com/google/uuid v1.3.0
|
||||
github.com/gorilla/handlers v1.5.1
|
||||
github.com/gorilla/sessions v1.2.1
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/hacdias/indieauth v1.7.1
|
||||
github.com/jlaffaye/ftp v0.0.0-20220201222555-02685330ee35
|
||||
// master
|
||||
|
@ -49,14 +49,14 @@ require (
|
|||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tdewolff/minify/v2 v2.10.0
|
||||
github.com/thoas/go-funk v0.9.1
|
||||
github.com/tkrajina/gpxgo v1.2.0
|
||||
github.com/tkrajina/gpxgo v1.2.1
|
||||
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80
|
||||
github.com/vcraescu/go-paginator v1.0.1-0.20201114172518-2cfc59fe05c2
|
||||
github.com/yuin/goldmark v1.4.6
|
||||
// master
|
||||
github.com/yuin/goldmark-emoji v1.0.2-0.20210607094911-0487583eca38
|
||||
github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594
|
||||
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||
golang.org/x/text v0.3.7
|
||||
|
|
12
go.sum
12
go.sum
|
@ -229,8 +229,8 @@ github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+
|
|||
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hacdias/indieauth v1.7.1 h1:gIIVrUozSTbTEOpqSYs884y37UWeFnVwX3KVT3sm/94=
|
||||
github.com/hacdias/indieauth v1.7.1/go.mod h1:NHpFIYe4d5vl+hZY+16XsneVmD6usNcZdrSIpP5blqM=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
|
@ -422,8 +422,8 @@ github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
|
|||
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
||||
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
|
||||
github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
|
||||
github.com/tkrajina/gpxgo v1.2.0 h1:WzEMWKmsYZm6Nqvro4FibSA9p8kMph5u7nfaNWLGtqY=
|
||||
github.com/tkrajina/gpxgo v1.2.0/go.mod h1:795sjVRFo5wWyN6oOZp0RYienGGBJjpAlgOz2nCngA0=
|
||||
github.com/tkrajina/gpxgo v1.2.1 h1:MJJtT4Re5btDGg89brFDrUP3EWz+cBmyo8pQwV0ZOak=
|
||||
github.com/tkrajina/gpxgo v1.2.1/go.mod h1:795sjVRFo5wWyN6oOZp0RYienGGBJjpAlgOz2nCngA0=
|
||||
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=
|
||||
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE=
|
||||
github.com/u-root/uio v0.0.0-20210528114334-82958018845c h1:BFvcl34IGnw8yvJi8hlqLFo9EshRInwWBs2M5fGWzQA=
|
||||
|
@ -474,8 +474,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
|||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 h1:XdAboW3BNMv9ocSCOk/u1MFioZGzCNkiJZ19v9Oe3Ig=
|
||||
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package mp3merge
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/dmulholl/mp3lib"
|
||||
"go.goblog.app/app/pkgs/bufferpool"
|
||||
)
|
||||
|
||||
// Inspired by https://github.com/dmulholl/mp3cat/blob/2ec1e4fe4d995ebd41bf1887b3cab8e2a569b3d4/mp3cat.go
|
||||
|
@ -18,7 +18,9 @@ func MergeMP3(out io.Writer, in ...io.Reader) error {
|
|||
var totalFrames, totalBytes uint32
|
||||
var firstBitRate int
|
||||
var isVBR bool
|
||||
var tmpOut bytes.Buffer
|
||||
|
||||
tmpOut := bufferpool.Get()
|
||||
defer bufferpool.Put(tmpOut)
|
||||
|
||||
// Loop over the input files and append their MP3 frames to the output file.
|
||||
for _, inReader := range in {
|
||||
|
|
19
sessions.go
19
sessions.go
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/araddon/dateparse"
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/sessions"
|
||||
"go.goblog.app/app/pkgs/bufferpool"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -133,8 +134,9 @@ func (s *dbSessionStore) load(session *sessions.Session) (err error) {
|
|||
|
||||
func (s *dbSessionStore) insert(session *sessions.Session) (err error) {
|
||||
deleteSessionValuesNotNeededForDb(session)
|
||||
var encoded bytes.Buffer
|
||||
if err := gob.NewEncoder(&encoded).Encode(session.Values); err != nil {
|
||||
encoded := bufferpool.Get()
|
||||
defer bufferpool.Put(encoded)
|
||||
if err := gob.NewEncoder(encoded).Encode(session.Values); err != nil {
|
||||
return err
|
||||
}
|
||||
session.ID = session.Name() + "-" + uuid.NewString()
|
||||
|
@ -156,12 +158,17 @@ func (s *dbSessionStore) save(session *sessions.Session) (err error) {
|
|||
return s.insert(session)
|
||||
}
|
||||
deleteSessionValuesNotNeededForDb(session)
|
||||
var encoded bytes.Buffer
|
||||
if err = gob.NewEncoder(&encoded).Encode(session.Values); err != nil {
|
||||
encoded := bufferpool.Get()
|
||||
defer bufferpool.Put(encoded)
|
||||
if err = gob.NewEncoder(encoded).Encode(session.Values); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = s.db.exec("update sessions set data = @data, modified = @modified where id = @id",
|
||||
sql.Named("data", encoded.Bytes()), sql.Named("modified", utcNowString()), sql.Named("id", session.ID))
|
||||
_, err = s.db.exec(
|
||||
"update sessions set data = @data, modified = @modified where id = @id",
|
||||
sql.Named("data", encoded.Bytes()),
|
||||
sql.Named("modified", utcNowString()),
|
||||
sql.Named("id", session.ID),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
10
telegram.go
10
telegram.go
|
@ -1,13 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"log"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"go.goblog.app/app/pkgs/bufferpool"
|
||||
)
|
||||
|
||||
func (a *goBlog) initTelegram() {
|
||||
|
@ -123,11 +123,12 @@ func (tg *configTelegram) enabled() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (tg *configTelegram) generateHTML(title, fullURL, shortURL string) string {
|
||||
func (tg *configTelegram) generateHTML(title, fullURL, shortURL string) (html string) {
|
||||
if !tg.enabled() {
|
||||
return ""
|
||||
}
|
||||
var message bytes.Buffer
|
||||
message := bufferpool.Get()
|
||||
defer bufferpool.Put(message)
|
||||
if title != "" {
|
||||
message.WriteString(tgbotapi.EscapeText(tgbotapi.ModeHTML, title))
|
||||
message.WriteString("\n\n")
|
||||
|
@ -141,7 +142,8 @@ func (tg *configTelegram) generateHTML(title, fullURL, shortURL string) string {
|
|||
message.WriteString(tgbotapi.EscapeText(tgbotapi.ModeHTML, shortURL))
|
||||
message.WriteString("</a>")
|
||||
}
|
||||
return message.String()
|
||||
html = message.String()
|
||||
return
|
||||
}
|
||||
|
||||
func (a *goBlog) sendTelegram(tg *configTelegram, message, mode string) (int64, int, error) {
|
||||
|
|
Loading…
Reference in New Issue