diff --git a/shroom/upload.go b/shroom/upload.go index 92fb51d..9fa0530 100644 --- a/shroom/upload.go +++ b/shroom/upload.go @@ -16,14 +16,22 @@ import ( "github.com/bouncepaw/mycorrhiza/user" ) -func UploadText(h *hyphae.Hypha, data []byte, u *user.User) (hop *history.HistoryOp, errtitle string) { +func UploadText(h *hyphae.Hypha, data []byte, message string, u *user.User) (hop *history.HistoryOp, errtitle string) { hop = history.Operation(history.TypeEditText) + var action string if h.Exists { - hop.WithMsg(fmt.Sprintf("Edit ‘%s’", h.Name)) + action = "Edit" } else { - hop.WithMsg(fmt.Sprintf("Create ‘%s’", h.Name)) + action = "Create" } + if message == "" { + hop.WithMsg(fmt.Sprintf("%s ‘%s’", action, h.Name)) + } else { + hop.WithMsg(fmt.Sprintf("%s ‘%s’ with message: ‘%s’", action, h.Name, message)) + } + + if err, errtitle := CanEdit(u, h); err != nil { return hop.WithErrAbort(err), errtitle } diff --git a/static/default.css b/static/default.css index 3e554d6..836784d 100644 --- a/static/default.css +++ b/static/default.css @@ -111,7 +111,7 @@ textarea {font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif; .edit__title { margin-top: 0; } .edit__preview { border: 2px dashed #ddd; } .edit-form {height:70vh;} -.edit-form textarea {width:100%;height:95%;} +.edit-form textarea {width:100%;height:calc(100% - 6rem);} .edit-form__save { font-weight: bold; } .edit-toolbar__buttons, .edit-toolbar__ad { margin: .5rem; } @@ -389,4 +389,4 @@ kbd { .dialog { background-color: #343434; } -} \ No newline at end of file +} diff --git a/views/mutators.qtpl b/views/mutators.qtpl index 139dccb..0e15f55 100644 --- a/views/mutators.qtpl +++ b/views/mutators.qtpl @@ -77,7 +77,10 @@
-
+

+ + +

Cancel @@ -88,7 +91,7 @@ {%= editScripts() %} {% endfunc %} -{% func PreviewHTML(rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) %} +{% func PreviewHTML(rq *http.Request, hyphaName, textAreaFill, message, warning string, renderedPage string) %} {%s= NavHTML(rq, hyphaName, "edit") %}
@@ -97,7 +100,10 @@ -
+

+ + +

Cancel diff --git a/views/mutators.qtpl.go b/views/mutators.qtpl.go index ade7926..8d513a7 100644 --- a/views/mutators.qtpl.go +++ b/views/mutators.qtpl.go @@ -204,191 +204,201 @@ func StreamEditHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, text qw422016.E().S(textAreaFill) //line views/mutators.qtpl:79 qw422016.N().S(` -
+

+ + +

Cancel
`) -//line views/mutators.qtpl:86 +//line views/mutators.qtpl:89 qw422016.N().S(Toolbar(user.FromRequest(rq))) -//line views/mutators.qtpl:86 +//line views/mutators.qtpl:89 qw422016.N().S(`
`) -//line views/mutators.qtpl:88 +//line views/mutators.qtpl:91 streameditScripts(qw422016) -//line views/mutators.qtpl:88 +//line views/mutators.qtpl:91 qw422016.N().S(` `) -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 } -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 func WriteEditHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) { -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 StreamEditHTML(qw422016, rq, hyphaName, textAreaFill, warning) -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 qt422016.ReleaseWriter(qw422016) -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 } -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 func EditHTML(rq *http.Request, hyphaName, textAreaFill, warning string) string { -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 qb422016 := qt422016.AcquireByteBuffer() -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 WriteEditHTML(qb422016, rq, hyphaName, textAreaFill, warning) -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 qs422016 := string(qb422016.B) -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 qt422016.ReleaseByteBuffer(qb422016) -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 return qs422016 -//line views/mutators.qtpl:89 +//line views/mutators.qtpl:92 } -//line views/mutators.qtpl:91 -func StreamPreviewHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) { -//line views/mutators.qtpl:91 +//line views/mutators.qtpl:94 +func StreamPreviewHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, message, warning string, renderedPage string) { +//line views/mutators.qtpl:94 qw422016.N().S(` `) -//line views/mutators.qtpl:92 +//line views/mutators.qtpl:95 qw422016.N().S(NavHTML(rq, hyphaName, "edit")) -//line views/mutators.qtpl:92 +//line views/mutators.qtpl:95 qw422016.N().S(`

Edit `) -//line views/mutators.qtpl:95 +//line views/mutators.qtpl:98 qw422016.E().S(util.BeautifulName(hyphaName)) -//line views/mutators.qtpl:95 +//line views/mutators.qtpl:98 qw422016.N().S(` (preview)

`) -//line views/mutators.qtpl:96 +//line views/mutators.qtpl:99 qw422016.N().S(warning) -//line views/mutators.qtpl:96 +//line views/mutators.qtpl:99 qw422016.N().S(`
-
+

+ + +

Cancel

Note that the hypha is not saved yet. You can preview the changes ↓

`) -//line views/mutators.qtpl:106 +//line views/mutators.qtpl:112 qw422016.N().S(renderedPage) -//line views/mutators.qtpl:106 +//line views/mutators.qtpl:112 qw422016.N().S(`
`) -//line views/mutators.qtpl:108 +//line views/mutators.qtpl:114 qw422016.N().S(Toolbar(user.FromRequest(rq))) -//line views/mutators.qtpl:108 +//line views/mutators.qtpl:114 qw422016.N().S(`
`) -//line views/mutators.qtpl:110 +//line views/mutators.qtpl:116 streameditScripts(qw422016) -//line views/mutators.qtpl:110 +//line views/mutators.qtpl:116 qw422016.N().S(` `) -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 } -//line views/mutators.qtpl:111 -func WritePreviewHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) { -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 +func WritePreviewHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, message, warning string, renderedPage string) { +//line views/mutators.qtpl:117 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/mutators.qtpl:111 - StreamPreviewHTML(qw422016, rq, hyphaName, textAreaFill, warning, renderedPage) -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 + StreamPreviewHTML(qw422016, rq, hyphaName, textAreaFill, message, warning, renderedPage) +//line views/mutators.qtpl:117 qt422016.ReleaseWriter(qw422016) -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 } -//line views/mutators.qtpl:111 -func PreviewHTML(rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) string { -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 +func PreviewHTML(rq *http.Request, hyphaName, textAreaFill, message, warning string, renderedPage string) string { +//line views/mutators.qtpl:117 qb422016 := qt422016.AcquireByteBuffer() -//line views/mutators.qtpl:111 - WritePreviewHTML(qb422016, rq, hyphaName, textAreaFill, warning, renderedPage) -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 + WritePreviewHTML(qb422016, rq, hyphaName, textAreaFill, message, warning, renderedPage) +//line views/mutators.qtpl:117 qs422016 := string(qb422016.B) -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 qt422016.ReleaseByteBuffer(qb422016) -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 return qs422016 -//line views/mutators.qtpl:111 +//line views/mutators.qtpl:117 } -//line views/mutators.qtpl:113 +//line views/mutators.qtpl:119 func streameditScripts(qw422016 *qt422016.Writer) { -//line views/mutators.qtpl:113 +//line views/mutators.qtpl:119 qw422016.N().S(` `) -//line views/mutators.qtpl:114 +//line views/mutators.qtpl:120 for _, scriptPath := range cfg.EditScripts { -//line views/mutators.qtpl:114 +//line views/mutators.qtpl:120 qw422016.N().S(` `) -//line views/mutators.qtpl:116 +//line views/mutators.qtpl:122 } -//line views/mutators.qtpl:116 +//line views/mutators.qtpl:122 qw422016.N().S(` `) -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 } -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 func writeeditScripts(qq422016 qtio422016.Writer) { -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 streameditScripts(qw422016) -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 qt422016.ReleaseWriter(qw422016) -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 } -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 func editScripts() string { -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 qb422016 := qt422016.AcquireByteBuffer() -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 writeeditScripts(qb422016) -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 qs422016 := string(qb422016.B) -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 qt422016.ReleaseByteBuffer(qb422016) -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 return qs422016 -//line views/mutators.qtpl:117 +//line views/mutators.qtpl:123 } diff --git a/web/mutators.go b/web/mutators.go index dfda455..0ec256a 100644 --- a/web/mutators.go +++ b/web/mutators.go @@ -173,13 +173,14 @@ func handlerUploadText(w http.ResponseWriter, rq *http.Request) { h = hyphae.ByName(hyphaName) textData = rq.PostFormValue("text") action = rq.PostFormValue("action") + message = rq.PostFormValue("message") u = user.FromRequest(rq) hop *history.HistoryOp errtitle string ) if action != "Preview" { - hop, errtitle = shroom.UploadText(h, []byte(textData), u) + hop, errtitle = shroom.UploadText(h, []byte(textData), message, u) if hop.HasErrors() { httpErr(w, http.StatusForbidden, hyphaName, errtitle, @@ -199,6 +200,7 @@ func handlerUploadText(w http.ResponseWriter, rq *http.Request) { rq, hyphaName, textData, + message, "", mycomarkup.BlocksToHTML(ctx, mycomarkup.BlockTree(ctx))), u))