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