mirror of
https://github.com/eiblog/eiblog.git
synced 2026-03-01 00:34:58 +08:00
update
This commit is contained in:
@@ -355,7 +355,7 @@ var reg = regexp.MustCompile(setting.Conf.Identifier)
|
|||||||
func GenerateExcerptAndRender(artc *Article) {
|
func GenerateExcerptAndRender(artc *Article) {
|
||||||
index := reg.FindStringIndex(artc.Content)
|
index := reg.FindStringIndex(artc.Content)
|
||||||
if len(index) > 0 {
|
if len(index) > 0 {
|
||||||
artc.Excerpt = artc.Content[0:index[0]]
|
artc.Excerpt = IgnoreHtmlTag(artc.Content[0:index[0]])
|
||||||
} else {
|
} else {
|
||||||
uc := []rune(artc.Content)
|
uc := []rune(artc.Content)
|
||||||
length := setting.Conf.Length
|
length := setting.Conf.Length
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ func ElasticsearchSimple(q string, size, from int) *ESSearchResult {
|
|||||||
func ElasticIndex(artc *Article) error {
|
func ElasticIndex(artc *Article) error {
|
||||||
mapping := map[string]interface{}{
|
mapping := map[string]interface{}{
|
||||||
"title": artc.Title,
|
"title": artc.Title,
|
||||||
"content": artc.Content,
|
"content": IgnoreHtmlTag(artc.Content),
|
||||||
"slug": artc.Slug,
|
"slug": artc.Slug,
|
||||||
"tags": artc.Tags,
|
"tags": artc.Tags,
|
||||||
"create_time": artc.CreateTime,
|
"create_time": artc.CreateTime,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -24,3 +25,13 @@ func EncryptPasswd(name, pass string) string {
|
|||||||
func VerifyPasswd(origin, name, input string) bool {
|
func VerifyPasswd(origin, name, input string) bool {
|
||||||
return origin == EncryptPasswd(name, input)
|
return origin == EncryptPasswd(name, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IgnoreHtmlTag(src string) string {
|
||||||
|
//去除所有尖括号内的HTML代码
|
||||||
|
re, _ := regexp.Compile("\\<[\\S\\s]+?\\>")
|
||||||
|
src = re.ReplaceAllString(src, "")
|
||||||
|
|
||||||
|
//去除换行符
|
||||||
|
re, _ = regexp.Compile("\\s{1,}")
|
||||||
|
return re.ReplaceAllString(src, "")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user