From ee5bf1d50b9165729d0c61f7d1f968949e3e0638 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Wed, 4 Jul 2018 14:58:43 -0700 Subject: enable feed export from web interface --- web/rice-box.go | 8 ++++---- web/web.go | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'web') diff --git a/web/rice-box.go b/web/rice-box.go index bb8b8b5..7a52f0e 100644 --- a/web/rice-box.go +++ b/web/rice-box.go @@ -60,8 +60,8 @@ func init() { } filec := &embedded.EmbeddedFile{ Filename: "ui.html", - FileModTime: time.Unix(1529169644, 0), - Content: string("\n\n \n neko rss mode\n \n \n \n \n \n \n \n \n \n \n \n

🐱

\n\n
\n\n
\n

Tags

\n \n \n

Feeds

\n \n
\n\n \n\n
\n
\n
\n
\n \n \n\n \n\n \n\n \n \n\n \n"), + FileModTime: time.Unix(1530741472, 0), + Content: string("\n\n \n neko rss mode\n \n \n \n \n \n \n \n \n \n \n \n

🐱

\n\n
\n\n
\n

Tags

\n \n \n

Feeds

\n \n\n

Export

\n \n\n
\n \n \n\n
\n
\n
\n
\n \n \n\n \n\n \n\n \n \n\n \n"), } filed := &embedded.EmbeddedFile{ Filename: "ui.js", @@ -82,7 +82,7 @@ func init() { // define dirs dir1 := &embedded.EmbeddedDir{ Filename: "", - DirModTime: time.Unix(1529169644, 0), + DirModTime: time.Unix(1530741472, 0), ChildFiles: []*embedded.EmbeddedFile{ file2, // ".DS_Store" file3, // "backbone-1.3.3.min.js" @@ -108,7 +108,7 @@ func init() { // register embeddedBox embedded.RegisterEmbeddedBox(`../static`, &embedded.EmbeddedBox{ Name: `../static`, - Time: time.Unix(1529169644, 0), + Time: time.Unix(1530741472, 0), Dirs: map[string]*embedded.EmbeddedDir{ "": dir1, }, diff --git a/web/web.go b/web/web.go index 8b3b19d..f7fec31 100644 --- a/web/web.go +++ b/web/web.go @@ -3,6 +3,7 @@ package web import ( "adammathes.com/neko/config" "adammathes.com/neko/crawler" + "adammathes.com/neko/exporter" "adammathes.com/neko/models/feed" "adammathes.com/neko/models/item" "encoding/base64" @@ -193,6 +194,13 @@ func imageProxyHandler(w http.ResponseWriter, r *http.Request) { return } +func exportHandler(w http.ResponseWriter, r *http.Request) { + format := r.URL.String() + w.Header().Set("content-type", "text/plain") + w.Write([]byte(exporter.ExportFeeds(format))) + return +} + func fullTextHandler(w http.ResponseWriter, r *http.Request) { fmt.Printf("request: %v\n\n", r) @@ -289,6 +297,7 @@ func Serve() { http.HandleFunc("/feed/", AuthWrap(feedHandler)) http.HandleFunc("/tag/", AuthWrap(categoryHandler)) http.Handle("/image/", http.StripPrefix("/image/", AuthWrap(imageProxyHandler))) + http.Handle("/export/", http.StripPrefix("/export/", AuthWrap(exportHandler))) http.HandleFunc("/login/", loginHandler) http.HandleFunc("/logout/", logoutHandler) -- cgit v1.2.3