diff options
author | Adam Mathes <adam@trenchant.org> | 2018-04-29 12:58:25 -0700 |
---|---|---|
committer | Adam Mathes <adam@trenchant.org> | 2018-04-29 12:58:25 -0700 |
commit | 5e9981a5a8f993d6233b9a321a643bd947ce4449 (patch) | |
tree | cd036534c77f20bb2ec0ae4d6804dbc92fcf5796 | |
parent | 09b8f4494bf904b03d3d9f78d9c00004d2f5b992 (diff) | |
download | neko-5e9981a5a8f993d6233b9a321a643bd947ce4449.tar.gz neko-5e9981a5a8f993d6233b9a321a643bd947ce4449.tar.bz2 neko-5e9981a5a8f993d6233b9a321a643bd947ce4449.zip |
debug cleanup
-rw-r--r-- | main.go | 6 | ||||
-rw-r--r-- | models/item/item.go | 17 | ||||
-rw-r--r-- | web/web.go | 5 |
3 files changed, 17 insertions, 11 deletions
@@ -34,16 +34,20 @@ func main() { vlog.VERBOSE = verbose if update { + vlog.Printf("starting crawl\n") crawler.Crawl() } if serve { - vlog.Printf("starting web server at %s", config.Config.WebServer) + vlog.Printf("starting web server at %s\n", + config.Config.WebServer) web.Serve() } if newFeed != "" { + vlog.Printf("creating new feed\n") feed.NewFeed(newFeed) } if export != "" { + vlog.Printf("feed export\n") exporter.ExportFeeds(export) } } diff --git a/models/item/item.go b/models/item/item.go index 8e14e02..52d3d37 100644 --- a/models/item/item.go +++ b/models/item/item.go @@ -10,7 +10,6 @@ import ( "github.com/advancedlogic/GoOse" "github.com/microcosm-cc/bluemonday" "github.com/russross/blackfriday" - "log" "strings" ) @@ -46,6 +45,7 @@ func (i *Item) Create() error { item(title, url, description, publish_date, feed_id) VALUES(?, ?, ?, ?, ?)`, i.Title, i.Url, i.Description, i.PublishDate, i.FeedId) if err != nil { + vlog.Printf("Error on item.Create\n%v\n%v\n", i, err) return err } @@ -60,7 +60,7 @@ func (i *Item) Save() { SET read_state=?, starred=? WHERE id=?`, i.ReadState, i.Starred, i.Id) if err != nil { - log.Println(err) + vlog.Printf("Error on item.Save\n%v\n%v\n", i, err) } } @@ -69,7 +69,7 @@ func (i *Item) FullSave() { SET title=?, url=?, description=?, feed_id=? WHERE id=?`, i.Title, i.Url, i.Description, i.FeedId, i.Id) if err != nil { - log.Println(err) + vlog.Printf("Error on item.fullSave\n%v\n%v\n", i, err) } } @@ -165,12 +165,12 @@ func Filter(max_id int64, feed_id int64, category string, unread_only bool, star } query = query + "ORDER BY item.id DESC LIMIT 15" - // log.Println(query) - // log.Println(args...) + // vlog.Println(query) + // vlog.Println(args...) rows, err := models.DB.Query(query, args...) if err != nil { - log.Println(err) + vlog.Println(err) return nil, err } defer rows.Close() @@ -183,7 +183,7 @@ func Filter(max_id int64, feed_id int64, category string, unread_only bool, star var feed_id int64 err := rows.Scan(&i.Id, &feed_id, &i.Title, &i.Url, &i.Description, &i.ReadState, &i.Starred, &i.PublishDate, &i.FullContent, &i.HeaderImage, &i.FeedUrl, &i.FeedTitle, &i.FeedCategory) if err != nil { - log.Println(err) + vlog.Println(err) return nil, err } @@ -220,7 +220,8 @@ func (i *Item) CleanHeaderImage() { func rewriteImages(s string) string { doc, err := goquery.NewDocumentFromReader(strings.NewReader(s)) if err != nil { - panic("can not parse doc to rewrite") + vlog.Println(err) + return s } doc.Find("img").Each(func(i int, img *goquery.Selection) { @@ -161,7 +161,8 @@ func imageProxyHandler(w http.ResponseWriter, r *http.Request) { request, err := http.NewRequest("GET", string(decodedURL), nil) if err != nil { - log.Fatalln(err) + http.Error(w, "failed to proxy image", 404) + return } userAgent := "neko RSS Reader Image Proxy +https://github.com/adammathes/neko" @@ -169,7 +170,7 @@ func imageProxyHandler(w http.ResponseWriter, r *http.Request) { resp, err := c.Do(request) if err != nil { - http.Error(w, "filed to proxy image", 404) + http.Error(w, "failed to proxy image", 404) return } |