Clean and finalize with a link for v0.1
parent
78e38f84d1
commit
a3b9ef5ce5
|
|
@ -1,8 +1,10 @@
|
|||
*.key
|
||||
rssmon2
|
||||
db
|
||||
vendor
|
||||
*.crt
|
||||
2do
|
||||
2add
|
||||
*.pem
|
||||
*.swp
|
||||
*.swo
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"local3/rssmon2/rss"
|
||||
"local3/rssmon2/server"
|
||||
"local3/rssmon2/store"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -139,6 +140,9 @@ func (ex *Exchange) GetFeedTagRSS(tag string) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sort.Slice(combinedItems, func(i, j int) bool {
|
||||
return !combinedItems[i].TS.Before(combinedItems[j].TS)
|
||||
})
|
||||
return rss.ToRSS(combinedFeed, combinedItems)
|
||||
}
|
||||
|
||||
|
|
@ -186,6 +190,7 @@ func (ex *Exchange) UpdateFeed(url string) {
|
|||
logger.Logf("can't save rss item %q.%q: %v", feed.ID(), items[i].ID(), err)
|
||||
return
|
||||
}
|
||||
logger.Log("Saved feed item", feed.ID(), items[i].ID(), items[i])
|
||||
//logger.Log("Saved feed item", feed.ID(), items[i].ID(), items[i])
|
||||
}
|
||||
logger.Logf("Saved %d feed items for %s", len(items), feed.Title)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ func (monitor *Monitor) loop() error {
|
|||
if !ok {
|
||||
logger.Fatal("queue contains illegal item")
|
||||
}
|
||||
monitor.trigger(item.URL)
|
||||
go monitor.trigger(item.URL)
|
||||
item.increment()
|
||||
queue.Put(item)
|
||||
if nextEvent, err = nextEventTime(queue); err != nil {
|
||||
|
|
|
|||
12
rss/item.go
12
rss/item.go
|
|
@ -7,6 +7,7 @@ import (
|
|||
"html"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -22,10 +23,10 @@ type Item struct {
|
|||
}
|
||||
|
||||
func (item *Item) String() string {
|
||||
return fmt.Sprintf("Name %v, Link %v, Content %q, TS %v",
|
||||
return fmt.Sprintf("Name %v, Link %v, Content %v, TS %v",
|
||||
item.Name,
|
||||
item.Link,
|
||||
item.Content,
|
||||
len(item.Content),
|
||||
item.TS.Local(),
|
||||
)
|
||||
}
|
||||
|
|
@ -57,15 +58,22 @@ func fromGofeedItem(gfitem *gofeed.Item, filter string) *Item {
|
|||
TS: *gofeedItemTS(gfitem),
|
||||
}
|
||||
content := gfitem.Content
|
||||
if content == "" {
|
||||
content = gfitem.Description
|
||||
}
|
||||
if content == "" {
|
||||
content = contentFromLink(item.Link)
|
||||
}
|
||||
if unescaped, err := url.QueryUnescape(content); err == nil {
|
||||
content = unescaped
|
||||
}
|
||||
if filter != "" {
|
||||
r := regexp.MustCompile(filter)
|
||||
matches := r.FindAllString(content, -1)
|
||||
content = strings.Join(matches, "<br>")
|
||||
}
|
||||
content = cleanImgTags(content)
|
||||
content = "<a href=\"" + gfitem.Link + "\">" + item.Name + "</a><br>" + content
|
||||
item.Content = content
|
||||
return item
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue