Replaces <br> tags with spaces
This commit is contained in:
parent
1adaba8322
commit
9d2601e6c9
@ -32,6 +32,7 @@ func main() {
|
|||||||
|
|
||||||
p = bluemonday.NewPolicy()
|
p = bluemonday.NewPolicy()
|
||||||
spaceReg = regexp.MustCompile(`[\s\t\.]+`)
|
spaceReg = regexp.MustCompile(`[\s\t\.]+`)
|
||||||
|
removeHTMLReg = regexp.MustCompile(`<\/?\s*br\s*>`)
|
||||||
re = regexp.MustCompile("^https?://([^/]*)/(.*)$")
|
re = regexp.MustCompile("^https?://([^/]*)/(.*)$")
|
||||||
|
|
||||||
for _, endpoint := range settings.Autostart {
|
for _, endpoint := range settings.Autostart {
|
||||||
|
@ -2,19 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/microcosm-cc/bluemonday"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
var p *bluemonday.Policy
|
|
||||||
var spaceReg *regexp.Regexp
|
|
||||||
var re *regexp.Regexp
|
|
||||||
|
|
||||||
func DoTries(o *RunningInstance, req *http.Request) (*http.Response, error) {
|
func DoTries(o *RunningInstance, req *http.Request) (*http.Response, error) {
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
var err error
|
var err error
|
||||||
|
10
retrieve.go
10
retrieve.go
@ -10,8 +10,15 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"regexp"
|
||||||
|
"github.com/microcosm-cc/bluemonday"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var p *bluemonday.Policy
|
||||||
|
var spaceReg *regexp.Regexp
|
||||||
|
var removeHTMLReg *regexp.Regexp
|
||||||
|
var re *regexp.Regexp
|
||||||
|
|
||||||
type ImageType struct {
|
type ImageType struct {
|
||||||
// Type string `json:"type"`
|
// Type string `json:"type"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
@ -137,7 +144,8 @@ func check_post(uri string) (PostJson, error) {
|
|||||||
return postjson, err
|
return postjson, err
|
||||||
}
|
}
|
||||||
|
|
||||||
postjson.normalized = html.UnescapeString(strings.ToLower(p.Sanitize(postjson.Content)))
|
postjson.normalized = removeHTMLReg.ReplaceAllString(postjson.Content, " ")
|
||||||
|
postjson.normalized = html.UnescapeString(strings.ToLower(p.Sanitize(postjson.normalized)))
|
||||||
postjson.normalized = spaceReg.ReplaceAllString(postjson.normalized, " ")
|
postjson.normalized = spaceReg.ReplaceAllString(postjson.normalized, " ")
|
||||||
|
|
||||||
_, err = pool.Exec(context.Background(), "INSERT INTO posts (id, inreplyto, published, summary, content, normalized, attributedto, posthash, instance) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)", postjson.ID, postjson.InReplyTo, postjson.Published, postjson.Summary, postjson.Content, postjson.normalized, postjson.AttributedTo, postjson.posthash, postjson.instance)
|
_, err = pool.Exec(context.Background(), "INSERT INTO posts (id, inreplyto, published, summary, content, normalized, attributedto, posthash, instance) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)", postjson.ID, postjson.InReplyTo, postjson.Published, postjson.Summary, postjson.Content, postjson.normalized, postjson.AttributedTo, postjson.posthash, postjson.instance)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user