mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-25 05:29:20 +00:00
gofmt
This commit is contained in:
parent
391ce61362
commit
9f376db0f4
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"flag"
|
"flag"
|
||||||
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ func main() {
|
|||||||
for _, res := range []int{1024, 512, 256, 128, 64, 32, 16} {
|
for _, res := range []int{1024, 512, 256, 128, 64, 32, 16} {
|
||||||
outfile := fmt.Sprintf("icon_%dx%d.png", res, res)
|
outfile := fmt.Sprintf("icon_%dx%d.png", res, res)
|
||||||
if res == 1024 || res == 64 {
|
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),
|
"sips", "-s", "format", "png", "--resampleWidth", strconv.Itoa(res),
|
||||||
iconFile, "--out", path.Join(iconsetDir, outfile),
|
iconFile, "--out", path.Join(iconsetDir, outfile),
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ func unsafeMethod(method string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Middleware) Handler(c *router.Context) {
|
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()
|
c.Next()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package crawler
|
package crawler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
const base = "http://example.com"
|
const base = "http://example.com"
|
||||||
|
@ -19,7 +19,7 @@ var GitHash string = "unknown"
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetOutput(os.Stdout)
|
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 addr, db, authfile, certfile, keyfile string
|
||||||
var ver, open bool
|
var ver, open bool
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package opml
|
package opml
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"html"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Folder struct {
|
type Folder struct {
|
||||||
@ -36,7 +36,7 @@ func (f Folder) outline(level int) string {
|
|||||||
prefix := strings.Repeat(indent, level)
|
prefix := strings.Repeat(indent, level)
|
||||||
|
|
||||||
if level > 0 {
|
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 {
|
for _, folder := range f.Folders {
|
||||||
builder.WriteString(folder.outline(level + 1))
|
builder.WriteString(folder.outline(level + 1))
|
||||||
@ -52,7 +52,7 @@ func (f Folder) outline(level int) string {
|
|||||||
|
|
||||||
func (f Feed) outline(level int) string {
|
func (f Feed) outline(level int) string {
|
||||||
return strings.Repeat(indent, level) + fmt.Sprintf(
|
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),
|
e(f.Title), e(f.FeedUrl), e(f.SiteUrl),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -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/",
|
||||||
|
@ -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/",
|
||||||
|
@ -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) {
|
||||||
|
@ -51,7 +51,7 @@ func (r *Router) resolve(path string) *Route {
|
|||||||
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
// autoclose open base url
|
// autoclose open base url
|
||||||
if r.base != "" && r.base == req.URL.Path {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"html"
|
"html"
|
||||||
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var migrations = []func(*sql.Tx)error{
|
var migrations = []func(*sql.Tx) error{
|
||||||
m01_initial,
|
m01_initial,
|
||||||
m02_feed_states_and_errors,
|
m02_feed_states_and_errors,
|
||||||
m03_on_delete_actions,
|
m03_on_delete_actions,
|
||||||
@ -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
|
||||||
@ -56,7 +56,7 @@ func migrate(db *sql.DB) error {
|
|||||||
func migrateVersion(v int64, db *sql.DB) error {
|
func migrateVersion(v int64, db *sql.DB) error {
|
||||||
var err error
|
var err error
|
||||||
var tx *sql.Tx
|
var tx *sql.Tx
|
||||||
migratefunc := migrations[v - 1]
|
migratefunc := migrations[v-1]
|
||||||
if tx, err = db.Begin(); err != nil {
|
if tx, err = db.Begin(); err != nil {
|
||||||
log.Printf("[migration:%d] failed to start transaction", v)
|
log.Printf("[migration:%d] failed to start transaction", v)
|
||||||
return err
|
return err
|
||||||
|
@ -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"
|
||||||
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user