mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
unescape titles
This commit is contained in:
parent
221cf8519a
commit
cdf7e53be2
@ -1,5 +1,9 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"html"
|
||||
)
|
||||
|
||||
type Feed struct {
|
||||
Id int64 `json:"id"`
|
||||
FolderId *int64 `json:"folder_id"`
|
||||
@ -15,7 +19,7 @@ func (s *Storage) CreateFeed(title, description, link, feedLink, icon string, fo
|
||||
insert into feeds (title, description, link, feed_link, icon, folder_id)
|
||||
values (?, ?, ?, ?, ?, ?)
|
||||
on conflict (feed_link) do update set folder_id=?`,
|
||||
title, description, link, feedLink, icon, folderId,
|
||||
html.UnescapeString(title), description, link, feedLink, icon, folderId,
|
||||
folderId,
|
||||
)
|
||||
if err != nil {
|
||||
|
@ -3,7 +3,8 @@ package storage
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"golang.org/x/net/html"
|
||||
xhtml "golang.org/x/net/html"
|
||||
"html"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -77,7 +78,7 @@ func (s *Storage) CreateItems(items []Item) bool {
|
||||
)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
on conflict (guid) do update set date_updated=?`,
|
||||
item.GUID, item.FeedId, item.Title, item.Link, item.Description,
|
||||
item.GUID, item.FeedId, html.UnescapeString(item.Title), item.Link, item.Description,
|
||||
item.Content, item.Author, item.Date, item.DateUpdated, UNREAD, item.Image,
|
||||
// upsert values
|
||||
item.DateUpdated,
|
||||
@ -259,15 +260,15 @@ func (s *Storage) FeedStats() []FeedStat {
|
||||
}
|
||||
|
||||
func HTMLText(s string) string {
|
||||
tokenizer := html.NewTokenizer(strings.NewReader(s))
|
||||
tokenizer := xhtml.NewTokenizer(strings.NewReader(s))
|
||||
contents := make([]string, 0)
|
||||
for {
|
||||
token := tokenizer.Next()
|
||||
if token == html.ErrorToken {
|
||||
if token == xhtml.ErrorToken {
|
||||
break
|
||||
}
|
||||
if token == html.TextToken {
|
||||
content := strings.TrimSpace(html.UnescapeString(string(tokenizer.Text())))
|
||||
if token == xhtml.TextToken {
|
||||
content := strings.TrimSpace(xhtml.UnescapeString(string(tokenizer.Text())))
|
||||
if len(content) > 0 {
|
||||
contents = append(contents, content)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user