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