mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-14 02:10:04 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0916f1179e | ||
|
6a5be593df | ||
|
7fd1ef80c5 | ||
|
26313f7842 | ||
|
ce1914419a | ||
|
6a828532cb | ||
|
e8a002d535 |
@@ -1,11 +1,17 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
(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 api = function(method, endpoint, data) {
|
||||||
var headers = {'Content-Type': 'application/json'}
|
var headers = {'Content-Type': 'application/json'}
|
||||||
if (['post', 'put', 'delete'].indexOf(method) !== -1)
|
return xfetch(endpoint, {
|
||||||
headers['x-requested-by'] = 'yarr'
|
|
||||||
return fetch(endpoint, {
|
|
||||||
method: method,
|
method: method,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
@@ -87,13 +93,16 @@
|
|||||||
return api('get', './api/status').then(json)
|
return api('get', './api/status').then(json)
|
||||||
},
|
},
|
||||||
upload_opml: function(form) {
|
upload_opml: function(form) {
|
||||||
return fetch('./opml/import', {
|
return xfetch('./opml/import', {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
body: new FormData(form),
|
body: new FormData(form),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
logout: function() {
|
||||||
|
return api('post', './logout')
|
||||||
|
},
|
||||||
crawl: function(url) {
|
crawl: function(url) {
|
||||||
return fetch('./page?url=' + url).then(function(res) {
|
return xfetch('./page?url=' + url).then(function(res) {
|
||||||
return res.text()
|
return res.text()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -509,6 +509,11 @@ var vm = new Vue({
|
|||||||
vm.refreshStats()
|
vm.refreshStats()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
logout: function() {
|
||||||
|
api.logout().then(function() {
|
||||||
|
document.location.reload()
|
||||||
|
})
|
||||||
|
},
|
||||||
getReadable: function(item) {
|
getReadable: function(item) {
|
||||||
if (this.itemSelectedReadability) {
|
if (this.itemSelectedReadability) {
|
||||||
this.itemSelectedReadability = null
|
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) autorefresh rate
|
||||||
- (new) reduced bandwidth usage via stateful http headers `last-modified/etag`
|
- (new) reduced bandwidth usage via stateful http headers `last-modified/etag`
|
||||||
@@ -8,6 +14,7 @@
|
|||||||
- (new) `-auth-file` flag for authentication
|
- (new) `-auth-file` flag for authentication
|
||||||
- (new) `-cert-file` & `-key-file` flags for TLS
|
- (new) `-cert-file` & `-key-file` flags for TLS
|
||||||
- (fix) wrapping long words in the ui to prevent vertical scroll
|
- (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)
|
# 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)
|
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
|
CGO_ENABLED=1
|
||||||
|
|
||||||
GO_LDFLAGS = -s -w
|
GO_LDFLAGS = -s -w
|
||||||
|
@@ -51,6 +51,7 @@ func encode(b []byte) string {
|
|||||||
func main() {
|
func main() {
|
||||||
assets := make([]asset, 0)
|
assets := make([]asset, 0)
|
||||||
filepatterns := []string{
|
filepatterns := []string{
|
||||||
|
"assets/login.html",
|
||||||
"assets/graphicarts/*.svg",
|
"assets/graphicarts/*.svg",
|
||||||
"assets/graphicarts/*.png",
|
"assets/graphicarts/*.png",
|
||||||
"assets/javascripts/*.js",
|
"assets/javascripts/*.js",
|
||||||
|
@@ -39,6 +39,15 @@ func userAuthenticate(rw http.ResponseWriter, username, password string) {
|
|||||||
http.SetCookie(rw, &cookie)
|
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 {
|
func stringsEqual(p1, p2 string) bool {
|
||||||
return subtle.ConstantTimeCompare([]byte(p1), []byte(p2)) == 1
|
return subtle.ConstantTimeCompare([]byte(p1), []byte(p2)) == 1
|
||||||
}
|
}
|
||||||
|
@@ -40,6 +40,7 @@ var routes []Route = []Route{
|
|||||||
p("/opml/import", OPMLImportHandler),
|
p("/opml/import", OPMLImportHandler),
|
||||||
p("/opml/export", OPMLExportHandler),
|
p("/opml/export", OPMLExportHandler),
|
||||||
p("/page", PageCrawlHandler),
|
p("/page", PageCrawlHandler),
|
||||||
|
p("/logout", LogoutHandler),
|
||||||
}
|
}
|
||||||
|
|
||||||
type asset struct {
|
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