Compare commits

..

No commits in common. "2fdf9ce7e662add7d640a520f04b23327a85fdd6" and "def6e6f24ffc95ca7ec3e0f70c707c5735c3a9f8" have entirely different histories.

3 changed files with 5 additions and 10 deletions

View File

@ -55,8 +55,6 @@ func PrepareTable(tx *sqlx.Tx) error {
func NewFromMd(db *db.Database, body string) *Entry {
e := New(db)
e.Content = body
e.Title = e.GenerateTitle()
e.Slug = e.UniqueSlug()
return e
}

View File

@ -75,7 +75,7 @@
.then(res => {
this.$emit('markDirty', false)
this.$store.dispatch('updateSearch')
if (res.data.Slug !== this.$route.params.slug)
if (res.data.Slug != this.$route.params.slug)
this.$router.replace({params: { slug: res.data.Slug }})
})
.catch(() => { })

View File

@ -17,16 +17,13 @@ func (web *Web) editEntry(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
slug := vars["slug"]
dec := json.NewDecoder(r.Body)
req := struct {
Content string
}{}
err := dec.Decode(&req)
newEntry := entry.New(web.db)
err := dec.Decode(&newEntry)
if err != nil {
w.WriteHeader(500)
fmt.Fprint(w, err)
return
}
newEntry := entry.NewFromMd(web.db, req.Content)
oldEntry, err := entry.GetBySlug(web.db, slug)
if err != nil {
@ -36,8 +33,6 @@ func (web *Web) editEntry(w http.ResponseWriter, r *http.Request) {
}
oldEntry.Content = newEntry.Content
oldEntry.Title = newEntry.Title
oldEntry.Slug = newEntry.UniqueSlug()
oldEntry.Tags = newEntry.Tags
oldEntry.Updated = time.Now()
@ -54,6 +49,8 @@ func (web *Web) editEntry(w http.ResponseWriter, r *http.Request) {
return
}
log.Debug().Interface("oldEntry", oldEntry).Msg("Got a PUT")
w.Header().Set("content-type", "application/json")
fmt.Fprint(w, string(resp))
}