Compare commits

...

4 Commits

Author SHA1 Message Date
henry.chen
8e2679e49f chore(release): 2.2.15 2025-01-01 02:53:10 +08:00
henry.chen
52fe7303f3 fix: disqus list posts 2025-01-01 02:49:21 +08:00
henry.chen
616248d33f fix: disqus thread not store 2025-01-01 02:19:48 +08:00
henry.chen
6e1965a764 chore: replace ioutil -> io 2024-11-04 10:31:28 +08:00
10 changed files with 42 additions and 33 deletions

View File

@@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.2.15](https://github.com/eiblog/eiblog/compare/v2.2.14...v2.2.15) (2024-12-31)
### Bug Fixes
* disqus list posts ([52fe730](https://github.com/eiblog/eiblog/commit/52fe7303f3345421c0f2e2989a6c174d5b1a689e))
* disqus thread not store ([616248d](https://github.com/eiblog/eiblog/commit/616248d33fdf44dbc3aed41e92adae001a4f5577))
### [2.2.14](https://github.com/eiblog/eiblog/compare/v2.2.13...v2.2.14) (2024-10-10) ### [2.2.14](https://github.com/eiblog/eiblog/compare/v2.2.13...v2.2.14) (2024-10-10)

View File

@@ -2,7 +2,6 @@
package config package config
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@@ -147,7 +146,7 @@ func init() {
WorkDir = workDir() WorkDir = workDir()
path := filepath.Join(WorkDir, "conf", "app.yml") path := filepath.Join(WorkDir, "conf", "app.yml")
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@@ -288,14 +288,14 @@ func handleAPIPostCreate(c *gin.Context) {
cid = article.ID cid = article.ID
if !article.IsDraft { if !article.IsDraft {
// disqus
internal.ThreadCreate(article, cache.Ei.Blogger.BTitle)
// 异步执行,快 // 异步执行,快
go func() { go func() {
// elastic // elastic
internal.ElasticAddIndex(article) internal.ElasticAddIndex(article)
// rss // rss
internal.PingFunc(cache.Ei.Blogger.BTitle, slug) internal.PingFunc(cache.Ei.Blogger.BTitle, slug)
// disqus
internal.ThreadCreate(article, cache.Ei.Blogger.BTitle)
}() }()
} }
return return
@@ -327,16 +327,16 @@ func handleAPIPostCreate(c *gin.Context) {
} }
if !article.IsDraft { if !article.IsDraft {
cache.Ei.RepArticle(artc, article) cache.Ei.RepArticle(artc, article)
// disqus
if artc == nil {
internal.ThreadCreate(article, cache.Ei.Blogger.BTitle)
}
// 异步执行,快 // 异步执行,快
go func() { go func() {
// elastic // elastic
internal.ElasticAddIndex(article) internal.ElasticAddIndex(article)
// rss // rss
internal.PingFunc(cache.Ei.Blogger.BTitle, slug) internal.PingFunc(cache.Ei.Blogger.BTitle, slug)
// disqus
if artc == nil {
internal.ThreadCreate(article, cache.Ei.Blogger.BTitle)
}
}() }()
} }
} }

View File

@@ -6,7 +6,7 @@ import (
"context" "context"
"fmt" "fmt"
htemplate "html/template" htemplate "html/template"
"io/ioutil" "io"
"math/rand" "math/rand"
"net/http" "net/http"
"strconv" "strconv"
@@ -370,7 +370,7 @@ func handleBeaconPage(c *gin.Context) {
return return
} }
defer res.Body.Close() defer res.Body.Close()
data, err := ioutil.ReadAll(res.Body) data, err := io.ReadAll(res.Body)
if err != nil { if err != nil {
logrus.Error("HandleBeaconPage.ReadAll: ", err) logrus.Error("HandleBeaconPage.ReadAll: ", err)
return return

View File

@@ -18,7 +18,7 @@ var htmlTmpl *template.Template
func init() { func init() {
htmlTmpl = template.New("eiblog").Funcs(tools.TplFuncMap) htmlTmpl = template.New("eiblog").Funcs(tools.TplFuncMap)
root := filepath.Join(config.WorkDir, "website") root := filepath.Join(config.WorkDir, "website")
files := tools.ReadDirFiles(root, func(fi fs.FileInfo) bool { files := tools.ReadDirFiles(root, func(fi fs.DirEntry) bool {
name := fi.Name() name := fi.Name()
if name == ".DS_Store" { if name == ".DS_Store" {
return true return true

View File

@@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@@ -71,7 +71,7 @@ func PostsCount(articles map[string]*model.Article) error {
} }
defer resp.Body.Close() defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@@ -91,7 +91,9 @@ func PostsCount(articles map[string]*model.Article) error {
if article := articles[slug]; article != nil { if article := articles[slug]; article != nil {
article.Count = v.Posts article.Count = v.Posts
article.Thread = v.ID if article.Thread == "" && v.ID != "" {
article.Thread = v.ID
}
} }
} }
} }
@@ -133,7 +135,7 @@ func PostsList(article *model.Article, cursor string) (*PostsListResp, error) {
vals := url.Values{} vals := url.Values{}
vals.Set("api_key", disqusAPIKey) vals.Set("api_key", disqusAPIKey)
vals.Set("forum", config.Conf.EiBlogApp.Disqus.ShortName) vals.Set("forum", config.Conf.EiBlogApp.Disqus.ShortName)
vals.Set("thread", article.Thread) vals.Set("thread:ident", "post-"+article.Slug)
vals.Set("cursor", cursor) vals.Set("cursor", cursor)
vals.Set("order", "popular") vals.Set("order", "popular")
vals.Set("limit", "50") vals.Set("limit", "50")
@@ -144,7 +146,7 @@ func PostsList(article *model.Article, cursor string) (*PostsListResp, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -198,7 +200,7 @@ func PostCreate(pc *PostComment) (*PostCreateResp, error) {
return nil, err return nil, err
} }
defer resp.Body.Close() defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -240,7 +242,7 @@ func PostApprove(post string) error {
} }
defer resp.Body.Close() defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@@ -282,7 +284,7 @@ func ThreadCreate(article *model.Article, btitle string) error {
return err return err
} }
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@@ -325,7 +327,7 @@ func ThreadDetails(article *model.Article) error {
return err return err
} }
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -6,7 +6,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"regexp" "regexp"
"strings" "strings"
@@ -160,7 +160,7 @@ func createIndexAndMappings(index, typ string, mappings []byte) error {
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@@ -183,7 +183,7 @@ func indexOrUpdateDocument(index, typ string, id int, doc []byte) (err error) {
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@@ -220,7 +220,7 @@ func deleteIndexDocument(index, typ string, ids []string) error {
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@@ -272,7 +272,7 @@ func indexQueryDSL(index, typ string, size, from int, dsl []byte) (*SearchIndexR
return nil, err return nil, err
} }
defer resp.Body.Close() defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -5,7 +5,7 @@ import (
"bytes" "bytes"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
@@ -30,7 +30,7 @@ var feedrPingFunc = func(btitle, slug string) error {
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@@ -88,7 +88,7 @@ var rpcPingFunc = func(btitle, slug string) error {
continue continue
} }
defer resp.Body.Close() defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
logrus.Error("rpcPingFunc.ReadAll: ", err) logrus.Error("rpcPingFunc.ReadAll: ", err)
continue continue

View File

@@ -4,7 +4,7 @@ package tools
import ( import (
"encoding/base64" "encoding/base64"
htmpl "html/template" htmpl "html/template"
"io/ioutil" "io"
"log" "log"
"net/http" "net/http"
"strings" "strings"
@@ -62,7 +62,7 @@ func GetAvatar(domain string) string {
} }
defer resp.Body.Close() defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return "" return ""

View File

@@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"io/ioutil" "os"
"path" "path"
"regexp" "regexp"
"time" "time"
@@ -23,8 +23,8 @@ func EncryptPasswd(name, pass string) string {
} }
// ReadDirFiles 读取目录 // ReadDirFiles 读取目录
func ReadDirFiles(dir string, filter func(fi fs.FileInfo) bool) (files []string) { func ReadDirFiles(dir string, filter func(fi fs.DirEntry) bool) (files []string) {
fileInfos, err := ioutil.ReadDir(dir) fileInfos, err := os.ReadDir(dir)
if err != nil { if err != nil {
return return
} }