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
import (
"io/ioutil"
"flag"
"io/ioutil"
"strings"
)

View File

@ -85,9 +85,9 @@ func main() {
for _, res := range []int{1024, 512, 256, 128, 64, 32, 16} {
outfile := fmt.Sprintf("icon_%dx%d.png", res, res)
if res == 1024 || res == 64 {
outfile = fmt.Sprintf("icon_%dx%d@2x.png", res / 2, res / 2)
outfile = fmt.Sprintf("icon_%dx%d@2x.png", res/2, res/2)
}
cmd := []string {
cmd := []string{
"sips", "-s", "format", "png", "--resampleWidth", strconv.Itoa(res),
iconFile, "--out", path.Join(iconsetDir, outfile),
}

View File

@ -20,7 +20,7 @@ func unsafeMethod(method string) bool {
}
func (m *Middleware) Handler(c *router.Context) {
if strings.HasPrefix(c.Req.URL.Path, m.BasePath + m.Public) {
if strings.HasPrefix(c.Req.URL.Path, m.BasePath+m.Public) {
c.Next()
return
}

View File

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

View File

@ -19,7 +19,7 @@ var GitHash string = "unknown"
func main() {
log.SetOutput(os.Stdout)
log.SetFlags(log.Ldate|log.Ltime|log.Lshortfile)
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
var addr, db, authfile, certfile, keyfile string
var ver, open bool

View File

@ -1,9 +1,9 @@
package opml
import (
"strings"
"html"
"fmt"
"html"
"strings"
)
type Folder struct {
@ -36,7 +36,7 @@ func (f Folder) outline(level int) string {
prefix := strings.Repeat(indent, level)
if level > 0 {
builder.WriteString(prefix + fmt.Sprintf(`<outline text="%s">` + nl, e(f.Title)))
builder.WriteString(prefix + fmt.Sprintf(`<outline text="%s">`+nl, e(f.Title)))
}
for _, folder := range f.Folders {
builder.WriteString(folder.outline(level + 1))
@ -52,7 +52,7 @@ func (f Folder) outline(level int) string {
func (f Feed) outline(level int) string {
return strings.Repeat(indent, level) + fmt.Sprintf(
`<outline type="rss" text="%s" xmlUrl="%s" htmlUrl="%s"/>` + nl,
`<outline type="rss" text="%s" xmlUrl="%s" htmlUrl="%s"/>`+nl,
e(f.Title), e(f.FeedUrl), e(f.SiteUrl),
)
}

View File

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

View File

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

View File

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

View File

@ -51,7 +51,7 @@ func (r *Router) resolve(path string) *Route {
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// autoclose open base url
if r.base != "" && r.base == req.URL.Path {
http.Redirect(rw, req, r.base + "/", http.StatusFound)
http.Redirect(rw, req, r.base+"/", http.StatusFound)
return
}

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import (
"log"
)
var migrations = []func(*sql.Tx)error{
var migrations = []func(*sql.Tx) error{
m01_initial,
m02_feed_states_and_errors,
m03_on_delete_actions,
@ -17,7 +17,7 @@ var maxVersion = int64(len(migrations))
func migrate(db *sql.DB) error {
var version int64
db.QueryRow("pragma user_version").Scan(&version);
db.QueryRow("pragma user_version").Scan(&version)
if version >= maxVersion {
return nil
@ -56,7 +56,7 @@ func migrate(db *sql.DB) error {
func migrateVersion(v int64, db *sql.DB) error {
var err error
var tx *sql.Tx
migratefunc := migrations[v - 1]
migratefunc := migrations[v-1]
if tx, err = db.Begin(); err != nil {
log.Printf("[migration:%d] failed to start transaction", v)
return err

View File

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

View File

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