parent
d629a79d52
commit
7313ce5bd7
|
@ -7,3 +7,9 @@ type Author struct {
|
|||
|
||||
Notebooks []*Notebook
|
||||
}
|
||||
|
||||
var PublicAuthor = &Author{
|
||||
Key: "public",
|
||||
Name: "Anonymous",
|
||||
Email: "anonymous@stick.app",
|
||||
}
|
||||
|
|
11
stick.go
11
stick.go
|
@ -38,6 +38,8 @@ func (s *Stick) loadAuthors() {
|
|||
for _, author := range stick.Config.Authors {
|
||||
stick.Authors[hash(author.Email)] = &Author{Key: hash(author.Email), Email: author.Email, Name: author.Name}
|
||||
}
|
||||
|
||||
stick.Authors["public"] = PublicAuthor
|
||||
}
|
||||
|
||||
func (s *Stick) loadNotebooks() {
|
||||
|
@ -55,7 +57,13 @@ func (s *Stick) loadNotebooks() {
|
|||
|
||||
notebook.Serve = make(map[string]int)
|
||||
for serveauthor, serveaccess := range nbconfig.Serve {
|
||||
notebook.Serve[hash(serveauthor)] = serveaccess
|
||||
var servehash string
|
||||
if serveauthor == "public" {
|
||||
servehash = "public"
|
||||
} else {
|
||||
servehash = hash(serveauthor)
|
||||
}
|
||||
notebook.Serve[servehash] = serveaccess
|
||||
}
|
||||
|
||||
stick.Notebooks[hash(nbconfig.Label)] = notebook
|
||||
|
@ -66,6 +74,7 @@ func (s *Stick) loadNotebooks() {
|
|||
for serveauth := range notebook.Serve {
|
||||
author = stick.getAuthor(serveauth)
|
||||
if author == nil {
|
||||
log.Println("no author", notebook.Label, stick.getAuthor(serveauth))
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
9
web.go
9
web.go
|
@ -249,8 +249,15 @@ func printServedNotebooks() {
|
|||
continue
|
||||
}
|
||||
|
||||
var authorName string
|
||||
if authkey == "public" {
|
||||
authorName = "Public"
|
||||
} else {
|
||||
authorName = author.Name[0:int(math.Min(10, float64(len(author.Name))))]
|
||||
}
|
||||
|
||||
log.Println()
|
||||
log.Printf("%-10s http://%s/#login/%s", author.Name[0:int(math.Min(10, float64(len(author.Name))))], stick.Config.Serve, authkey)
|
||||
log.Printf("%-10s http://%s/#login/%s", authorName, stick.Config.Serve, authkey)
|
||||
for _, notebook := range author.Notebooks {
|
||||
log.Printf("- %s", notebook.Label[0:int(math.Min(20, float64(len(notebook.Label))))])
|
||||
}
|
||||
|
|
|
@ -59,9 +59,6 @@ function Initialize() {
|
|||
if (window.location.hash.substring(0, 7) === '#login/') {
|
||||
processHash();
|
||||
processedHash = true;
|
||||
} else if (AuthKey === "") {
|
||||
alert('Please sign in');
|
||||
return;
|
||||
}
|
||||
|
||||
$(window).on("focus blur", function (e) {
|
||||
|
@ -120,8 +117,8 @@ function ResumeStick() {
|
|||
clearTimeout(PauseTimeout);
|
||||
PauseTimeout = null;
|
||||
}
|
||||
if (AuthKey === "") {
|
||||
return;
|
||||
if (AuthKey == "") {
|
||||
AuthKey = "public";
|
||||
}
|
||||
if (webSocketReady() || ReconnectDelay !== -1) {
|
||||
return;
|
||||
|
@ -735,6 +732,10 @@ function bindEditor() {
|
|||
}
|
||||
|
||||
function setAuthKey(newAuthKey) {
|
||||
if (newAuthKey == "") {
|
||||
newAuthKey = "public";
|
||||
}
|
||||
|
||||
AuthKey = newAuthKey;
|
||||
|
||||
db.transaction('rw', db.credentials, async () => {
|
||||
|
|
Loading…
Reference in New Issue