Initial version of .docx upload support

This commit is contained in:
2025-01-17 05:02:31 +01:00
parent 0e825a55e5
commit 3d3cda319d
11 changed files with 256 additions and 38 deletions

View File

@@ -8,6 +8,7 @@ import (
"os"
"time"
"github.com/google/uuid"
b "streifling.com/jason/cpolis/cmd/backend"
)
@@ -26,6 +27,7 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s map[string]*Session) http.Handl
Rejected: false,
Created: time.Now(),
AutoGenerated: true,
UUID: uuid.New(),
}
if len(article.Title) == 0 {
@@ -55,7 +57,7 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s map[string]*Session) http.Handl
return
}
articleAbsName := fmt.Sprint(c.ArticleDir, "/", article.ID, ".md")
articleAbsName := fmt.Sprint(c.ArticleDir, "/", article.UUID, ".md")
if err = os.WriteFile(articleAbsName, content, 0644); err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)