fix go templating
This commit is contained in:
@@ -19,7 +19,7 @@ func (h *Handlers) CreateNotePageHandler(c *gin.Context) {
|
||||
|
||||
notesTree, err := utils.BuildTreeStructure(h.config.NotesDir, h.config.NotesDirHideSidepane, h.config)
|
||||
if err != nil {
|
||||
c.HTML(http.StatusInternalServerError, "base.html", gin.H{
|
||||
c.HTML(http.StatusInternalServerError, "error", gin.H{
|
||||
"error": "Failed to build tree structure",
|
||||
"app_name": h.config.AppName,
|
||||
"message": err.Error(),
|
||||
@@ -27,7 +27,7 @@ func (h *Handlers) CreateNotePageHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "base.html", gin.H{
|
||||
c.HTML(http.StatusOK, "create", gin.H{
|
||||
"app_name": h.config.AppName,
|
||||
"folder_path": folderPath,
|
||||
"notes_tree": notesTree,
|
||||
@@ -105,7 +105,7 @@ func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
notePath := strings.TrimPrefix(c.Param("path"), "/")
|
||||
|
||||
if !strings.HasSuffix(notePath, ".md") {
|
||||
c.HTML(http.StatusBadRequest, "base.html", gin.H{
|
||||
c.HTML(http.StatusBadRequest, "error", gin.H{
|
||||
"error": "Invalid note path",
|
||||
"app_name": h.config.AppName,
|
||||
"message": "Note path must end with .md",
|
||||
@@ -115,7 +115,7 @@ func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
|
||||
// Security check
|
||||
if strings.Contains(notePath, "..") {
|
||||
c.HTML(http.StatusBadRequest, "base.html", gin.H{
|
||||
c.HTML(http.StatusBadRequest, "error", gin.H{
|
||||
"error": "Invalid path",
|
||||
"app_name": h.config.AppName,
|
||||
"message": "Path traversal is not allowed",
|
||||
@@ -125,7 +125,7 @@ func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
|
||||
// Check if path is in skipped directories
|
||||
if utils.IsPathInSkippedDirs(notePath, h.config.NotesDirSkip) {
|
||||
c.HTML(http.StatusForbidden, "base.html", gin.H{
|
||||
c.HTML(http.StatusForbidden, "error", gin.H{
|
||||
"error": "Access denied",
|
||||
"app_name": h.config.AppName,
|
||||
"message": "This note cannot be edited",
|
||||
@@ -136,7 +136,7 @@ func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
fullPath := filepath.Join(h.config.NotesDir, notePath)
|
||||
|
||||
if _, err := os.Stat(fullPath); os.IsNotExist(err) {
|
||||
c.HTML(http.StatusNotFound, "base.html", gin.H{
|
||||
c.HTML(http.StatusNotFound, "error", gin.H{
|
||||
"error": "Note not found",
|
||||
"app_name": h.config.AppName,
|
||||
"message": "The requested note does not exist",
|
||||
@@ -146,7 +146,7 @@ func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
|
||||
content, err := os.ReadFile(fullPath)
|
||||
if err != nil {
|
||||
c.HTML(http.StatusInternalServerError, "base.html", gin.H{
|
||||
c.HTML(http.StatusInternalServerError, "error", gin.H{
|
||||
"error": "Failed to read note",
|
||||
"app_name": h.config.AppName,
|
||||
"message": err.Error(),
|
||||
@@ -156,7 +156,7 @@ func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
|
||||
notesTree, err := utils.BuildTreeStructure(h.config.NotesDir, h.config.NotesDirHideSidepane, h.config)
|
||||
if err != nil {
|
||||
c.HTML(http.StatusInternalServerError, "base.html", gin.H{
|
||||
c.HTML(http.StatusInternalServerError, "error", gin.H{
|
||||
"error": "Failed to build tree structure",
|
||||
"app_name": h.config.AppName,
|
||||
"message": err.Error(),
|
||||
@@ -170,7 +170,7 @@ func (h *Handlers) EditNotePageHandler(c *gin.Context) {
|
||||
folderPath = ""
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "base.html", gin.H{
|
||||
c.HTML(http.StatusOK, "edit", gin.H{
|
||||
"app_name": h.config.AppName,
|
||||
"title": title,
|
||||
"content": string(content),
|
||||
|
||||
Reference in New Issue
Block a user