Made link a single word
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/gomarkdown/markdown"
|
||||
"go.uber.org/zap"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -69,7 +70,7 @@ func articlePost(w http.ResponseWriter, r *http.Request) {
|
||||
Image: payload.Image,
|
||||
Created: time.Now().Unix(),
|
||||
Modified: time.Unix(0, 0).Unix(),
|
||||
Link: "/" + path.Join(config.Prefix, "article", payload.Link),
|
||||
Link: payload.Link,
|
||||
Markdown: string(rawMarkdown),
|
||||
Html: string(markdown.ToHTML(rawMarkdown, nil, nil)),
|
||||
}
|
||||
@@ -82,14 +83,16 @@ func articlePost(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
database.GetDB().Table("article_author").Create(&authors)
|
||||
var tags []map[string]interface{}
|
||||
for _, tag := range payload.Tags {
|
||||
authors = append(authors, map[string]interface{}{
|
||||
"article_id": a.ID,
|
||||
"tag": tag,
|
||||
})
|
||||
if len(payload.Tags) > 0 {
|
||||
var tags []map[string]interface{}
|
||||
for _, tag := range payload.Tags {
|
||||
authors = append(authors, map[string]interface{}{
|
||||
"article_id": a.ID,
|
||||
"tag": tag,
|
||||
})
|
||||
}
|
||||
database.GetDB().Table("article_tag").Create(&tags)
|
||||
}
|
||||
database.GetDB().Table("article_tag").Create(&tags)
|
||||
|
||||
var articleSummary schema.ArticleSummary
|
||||
database.GetDB().Table("article").Find(&articleSummary, &a.ID)
|
||||
@@ -99,6 +102,7 @@ func articlePost(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
articleSummary.Tags = []string{}
|
||||
}
|
||||
articleSummary.Link = "/" + path.Join(config.Prefix, "article", url.PathEscape(articleSummary.Link))
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
json.NewEncoder(w).Encode(articleSummary)
|
||||
@@ -175,7 +179,7 @@ func articlePatch(w http.ResponseWriter, r *http.Request) {
|
||||
updates["image"] = *payload.Image
|
||||
}
|
||||
if payload.Link != nil {
|
||||
updates["link"] = path.Join(config.Prefix, "article", *payload.Link)
|
||||
updates["link"] = *payload.Link
|
||||
}
|
||||
if payload.Content != nil {
|
||||
rawMarkdown, err := base64.StdEncoding.DecodeString(*payload.Content)
|
||||
@@ -212,6 +216,7 @@ func articlePatch(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
articleSummary.Tags = []string{}
|
||||
}
|
||||
articleSummary.Link = "/" + path.Join(config.Prefix, "article", url.PathEscape(articleSummary.Link))
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(articleSummary)
|
||||
|
||||
Reference in New Issue
Block a user