Skip to content

Commit

Permalink
update patch
Browse files Browse the repository at this point in the history
  • Loading branch information
gonejack committed Nov 25, 2024
1 parent 01d3e93 commit 30c2abd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions model/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"net/http"
"net/url"
"path"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -121,6 +122,26 @@ func (it *Item) fullBody() {
video := fmt.Sprintf(tpl, ms[1])
it.Summary.Content = video + it.Summary.Content
}
case strings.HasSuffix(u.Host, "colobu.com"):
doc, err := goquery.NewDocumentFromReader(strings.NewReader(it.Summary.Content))
if err != nil {
return
}
doc.Find("img").Each(func(i int, e *goquery.Selection) {
src, _ := e.Attr("src")
if len(src) > 0 && !strings.HasPrefix(src, it.Link()) {
full, exx := url.JoinPath(it.Link(), path.Base(src))
if exx == nil {
e.SetAttr("src", full)
}
}
})
htm, err := doc.Html()
if err != nil {
log.Printf("cannot generate content of %s", uri)
return
}
it.Summary.Content = htm
}
}
func (it *Item) grabDoc() (doc *goquery.Document, err error) {
Expand Down

0 comments on commit 30c2abd

Please sign in to comment.