work in progress
This commit is contained in:
parent
38f7c31517
commit
07ff5ccffb
23 changed files with 228 additions and 240 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2017 Marius Schellenberger
|
||||
|
||||
package main
|
||||
package server
|
||||
|
||||
import (
|
||||
"crypto/subtle"
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
package main
|
||||
|
||||
import "sync"
|
||||
|
||||
type Editor struct {
|
||||
Username string
|
||||
Time string
|
||||
}
|
||||
|
||||
type EditorStore struct {
|
||||
sync.RWMutex
|
||||
m map[string]*Editor
|
||||
}
|
||||
|
||||
func NewEditorStore() *EditorStore {
|
||||
return &EditorStore{m: make(map[string]*Editor)}
|
||||
}
|
||||
|
||||
func (e *EditorStore) Set(page, username string) *Editor {
|
||||
e.Lock()
|
||||
defer e.Unlock()
|
||||
editor := e.m[page]
|
||||
if editor != nil {
|
||||
return editor
|
||||
}
|
||||
e.m[page] = &Editor{username, now()}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *EditorStore) RemoveEditor(page, username string) {
|
||||
e.Lock()
|
||||
defer e.Unlock()
|
||||
if editor, ok := e.m[page]; ok {
|
||||
if editor.Username == username {
|
||||
delete(e.m, page)
|
||||
}
|
||||
}
|
||||
}
|
||||
func (e *EditorStore) Remove(page string) {
|
||||
e.Lock()
|
||||
defer e.Unlock()
|
||||
delete(e.m, page)
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2017 Marius Schellenberger
|
||||
|
||||
package main
|
||||
package server
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2017 Marius Schellenberger
|
||||
|
||||
package main
|
||||
package server
|
||||
|
||||
type route struct {
|
||||
Path string
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -10,6 +10,9 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/db"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/index"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -22,9 +25,8 @@ type HTTPServer struct {
|
|||
Version string
|
||||
SecCookie bool
|
||||
Store *sessions.CookieStore
|
||||
Editors *EditorStore
|
||||
BS *BoltStore
|
||||
Index *Index
|
||||
BS *db.BoltStore
|
||||
Index *index.Index
|
||||
listener net.Listener
|
||||
srv *http.Server
|
||||
templ map[string]*template.Template
|
||||
|
|
@ -37,7 +39,6 @@ func NewHTTPServer(l net.Listener, versin string, secCookie bool) (srv *HTTPServ
|
|||
SecCookie: secCookie,
|
||||
listener: l,
|
||||
}
|
||||
srv.Editors = NewEditorStore()
|
||||
srv.cookieStore()
|
||||
srv.loadTemplates()
|
||||
srv.srv = &http.Server{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package server
|
||||
|
||||
func allSnippetHandler(ctx *Context) {
|
||||
ctx.Template("allSnippetHandler")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// This file is auto-generated by build/templates.sh
|
||||
// using the contents of the templates directory
|
||||
|
||||
package main
|
||||
package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -415,13 +415,19 @@ const (
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-1 control-label">Public</label>
|
||||
<div class="col-xs-11">
|
||||
{{if .Data.Public}}
|
||||
<input type="checkbox" name="public" value="0" checked>
|
||||
{{else}}
|
||||
<input type="checkbox" name="public" value="0">
|
||||
{{end}}
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="perm1" name="perm" value="0" class="custom-control-input" checked="">
|
||||
<label class="custom-control-label" for="perm1">Public</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="perm2" name="perm" value="1" class="custom-control-input">
|
||||
<label class="custom-control-label" for="perm2">Internal</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="perm3" name="perm" value="2" class="custom-control-input">
|
||||
<label class="custom-control-label" for="perm3">Private</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
@ -504,9 +510,19 @@ const (
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-1 control-label">Public</label>
|
||||
<div class="col-xs-11">
|
||||
<input type="checkbox" name="public" value="0">
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="perm1" name="perm" value="0" class="custom-control-input" checked="">
|
||||
<label class="custom-control-label" for="perm1">Public</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="perm2" name="perm" value="1" class="custom-control-input">
|
||||
<label class="custom-control-label" for="perm2">Internal</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="perm3" name="perm" value="2" class="custom-control-input">
|
||||
<label class="custom-control-label" for="perm3">Private</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue