aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2018-04-29 12:58:25 -0700
committerAdam Mathes <adam@trenchant.org>2018-04-29 12:58:25 -0700
commit5e9981a5a8f993d6233b9a321a643bd947ce4449 (patch)
treecd036534c77f20bb2ec0ae4d6804dbc92fcf5796
parent09b8f4494bf904b03d3d9f78d9c00004d2f5b992 (diff)
downloadneko-5e9981a5a8f993d6233b9a321a643bd947ce4449.tar.gz
neko-5e9981a5a8f993d6233b9a321a643bd947ce4449.tar.bz2
neko-5e9981a5a8f993d6233b9a321a643bd947ce4449.zip
debug cleanup
-rw-r--r--main.go6
-rw-r--r--models/item/item.go17
-rw-r--r--web/web.go5
3 files changed, 17 insertions, 11 deletions
diff --git a/main.go b/main.go
index 40f2647..d23c4ec 100644
--- a/main.go
+++ b/main.go
@@ -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) {
diff --git a/web/web.go b/web/web.go
index 2151926..21caf22 100644
--- a/web/web.go
+++ b/web/web.go
@@ -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
}