fixed a couple minor bugs

pull/8/head
Stephen Searles 8 years ago
parent 5d78da0f30
commit c8881bedfc
  1. 2
      caddyhugo.go
  2. 18
      templates.go

@ -477,7 +477,7 @@ func (ch CaddyHugo) NewContent(w http.ResponseWriter, r *http.Request) (int, err
} }
// serve redirect // serve redirect
http.Redirect(w, r, filepath.Join("/hugo/edit/", ch.Site.Root, "content", filename), http.StatusFound) http.Redirect(w, r, filepath.Join("/hugo/edit/", "content", filename), http.StatusFound)
return http.StatusFound, nil return http.StatusFound, nil
} }

@ -7,6 +7,7 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"strings"
"git.stephensearles.com/stephen/acedoc" "git.stephensearles.com/stephen/acedoc"
@ -106,23 +107,18 @@ func baseNoExt(name string) string {
func (t tmplData) IframeSource() string { func (t tmplData) IframeSource() string {
name := baseNoExt(t.docref.name) name := baseNoExt(t.docref.name)
ctype := baseNoExt(path.Dir(t.docref.name)) ctype := baseNoExt(path.Dir(t.docref.name))
return fmt.Sprintf("/hugo/draft/%s/%s/%s/", base64.RawURLEncoding.EncodeToString([]byte(t.docref.name)), ctype, name) return fmt.Sprintf("/hugo/draft/%s/%s/%s/", base64.RawURLEncoding.EncodeToString([]byte(t.docref.name)), ctype, strings.Replace(name, " ", "-", -1))
} }
var EditPage = `<html> var EditPage = `<html>
<head> <head>
<script src="/hugo/simplemde.js"></script> <script src="/hugo/simplemde.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ext-settings_menu.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ext-keybinding_menu.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/keybinding-vim.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/mode-markdown.js"></script>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
#editor { #editor-wrapper {
position: absolute; position: absolute;
top: 50px; top: 50px;
right: 0; right: 0;
bottom: 0; bottom: 150px;
left: 40%; left: 40%;
} }
#draft { #draft {
@ -151,8 +147,10 @@ var EditPage = `<html>
<span v-else>saved</span> <span v-else>saved</span>
<span v-if="connectionError">, ${connectionError}</span> <span v-if="connectionError">, ${connectionError}</span>
</div> </div>
<textarea id="editor">{{ .LoadContent }}</textarea> <div id="editor-wrapper">
<div id="draft"><!--<iframe src="{{ .IframeSource }}">Loading draft...</iframe>--></div> <textarea id="editor">{{ .LoadContent }}</textarea>
</div>
<div id="draft"><iframe src="{{ .IframeSource }}">Loading draft...</iframe></div>
</div> </div>
<script> <script>
var uiBindings = { var uiBindings = {

Loading…
Cancel
Save