This commit is contained in:
Nazar Kanaev 2021-03-19 00:06:48 +00:00
parent 391ce61362
commit 9f376db0f4
24 changed files with 65 additions and 67 deletions

View File

@ -1,8 +1,8 @@
package main package main
import ( import (
"io/ioutil"
"flag" "flag"
"io/ioutil"
"strings" "strings"
) )

View File

@ -1,8 +1,8 @@
package crawler package crawler
import ( import (
"testing"
"reflect" "reflect"
"testing"
) )
const base = "http://example.com" const base = "http://example.com"

View File

@ -1,9 +1,9 @@
package opml package opml
import ( import (
"strings"
"html"
"fmt" "fmt"
"html"
"strings"
) )
type Folder struct { type Folder struct {

View File

@ -5,27 +5,26 @@ import (
"testing" "testing"
) )
func TestOPML(t *testing.T) { func TestOPML(t *testing.T) {
have := (Folder{ have := (Folder{
Title: "", Title: "",
Feeds: []Feed{ Feeds: []Feed{
Feed{ {
Title: "title1", Title: "title1",
FeedUrl: "https://baz.com/feed.xml", FeedUrl: "https://baz.com/feed.xml",
SiteUrl: "https://baz.com/", SiteUrl: "https://baz.com/",
}, },
}, },
Folders: []Folder{ Folders: []Folder{
Folder{ {
Title: "sub", Title: "sub",
Feeds: []Feed{ Feeds: []Feed{
Feed{ {
Title: "subtitle1", Title: "subtitle1",
FeedUrl: "https://foo.com/feed.xml", FeedUrl: "https://foo.com/feed.xml",
SiteUrl: "https://foo.com/", SiteUrl: "https://foo.com/",
}, },
Feed{ {
Title: "&>", Title: "&>",
FeedUrl: "https://bar.com/feed.xml", FeedUrl: "https://bar.com/feed.xml",
SiteUrl: "https://bar.com/", SiteUrl: "https://bar.com/",

View File

@ -6,7 +6,6 @@ import (
"testing" "testing"
) )
func TestParse(t *testing.T) { func TestParse(t *testing.T) {
have, _ := Parse(strings.NewReader(` have, _ := Parse(strings.NewReader(`
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
@ -27,22 +26,22 @@ func TestParse(t *testing.T) {
want := Folder{ want := Folder{
Title: "", Title: "",
Feeds: []Feed{ Feeds: []Feed{
Feed{ {
Title: "title1", Title: "title1",
FeedUrl: "https://baz.com/feed.xml", FeedUrl: "https://baz.com/feed.xml",
SiteUrl: "https://baz.com/", SiteUrl: "https://baz.com/",
}, },
}, },
Folders: []Folder{ Folders: []Folder{
Folder{ {
Title: "sub", Title: "sub",
Feeds: []Feed{ Feeds: []Feed{
Feed{ {
Title: "subtitle1", Title: "subtitle1",
FeedUrl: "https://foo.com/feed.xml", FeedUrl: "https://foo.com/feed.xml",
SiteUrl: "https://foo.com/", SiteUrl: "https://foo.com/",
}, },
Feed{ {
Title: "&>", Title: "&>",
FeedUrl: "https://bar.com/feed.xml", FeedUrl: "https://bar.com/feed.xml",
SiteUrl: "https://bar.com/", SiteUrl: "https://bar.com/",

View File

@ -3,8 +3,8 @@
package platform package platform
import ( import (
"github.com/nkanaev/yarr/src/systray"
"github.com/nkanaev/yarr/src/server" "github.com/nkanaev/yarr/src/server"
"github.com/nkanaev/yarr/src/systray"
) )
func Start(s *server.Handler) { func Start(s *server.Handler) {

View File

@ -1,8 +1,8 @@
package storage package storage
import ( import (
"log"
"html" "html"
"log"
"net/url" "net/url"
) )

View File

@ -3,11 +3,11 @@ package storage
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
xhtml "golang.org/x/net/html"
"html" "html"
"log" "log"
"strings" "strings"
"time" "time"
xhtml "golang.org/x/net/html"
) )
type ItemStatus int type ItemStatus int

View File

@ -17,7 +17,7 @@ var maxVersion = int64(len(migrations))
func migrate(db *sql.DB) error { func migrate(db *sql.DB) error {
var version int64 var version int64
db.QueryRow("pragma user_version").Scan(&version); db.QueryRow("pragma user_version").Scan(&version)
if version >= maxVersion { if version >= maxVersion {
return nil return nil

View File

@ -5,8 +5,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/mmcdole/gofeed" "github.com/mmcdole/gofeed"
"github.com/nkanaev/yarr/src/storage"
"github.com/nkanaev/yarr/src/crawler" "github.com/nkanaev/yarr/src/crawler"
"github.com/nkanaev/yarr/src/storage"
"io/ioutil" "io/ioutil"
"net" "net"
"net/http" "net/http"

View File

@ -3,8 +3,8 @@ package worker
import ( import (
"github.com/nkanaev/yarr/src/storage" "github.com/nkanaev/yarr/src/storage"
"log" "log"
"sync/atomic"
"runtime" "runtime"
"sync/atomic"
"time" "time"
) )