7 Commits
v1.2 ... v1.3

Author SHA1 Message Date
Nazar Kanaev
0916f1179e v1.3 2021-02-18 10:28:55 +00:00
Nazar Kanaev
6a5be593df credits 2021-02-12 10:59:13 +00:00
Nazar Kanaev
7fd1ef80c5 update changelog 2021-02-12 10:56:43 +00:00
Nazar Kanaev
26313f7842 add login.html to bundle 2021-02-12 10:53:08 +00:00
Nazar Kanaev
ce1914419a fix: import not working if auth enabled 2021-02-12 10:46:14 +00:00
Nazar Kanaev
6a828532cb logout 2021-02-12 10:31:00 +00:00
Nazar Kanaev
e8a002d535 update changelog 2021-02-11 21:24:37 +00:00
7 changed files with 45 additions and 8 deletions

View File

@@ -1,11 +1,17 @@
"use strict";
(function() {
var xfetch = function(resource, init) {
init = init || {}
if (['post', 'put', 'delete'].indexOf(init.method) !== -1) {
init['headers'] = init['headers'] || {}
init['headers']['x-requested-by'] = 'yarr'
}
return fetch(resource, init)
}
var api = function(method, endpoint, data) {
var headers = {'Content-Type': 'application/json'}
if (['post', 'put', 'delete'].indexOf(method) !== -1)
headers['x-requested-by'] = 'yarr'
return fetch(endpoint, {
return xfetch(endpoint, {
method: method,
headers: headers,
body: JSON.stringify(data),
@@ -87,13 +93,16 @@
return api('get', './api/status').then(json)
},
upload_opml: function(form) {
return fetch('./opml/import', {
return xfetch('./opml/import', {
method: 'post',
body: new FormData(form),
})
},
logout: function() {
return api('post', './logout')
},
crawl: function(url) {
return fetch('./page?url=' + url).then(function(res) {
return xfetch('./page?url=' + url).then(function(res) {
return res.text()
})
}

View File

@@ -509,6 +509,11 @@ var vm = new Vue({
vm.refreshStats()
})
},
logout: function() {
api.logout().then(function() {
document.location.reload()
})
},
getReadable: function(item) {
if (this.itemSelectedReadability) {
this.itemSelectedReadability = null

View File

@@ -1,4 +1,10 @@
# upcoming
# v1.3 (2021-02-18)
- (fix) log out functionality if authentication is set
- (fix) import opml if authentication is set
- (fix) login page if authentication is set (thanks to @einschmidt)
# v1.2 (2021-02-11)
- (new) autorefresh rate
- (new) reduced bandwidth usage via stateful http headers `last-modified/etag`
@@ -8,6 +14,7 @@
- (new) `-auth-file` flag for authentication
- (new) `-cert-file` & `-key-file` flags for TLS
- (fix) wrapping long words in the ui to prevent vertical scroll
- (fix) increased toolbar height in mobile/tablet layout (thanks to @einschmidt)
# v1.1 (2020-10-05)

View File

@@ -1,7 +1,7 @@
VERSION=1.2
VERSION=1.3
GITHASH=$(shell git rev-parse --short=8 HEAD)
ASSETS = assets/javascripts/* assets/stylesheets/* assets/graphicarts/* assets/index.html
ASSETS = assets/javascripts/* assets/stylesheets/* assets/graphicarts/* assets/*.html
CGO_ENABLED=1
GO_LDFLAGS = -s -w

View File

@@ -51,6 +51,7 @@ func encode(b []byte) string {
func main() {
assets := make([]asset, 0)
filepatterns := []string{
"assets/login.html",
"assets/graphicarts/*.svg",
"assets/graphicarts/*.png",
"assets/javascripts/*.js",

View File

@@ -39,6 +39,15 @@ func userAuthenticate(rw http.ResponseWriter, username, password string) {
http.SetCookie(rw, &cookie)
}
func userLogout(rw http.ResponseWriter) {
cookie := http.Cookie{
Name: "auth",
Value: "",
MaxAge: -1,
}
http.SetCookie(rw, &cookie)
}
func stringsEqual(p1, p2 string) bool {
return subtle.ConstantTimeCompare([]byte(p1), []byte(p2)) == 1
}

View File

@@ -40,6 +40,7 @@ var routes []Route = []Route{
p("/opml/import", OPMLImportHandler),
p("/opml/export", OPMLExportHandler),
p("/page", PageCrawlHandler),
p("/logout", LogoutHandler),
}
type asset struct {
@@ -528,3 +529,8 @@ func PageCrawlHandler(rw http.ResponseWriter, req *http.Request) {
}
}
}
func LogoutHandler(rw http.ResponseWriter, req *http.Request) {
userLogout(rw)
rw.WriteHeader(http.StatusNoContent)
}