a bit of renaming things
This commit is contained in:
@@ -13,14 +13,14 @@ import (
|
||||
"git.stephensearles.com/stephen/acedoc"
|
||||
)
|
||||
|
||||
type docref struct {
|
||||
type editSession struct {
|
||||
clients uint
|
||||
name string
|
||||
doc *acedoc.Document
|
||||
tmpdir string
|
||||
}
|
||||
|
||||
func (ch *CaddyHugo) newClient(docName string) (*docref, error) {
|
||||
func (ch *CaddyHugo) newEditSession(docName string) (*editSession, error) {
|
||||
filename := ch.docFilename(docName)
|
||||
|
||||
fmt.Println("opening", filename)
|
||||
@@ -32,7 +32,7 @@ func (ch *CaddyHugo) newClient(docName string) (*docref, error) {
|
||||
draftPrefix := fmt.Sprintf("draft-%s", base64.RawURLEncoding.EncodeToString([]byte(docName)))
|
||||
tmpdir := path.Join(os.TempDir(), draftPrefix)
|
||||
|
||||
ref := &docref{
|
||||
ref := &editSession{
|
||||
name: docName,
|
||||
doc: acedoc.NewString(string(contents)),
|
||||
tmpdir: tmpdir,
|
||||
@@ -103,26 +103,25 @@ func (ch *CaddyHugo) newClient(docName string) (*docref, error) {
|
||||
return ref, nil
|
||||
}
|
||||
|
||||
func (ch *CaddyHugo) hasdocref(docName string) (*docref, bool) {
|
||||
func (ch *CaddyHugo) hasEditSession(docName string) (*editSession, bool) {
|
||||
dr, ok := ch.docs[ch.docFilename(docName)]
|
||||
return dr, ok
|
||||
}
|
||||
|
||||
func (ch *CaddyHugo) client(docName string) (*docref, error) {
|
||||
func (ch *CaddyHugo) editSession(docName string) (*editSession, error) {
|
||||
ch.mtx.Lock()
|
||||
defer ch.mtx.Unlock()
|
||||
|
||||
var err error
|
||||
|
||||
dr, ok := ch.hasdocref(docName)
|
||||
dr, ok := ch.hasEditSession(docName)
|
||||
if !ok {
|
||||
dr, err = ch.newClient(docName)
|
||||
dr, err = ch.newEditSession(docName)
|
||||
}
|
||||
|
||||
return dr, err
|
||||
}
|
||||
|
||||
func (ch *CaddyHugo) doc(r *http.Request) (*docref, error) {
|
||||
name := r.URL.Path[len("/hugo/edit/"):]
|
||||
return ch.client(name)
|
||||
func docNameFromEditRequest(r *http.Request) string {
|
||||
return r.URL.Path[len("/hugo/edit/"):]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user