Merge pull request #179 from writeas/fix-pad-edit

set a default pad tempate on all pad renders
This commit is contained in:
Matt Baer 2019-09-09 13:34:58 +02:00 committed by GitHub
commit 811a0a3cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

12
pad.go
View File

@ -11,12 +11,13 @@
package writefreely
import (
"net/http"
"strings"
"github.com/gorilla/mux"
"github.com/writeas/impart"
"github.com/writeas/web-core/log"
"github.com/writeas/writefreely/page"
"net/http"
"strings"
)
func handleViewPad(app *App, w http.ResponseWriter, r *http.Request) error {
@ -54,16 +55,13 @@ func handleViewPad(app *App, w http.ResponseWriter, r *http.Request) error {
}
padTmpl := app.cfg.App.Editor
if padTmpl == "" {
if templates[padTmpl] == nil {
log.Info("No template '%s' found. Falling back to default 'pad' template.", padTmpl)
padTmpl = "pad"
}
if action == "" && slug == "" {
// Not editing any post; simply render the Pad
if templates[padTmpl] == nil {
log.Info("No template '%s' found. Falling back to default 'pad' template.", padTmpl)
padTmpl = "pad"
}
if err = templates[padTmpl].ExecuteTemplate(w, "pad", appData); err != nil {
log.Error("Unable to execute template: %v", err)
}