Compare commits

...
2 Commits
Author SHA1 Message Date
stephen 733594be70 added media view to edit page 2017-06-24 16:56:33 -07:00
stephen e959b41f2c moving assets into a dir 2017-06-24 11:06:57 -07:00
22 changed files with 61 additions and 22 deletions
+2
View File
@@ -0,0 +1,2 @@
//go:generate go-bindata -pkg assets simplemde/dist/... simplemde/debug/...
package assets
+10 -10
View File
@@ -8,7 +8,7 @@
// require.js // require.js
// DO NOT EDIT! // DO NOT EDIT!
package caddyhugo package assets
import ( import (
"bytes" "bytes"
@@ -245,12 +245,12 @@ func AssetNames() []string {
// _bindata is a table, holding each asset generator, mapped to its name. // _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){ var _bindata = map[string]func() (*asset, error){
"simplemde/dist/simplemde.min.css": simplemdeDistSimplemdeMinCss, "simplemde/dist/simplemde.min.css": simplemdeDistSimplemdeMinCss,
"simplemde/dist/simplemde.min.js": simplemdeDistSimplemdeMinJs, "simplemde/dist/simplemde.min.js": simplemdeDistSimplemdeMinJs,
"simplemde/debug/simplemde.css": simplemdeDebugSimplemdeCss, "simplemde/debug/simplemde.css": simplemdeDebugSimplemdeCss,
"simplemde/debug/simplemde.debug.js": simplemdeDebugSimplemdeDebugJs, "simplemde/debug/simplemde.debug.js": simplemdeDebugSimplemdeDebugJs,
"simplemde/debug/simplemde.js": simplemdeDebugSimplemdeJs, "simplemde/debug/simplemde.js": simplemdeDebugSimplemdeJs,
"require.js": requireJs, "require.js": requireJs,
} }
// AssetDir returns the file names below a certain // AssetDir returns the file names below a certain
@@ -292,17 +292,18 @@ type bintree struct {
Func func() (*asset, error) Func func() (*asset, error)
Children map[string]*bintree Children map[string]*bintree
} }
var _bintree = &bintree{nil, map[string]*bintree{ var _bintree = &bintree{nil, map[string]*bintree{
"require.js": &bintree{requireJs, map[string]*bintree{}}, "require.js": &bintree{requireJs, map[string]*bintree{}},
"simplemde": &bintree{nil, map[string]*bintree{ "simplemde": &bintree{nil, map[string]*bintree{
"debug": &bintree{nil, map[string]*bintree{ "debug": &bintree{nil, map[string]*bintree{
"simplemde.css": &bintree{simplemdeDebugSimplemdeCss, map[string]*bintree{}}, "simplemde.css": &bintree{simplemdeDebugSimplemdeCss, map[string]*bintree{}},
"simplemde.debug.js": &bintree{simplemdeDebugSimplemdeDebugJs, map[string]*bintree{}}, "simplemde.debug.js": &bintree{simplemdeDebugSimplemdeDebugJs, map[string]*bintree{}},
"simplemde.js": &bintree{simplemdeDebugSimplemdeJs, map[string]*bintree{}}, "simplemde.js": &bintree{simplemdeDebugSimplemdeJs, map[string]*bintree{}},
}}, }},
"dist": &bintree{nil, map[string]*bintree{ "dist": &bintree{nil, map[string]*bintree{
"simplemde.min.css": &bintree{simplemdeDistSimplemdeMinCss, map[string]*bintree{}}, "simplemde.min.css": &bintree{simplemdeDistSimplemdeMinCss, map[string]*bintree{}},
"simplemde.min.js": &bintree{simplemdeDistSimplemdeMinJs, map[string]*bintree{}}, "simplemde.min.js": &bintree{simplemdeDistSimplemdeMinJs, map[string]*bintree{}},
}}, }},
}}, }},
}} }}
@@ -353,4 +354,3 @@ func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1) cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
} }
+3 -3
View File
@@ -1,4 +1,3 @@
//go:generate go-bindata -pkg caddyhugo simplemde/dist/... simplemde/debug/...
package caddyhugo package caddyhugo
import ( import (
@@ -18,6 +17,7 @@ import (
"time" "time"
"git.stephensearles.com/stephen/acedoc" "git.stephensearles.com/stephen/acedoc"
"git.stephensearles.com/stephen/caddy-hugo2/assets"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/mholt/caddy" "github.com/mholt/caddy"
@@ -146,11 +146,11 @@ func (ch *CaddyHugo) ServeHTTPWithNext(next httpserver.Handler, c *caddy.Control
return http.StatusFound, nil return http.StatusFound, nil
} }
if strings.HasPrefix(r.URL.Path, "/hugo/simplemde.css") { if strings.HasPrefix(r.URL.Path, "/hugo/simplemde.css") {
w.Write(MustAsset("simplemde/dist/simplemde.min.css")) w.Write(assets.MustAsset("simplemde/dist/simplemde.min.css"))
return http.StatusOK, nil return http.StatusOK, nil
} }
if strings.HasPrefix(r.URL.Path, "/hugo/simplemde.js") { if strings.HasPrefix(r.URL.Path, "/hugo/simplemde.js") {
w.Write(MustAsset("simplemde/debug/simplemde.js")) w.Write(assets.MustAsset("simplemde/debug/simplemde.js"))
return http.StatusOK, nil return http.StatusOK, nil
} }
if strings.HasPrefix(r.URL.Path, "/hugo/admin") { if strings.HasPrefix(r.URL.Path, "/hugo/admin") {
+16 -4
View File
@@ -222,15 +222,27 @@ func (ch *CaddyHugo) serveMediaPage(w http.ResponseWriter, r *http.Request) (int
io.WriteString(w, `<html> io.WriteString(w, `<html>
<head><style> <head><style>
.img { float: left; text-align: center; max-width: 19.9vw; min-height: 120px;} iframe { height: 100%; }
.img { display: inline-block; text-align: center; max-width: 19.9vw; min-height: 120px;}
.copy { cursor: pointer; } .copy { cursor: pointer; }
@media (max-width: 800px) {
.img {
width: 50%;
max-width: 50%;
}
body {
min-height: 300px;
}
}
</style></head> </style></head>
<body> <body>
<div style="position: fixed; top: 0; height: 10vh; width: 100%;"> <div style="position: fixed; top: 0; height: 10vh; width: 100%; background-color: white;">
<div style="float: left; width: 100%; height: 10vh;">
`) `)
io.WriteString(w, UploadPage("media")) io.WriteString(w, UploadPage("media"))
io.WriteString(w, "</div>")
io.WriteString(w, `</div>
<div style="display: inline-block; width: 100%; height: 10vh;"></div>
`)
if ch.Media != nil { if ch.Media != nil {
media, err := ch.Media.Walk() media, err := ch.Media.Walk()
if err != nil { if err != nil {
+30 -5
View File
@@ -137,6 +137,11 @@ var EditPage = `<html>
width: 100%; width: 100%;
border: none; border: none;
} }
a {
text-decoration: underline;
text-decoration-style: dotted;
cursor: pointer;
}
</style> </style>
<link rel="stylesheet" href="/hugo/simplemde.css" /> <link rel="stylesheet" href="/hugo/simplemde.css" />
<script src="https://unpkg.com/vue"></script> <script src="https://unpkg.com/vue"></script>
@@ -145,10 +150,16 @@ var EditPage = `<html>
<body> <body>
<div id="container" > <div id="container" >
<div id="lastSaved"> <div id="header">
<span v-if="ltime >serverLtime && (sendQueue.length > 0 || sentRecently.length > 0)">last saved ${ lastSaved.from(now) }, saving</span> <div id="lastSaved">
<span v-else>saved</span> <span v-if="ltime >serverLtime && (sendQueue.length > 0 || sentRecently.length > 0)">last saved ${ lastSaved.from(now) }, saving</span>
<span v-if="connectionError">, ${connectionError}</span> <span v-else>saved</span>
<span v-if="connectionError">, ${connectionError}</span>
</div>
<div>
<a id="sideview-toggle-media">media</a>
<a id="sideview-toggle-draft">draft</a>
</div>
</div> </div>
<div id="editor-wrapper"> <div id="editor-wrapper">
<textarea id="editor">{{ .LoadContent }}</textarea> <textarea id="editor">{{ .LoadContent }}</textarea>
@@ -156,6 +167,21 @@ var EditPage = `<html>
<div id="draft"><iframe src="{{ .IframeSource }}">Loading draft...</iframe></div> <div id="draft"><iframe src="{{ .IframeSource }}">Loading draft...</iframe></div>
</div> </div>
<script> <script>
var iframe = document.querySelector("#draft > iframe");
document.onclick = function (event) {
var iframe = document.querySelector("#draft > iframe");
switch (event.target.id) {
case "sideview-toggle-media":
iframe.src = "/hugo/media";
break;
case "sideview-toggle-draft":
iframe.src = "{{ .IframeSource }}";
break;
}
}
var uiBindings = { var uiBindings = {
ltime: 0, ltime: 0,
serverLtime: 0, serverLtime: 0,
@@ -200,7 +226,6 @@ var EditPage = `<html>
// Create WebSocket connection. // Create WebSocket connection.
var socket = connect(); var socket = connect();
var iframe = document.querySelector("#draft > iframe");
const sawChangesBumpsTo = 10; const sawChangesBumpsTo = 10;