mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 18:00:05 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0916f1179e | ||
|
6a5be593df | ||
|
7fd1ef80c5 | ||
|
26313f7842 | ||
|
ce1914419a | ||
|
6a828532cb | ||
|
e8a002d535 |
@@ -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()
|
||||
})
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
||||
|
4
makefile
4
makefile
@@ -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
|
||||
|
@@ -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",
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user