add local TailwindCSS, fix side bar folder view, add more function to Markdown editor and allow .markdown files
This commit is contained in:
@@ -96,8 +96,8 @@ func (h *Handlers) CreateNoteHandler(c *gin.Context) {
|
||||
title += ".md"
|
||||
ext = "md"
|
||||
} else {
|
||||
// Has extension: allow if md or in allowed file extensions
|
||||
allowed := ext == "md"
|
||||
// Has extension: allow if md/markdown or in allowed file extensions
|
||||
allowed := (ext == "md" || ext == "markdown")
|
||||
if !allowed {
|
||||
for _, a := range h.config.AllowedFileExtensions {
|
||||
if strings.EqualFold(a, ext) {
|
||||
@@ -143,7 +143,7 @@ func (h *Handlers) CreateNoteHandler(c *gin.Context) {
|
||||
|
||||
// Redirect based on extension
|
||||
redirect := h.config.URLPrefix + "/note/" + notePath
|
||||
if strings.ToLower(ext) != "md" {
|
||||
if e := strings.ToLower(ext); e != "md" && e != "markdown" {
|
||||
redirect = h.config.URLPrefix + "/view_text/" + notePath
|
||||
}
|
||||
|
||||
@@ -158,11 +158,12 @@ func (h *Handlers) CreateNoteHandler(c *gin.Context) {
|
||||
func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
notePath := strings.TrimPrefix(c.Param("path"), "/")
|
||||
|
||||
if !strings.HasSuffix(notePath, ".md") {
|
||||
lp := strings.ToLower(notePath)
|
||||
if !(strings.HasSuffix(lp, ".md") || strings.HasSuffix(lp, ".markdown")) {
|
||||
c.HTML(http.StatusBadRequest, "error", gin.H{
|
||||
"error": "Invalid note path",
|
||||
"app_name": h.config.AppName,
|
||||
"message": "Note path must end with .md",
|
||||
"message": "Note path must end with .md or .markdown",
|
||||
"ContentTemplate": "error_content",
|
||||
"ScriptsTemplate": "error_scripts",
|
||||
"Page": "error",
|
||||
@@ -236,7 +237,13 @@ func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
title := strings.TrimSuffix(filepath.Base(notePath), ".md")
|
||||
base := filepath.Base(notePath)
|
||||
var title string
|
||||
if strings.HasSuffix(strings.ToLower(base), ".markdown") {
|
||||
title = strings.TrimSuffix(base, ".markdown")
|
||||
} else {
|
||||
title = strings.TrimSuffix(base, ".md")
|
||||
}
|
||||
folderPath := filepath.Dir(notePath)
|
||||
if folderPath == "." {
|
||||
folderPath = ""
|
||||
@@ -264,7 +271,8 @@ func (h *Handlers) EditNoteHandler(c *gin.Context) {
|
||||
notePath := strings.TrimPrefix(c.Param("path"), "/")
|
||||
content := c.PostForm("content")
|
||||
|
||||
if !strings.HasSuffix(notePath, ".md") {
|
||||
lp := strings.ToLower(notePath)
|
||||
if !(strings.HasSuffix(lp, ".md") || strings.HasSuffix(lp, ".markdown")) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid note path"})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user