aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2018-04-27 15:52:00 -0700
committerAdam Mathes <adam@trenchant.org>2018-04-27 15:52:00 -0700
commit5068ca5c0d88694ec1c25dce81c747d5cfa6b54e (patch)
tree644bfb34b8525dbb7077ea5b2a3f5a1e24512b82 /web
parentb773d3b1fa1ca4e01b100eb5e89b88b8347740ce (diff)
downloadneko-5068ca5c0d88694ec1c25dce81c747d5cfa6b54e.tar.gz
neko-5068ca5c0d88694ec1c25dce81c747d5cfa6b54e.tar.bz2
neko-5068ca5c0d88694ec1c25dce81c747d5cfa6b54e.zip
separator for scrape
Diffstat (limited to 'web')
-rw-r--r--web/web.go49
1 files changed, 41 insertions, 8 deletions
diff --git a/web/web.go b/web/web.go
index 94204be..2151926 100644
--- a/web/web.go
+++ b/web/web.go
@@ -52,7 +52,7 @@ func streamHandler(w http.ResponseWriter, r *http.Request) {
}
var items []*item.Item
- items, err := item.Filter(int64(max_id), feed_id, category, unread_only, starred_only)
+ items, err := item.Filter(int64(max_id), feed_id, category, unread_only, starred_only, 0)
if err != nil {
log.Println(err)
}
@@ -63,12 +63,17 @@ func streamHandler(w http.ResponseWriter, r *http.Request) {
}
func itemHandler(w http.ResponseWriter, r *http.Request) {
- var i item.Item
- err := json.NewDecoder(r.Body).Decode(&i)
- if err != nil {
- log.Println(err)
- } else {
- i.Save()
+ switch r.Method {
+ case "PUT":
+ var i item.Item
+ err := json.NewDecoder(r.Body).Decode(&i)
+ if err != nil {
+ log.Println(err)
+ } else {
+ i.Save()
+ }
+ case "GET":
+ fullTextHandler(w, r)
}
defer r.Body.Close()
}
@@ -181,6 +186,31 @@ func imageProxyHandler(w http.ResponseWriter, r *http.Request) {
return
}
+func fullTextHandler(w http.ResponseWriter, r *http.Request) {
+ fmt.Printf("request: %v\n\n", r)
+
+ fmt.Printf("url string: %s\n\n", r.URL.String())
+
+ itemID, _ := strconv.Atoi(r.URL.String())
+ // fmt.Printf("item id: %v\n\n", itemID)
+
+ if itemID == 0 {
+ fmt.Printf("wah wah wah\n")
+ return
+ }
+
+ i := item.ItemById(int64(itemID))
+ // fmt.Println("item fetched: %v\n\n", i)
+
+ if i.FullContent == "" {
+ i.GetFullContent()
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ js, _ := json.Marshal(i)
+ w.Write(js)
+}
+
var AuthCookie = "auth"
var SecondsInAYear = 60 * 60 * 24 * 365
@@ -236,7 +266,10 @@ func Serve() {
http.Handle("/static/", http.StripPrefix("/static/", fs))
http.HandleFunc("/stream/", AuthWrap(streamHandler))
- http.HandleFunc("/item/", AuthWrap(itemHandler))
+
+ // http.HandleFunc("/item/", AuthWrap(itemHandler))
+ http.Handle("/item/", http.StripPrefix("/item/", AuthWrap(itemHandler)))
+
http.HandleFunc("/feed/", AuthWrap(feedHandler))
http.HandleFunc("/tag/", AuthWrap(categoryHandler))
http.Handle("/image/", http.StripPrefix("/image/", AuthWrap(imageProxyHandler)))