mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-16 03:10:13 +00:00
Compare commits
7 Commits
v2.4
...
7ecbbff18a
Author | SHA1 | Date | |
---|---|---|---|
|
7ecbbff18a | ||
|
850ce195a0 | ||
|
479aebd023 | ||
|
9b178d1fb3 | ||
|
3ab098db5c | ||
|
6d16e93008 | ||
|
98934daee4 |
@@ -1,5 +1,11 @@
|
|||||||
# upcoming
|
# upcoming
|
||||||
|
|
||||||
|
- (fix) duplicate articles caused by the same feed addition (thanks to @adaszko)
|
||||||
|
- (fix) relative article links (thanks to @adazsko for the report)
|
||||||
|
- (fix) atom article links stored in id element (thanks to @adazsko for the report)
|
||||||
|
|
||||||
|
# v2.4 (2023-08-15)
|
||||||
|
|
||||||
- (new) ARM build support (thanks to @tillcash & @fenuks)
|
- (new) ARM build support (thanks to @tillcash & @fenuks)
|
||||||
- (new) auth configuration via param or env variable (thanks to @pierreprinetti)
|
- (new) auth configuration via param or env variable (thanks to @pierreprinetti)
|
||||||
- (new) web app manifest for an app-like experience on mobile (thanks to @qbit)
|
- (new) web app manifest for an app-like experience on mobile (thanks to @qbit)
|
||||||
|
BIN
etc/promo.png
BIN
etc/promo.png
Binary file not shown.
Before Width: | Height: | Size: 223 KiB After Width: | Height: | Size: 173 KiB |
@@ -3,13 +3,13 @@
|
|||||||
**yarr** (yet another rss reader) is a web-based feed aggregator which can be used both
|
**yarr** (yet another rss reader) is a web-based feed aggregator which can be used both
|
||||||
as a desktop application and a personal self-hosted server.
|
as a desktop application and a personal self-hosted server.
|
||||||
|
|
||||||
It is written in Go with the frontend in Vue.js. The storage is backed by SQLite.
|
The app is a single binary with an embedded database (SQLite).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## usage
|
## usage
|
||||||
|
|
||||||
The latest prebuilt binaries for Linux/MacOS/Windows are available
|
The latest prebuilt binaries for Linux/MacOS/Windows AMD64 are available
|
||||||
[here](https://github.com/nkanaev/yarr/releases/latest).
|
[here](https://github.com/nkanaev/yarr/releases/latest).
|
||||||
|
|
||||||
### macos
|
### macos
|
||||||
|
@@ -2,6 +2,7 @@ package htmlutil
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Any(els []string, el string, match func(string, string) bool) bool {
|
func Any(els []string, el string, match func(string, string) bool) bool {
|
||||||
@@ -31,3 +32,7 @@ func URLDomain(val string) string {
|
|||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsAPossibleLink(val string) bool {
|
||||||
|
return strings.HasPrefix(val, "http://") || strings.HasPrefix(val, "https://")
|
||||||
|
}
|
||||||
|
@@ -81,9 +81,16 @@ func ParseAtom(r io.Reader) (*Feed, error) {
|
|||||||
SiteURL: firstNonEmpty(srcfeed.Links.First("alternate"), srcfeed.Links.First("")),
|
SiteURL: firstNonEmpty(srcfeed.Links.First("alternate"), srcfeed.Links.First("")),
|
||||||
}
|
}
|
||||||
for _, srcitem := range srcfeed.Entries {
|
for _, srcitem := range srcfeed.Entries {
|
||||||
link := firstNonEmpty(srcitem.OrigLink, srcitem.Links.First("alternate"), srcitem.Links.First(""))
|
linkFromID := ""
|
||||||
|
guidFromID := ""
|
||||||
|
if htmlutil.IsAPossibleLink(srcitem.ID) {
|
||||||
|
linkFromID = srcitem.ID
|
||||||
|
guidFromID = srcitem.ID + "::" + srcitem.Updated
|
||||||
|
}
|
||||||
|
|
||||||
|
link := firstNonEmpty(srcitem.OrigLink, srcitem.Links.First("alternate"), srcitem.Links.First(""), linkFromID)
|
||||||
dstfeed.Items = append(dstfeed.Items, Item{
|
dstfeed.Items = append(dstfeed.Items, Item{
|
||||||
GUID: firstNonEmpty(srcitem.ID, link),
|
GUID: firstNonEmpty(guidFromID, srcitem.ID, link),
|
||||||
Date: dateParse(firstNonEmpty(srcitem.Published, srcitem.Updated)),
|
Date: dateParse(firstNonEmpty(srcitem.Published, srcitem.Updated)),
|
||||||
URL: link,
|
URL: link,
|
||||||
Title: srcitem.Title.Text(),
|
Title: srcitem.Title.Text(),
|
||||||
|
@@ -131,3 +131,48 @@ func TestAtomImageLinkDuplicated(t *testing.T) {
|
|||||||
t.Fatal("item.image_url must be unset if present in the content")
|
t.Fatal("item.image_url must be unset if present in the content")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAtomLinkInID(t *testing.T) {
|
||||||
|
feed, _ := Parse(strings.NewReader(`
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
|
||||||
|
<entry>
|
||||||
|
<title>one updated</title>
|
||||||
|
<id>https://example.com/posts/1</id>
|
||||||
|
<updated>2003-12-13T09:17:51</updated>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>two</title>
|
||||||
|
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>one</title>
|
||||||
|
<id>https://example.com/posts/1</id>
|
||||||
|
</entry>
|
||||||
|
</feed>
|
||||||
|
`))
|
||||||
|
have := feed.Items
|
||||||
|
want := []Item{
|
||||||
|
Item{
|
||||||
|
GUID: "https://example.com/posts/1::2003-12-13T09:17:51",
|
||||||
|
Date: time.Date(2003, time.December, 13, 9, 17, 51, 0, time.UTC),
|
||||||
|
URL: "https://example.com/posts/1",
|
||||||
|
Title: "one updated",
|
||||||
|
},
|
||||||
|
Item{
|
||||||
|
GUID: "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6",
|
||||||
|
Date: time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), URL: "",
|
||||||
|
Title: "two",
|
||||||
|
},
|
||||||
|
Item{
|
||||||
|
GUID: "https://example.com/posts/1::",
|
||||||
|
Date: time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC),
|
||||||
|
URL: "https://example.com/posts/1",
|
||||||
|
Title: "one",
|
||||||
|
Content: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(want, have) {
|
||||||
|
t.Fatalf("\nwant: %#v\nhave: %#v\n", want, have)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nkanaev/yarr/src/assets"
|
"github.com/nkanaev/yarr/src/assets"
|
||||||
|
"github.com/nkanaev/yarr/src/content/htmlutil"
|
||||||
"github.com/nkanaev/yarr/src/content/readability"
|
"github.com/nkanaev/yarr/src/content/readability"
|
||||||
"github.com/nkanaev/yarr/src/content/sanitizer"
|
"github.com/nkanaev/yarr/src/content/sanitizer"
|
||||||
"github.com/nkanaev/yarr/src/content/silo"
|
"github.com/nkanaev/yarr/src/content/silo"
|
||||||
@@ -312,6 +313,14 @@ func (s *Server) handleItem(c *router.Context) {
|
|||||||
c.Out.WriteHeader(http.StatusBadRequest)
|
c.Out.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runtime fix for relative links
|
||||||
|
if !htmlutil.IsAPossibleLink(item.Link) {
|
||||||
|
if feed := s.db.GetFeed(item.FeedId); feed != nil {
|
||||||
|
item.Link = htmlutil.AbsoluteUrl(item.Link, feed.Link)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
item.Content = sanitizer.Sanitize(item.Link, item.Content)
|
item.Content = sanitizer.Sanitize(item.Link, item.Content)
|
||||||
|
|
||||||
c.JSON(http.StatusOK, item)
|
c.JSON(http.StatusOK, item)
|
||||||
|
@@ -20,18 +20,19 @@ func (s *Storage) CreateFeed(title, description, link, feedLink string, folderId
|
|||||||
if title == "" {
|
if title == "" {
|
||||||
title = feedLink
|
title = feedLink
|
||||||
}
|
}
|
||||||
result, err := s.db.Exec(`
|
row := s.db.QueryRow(`
|
||||||
insert into feeds (title, description, link, feed_link, folder_id)
|
insert into feeds (title, description, link, feed_link, folder_id)
|
||||||
values (?, ?, ?, ?, ?)
|
values (?, ?, ?, ?, ?)
|
||||||
on conflict (feed_link) do update set folder_id=?`,
|
on conflict (feed_link) do update set folder_id = ?
|
||||||
|
returning id`,
|
||||||
title, description, link, feedLink, folderId,
|
title, description, link, feedLink, folderId,
|
||||||
folderId,
|
folderId,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var id int64
|
||||||
|
err := row.Scan(&id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
log.Print(err)
|
||||||
}
|
|
||||||
id, idErr := result.LastInsertId()
|
|
||||||
if idErr != nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &Feed{
|
return &Feed{
|
||||||
|
@@ -17,6 +17,23 @@ func TestCreateFeed(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateFeedSameLink(t *testing.T) {
|
||||||
|
db := testDB()
|
||||||
|
feed1 := db.CreateFeed("title", "", "", "http://example1.com/feed.xml", nil)
|
||||||
|
if feed1 == nil || feed1.Id == 0 {
|
||||||
|
t.Fatal("expected feed")
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
db.CreateFeed("title", "", "", "http://example2.com/feed.xml", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
feed2 := db.CreateFeed("title", "", "http://example.com", "http://example1.com/feed.xml", nil)
|
||||||
|
if feed1.Id != feed2.Id {
|
||||||
|
t.Fatalf("expected the same feed.\nwant: %#v\nhave: %#v", feed1, feed2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestReadFeed(t *testing.T) {
|
func TestReadFeed(t *testing.T) {
|
||||||
db := testDB()
|
db := testDB()
|
||||||
if db.GetFeed(100500) != nil {
|
if db.GetFeed(100500) != nil {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,35 +12,21 @@ type Folder struct {
|
|||||||
|
|
||||||
func (s *Storage) CreateFolder(title string) *Folder {
|
func (s *Storage) CreateFolder(title string) *Folder {
|
||||||
expanded := true
|
expanded := true
|
||||||
result, err := s.db.Exec(`
|
row := s.db.QueryRow(`
|
||||||
insert into folders (title, is_expanded) values (?, ?)
|
insert into folders (title, is_expanded) values (?, ?)
|
||||||
on conflict (title) do nothing`,
|
on conflict (title) do update set title = ?
|
||||||
|
returning id`,
|
||||||
title, expanded,
|
title, expanded,
|
||||||
|
// provide title again so that we can extract row id
|
||||||
|
title,
|
||||||
)
|
)
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var id int64
|
var id int64
|
||||||
numrows, err := result.RowsAffected()
|
err := row.Scan(&id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if numrows == 1 {
|
|
||||||
id, err = result.LastInsertId()
|
|
||||||
if err != nil {
|
|
||||||
log.Print(err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err = s.db.QueryRow(`select id, is_expanded from folders where title=?`, title).Scan(&id, &expanded)
|
|
||||||
if err != nil {
|
|
||||||
log.Print(err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return &Folder{Id: id, Title: title, IsExpanded: expanded}
|
return &Folder{Id: id, Title: title, IsExpanded: expanded}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user