mirror of
https://github.com/writefreely/writefreely
synced 2024-11-10 11:24:13 +00:00
parent
c60c61c5b8
commit
fc856e36eb
3 changed files with 18 additions and 4 deletions
7
pad.go
7
pad.go
|
@ -124,7 +124,12 @@ func handleViewMeta(app *app, w http.ResponseWriter, r *http.Request) error {
|
|||
// TODO: add ErrForbiddenEditPost message to flashes
|
||||
return impart.HTTPError{http.StatusFound, r.URL.Path[:strings.LastIndex(r.URL.Path, "/meta")]}
|
||||
}
|
||||
appData.EditCollection, err = app.db.GetCollectionForPad(collAlias)
|
||||
if app.cfg.App.SingleUser {
|
||||
// TODO: optimize this query just like we do in GetCollectionForPad (?)
|
||||
appData.EditCollection, err = app.db.GetCollectionByID(1)
|
||||
} else {
|
||||
appData.EditCollection, err = app.db.GetCollectionForPad(collAlias)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
13
posts.go
13
posts.go
|
@ -681,7 +681,11 @@ func existingPost(app *app, w http.ResponseWriter, r *http.Request) error {
|
|||
collectionAlias := vars["alias"]
|
||||
redirect := "/" + postID + "/meta"
|
||||
if collectionAlias != "" {
|
||||
redirect = "/" + collectionAlias + "/" + pRes.Slug.String + "/edit/meta"
|
||||
collPre := "/" + collectionAlias
|
||||
if app.cfg.App.SingleUser {
|
||||
collPre = ""
|
||||
}
|
||||
redirect = collPre + "/" + pRes.Slug.String + "/edit/meta"
|
||||
}
|
||||
w.Header().Set("Location", redirect)
|
||||
w.WriteHeader(http.StatusFound)
|
||||
|
@ -1131,8 +1135,13 @@ func getRawCollectionPost(app *app, slug, collAlias string) *RawPost {
|
|||
var created time.Time
|
||||
var ownerID null.Int
|
||||
var views int64
|
||||
var err error
|
||||
|
||||
err := app.db.QueryRow("SELECT id, title, content, text_appearance, language, rtl, view_count, created, owner_id FROM posts WHERE slug = ? AND collection_id = (SELECT id FROM collections WHERE alias = ?)", slug, collAlias).Scan(&id, &title, &content, &font, &lang, &isRTL, &views, &created, &ownerID)
|
||||
if app.cfg.App.SingleUser {
|
||||
err = app.db.QueryRow("SELECT id, title, content, text_appearance, language, rtl, view_count, created, owner_id FROM posts WHERE slug = ? AND collection_id = 1", slug).Scan(&id, &title, &content, &font, &lang, &isRTL, &views, &created, &ownerID)
|
||||
} else {
|
||||
err = app.db.QueryRow("SELECT id, title, content, text_appearance, language, rtl, view_count, created, owner_id FROM posts WHERE slug = ? AND collection_id = (SELECT id FROM collections WHERE alias = ?)", slug, collAlias).Scan(&id, &title, &content, &font, &lang, &isRTL, &views, &created, &ownerID)
|
||||
}
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
return &RawPost{Content: "", Found: false, Gone: false}
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
<div class="content-container tight">
|
||||
<form action="/api/{{if .EditCollection}}collections/{{.EditCollection.Alias}}/{{end}}posts/{{.Post.Id}}" method="post" onsubmit="return updateMeta()">
|
||||
<h2>Edit metadata: {{if .Post.Title}}{{.Post.Title}}{{else}}{{.Post.Id}}{{end}} <a href="/{{if .EditCollection}}{{.EditCollection.Alias}}/{{.Post.Slug}}{{else}}{{if .SingleUser}}d/{{end}}{{.Post.Id}}{{end}}">view post</a></h2>
|
||||
<h2>Edit metadata: {{if .Post.Title}}{{.Post.Title}}{{else}}{{.Post.Id}}{{end}} <a href="/{{if .EditCollection}}{{if not .SingleUser}}{{.EditCollection.Alias}}/{{end}}{{.Post.Slug}}{{else}}{{if .SingleUser}}d/{{end}}{{.Post.Id}}{{end}}">view post</a></h2>
|
||||
|
||||
{{if .Flashes}}<ul class="errors">
|
||||
{{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
|
||||
|
|
Loading…
Reference in a new issue