20 Hopefully fix broken output by using path instead of filepath (windows related issue)

This commit is contained in:
Christoph Herb
2024-12-23 15:13:18 +01:00
parent a0fec07dfe
commit 86b98cc8a3
3 changed files with 10 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ import (
"io"
"net/http"
"os"
"path/filepath"
"path"
"strings"
"text/template"
@@ -93,10 +93,10 @@ func downloadIcon(baseDir, url string) (string, error) {
parts := strings.Split(url, "/")
fileName := parts[len(parts)-1]
destPath := filepath.Join(baseDir, fileName)
htmlPath := filepath.Join("/static/emojis", fileName)
destPath := path.Join(baseDir, fileName)
htmlPath := path.Join("/static/emojis", fileName)
if err := os.MkdirAll(filepath.Dir(destPath), os.ModePerm); err != nil {
if err := os.MkdirAll(path.Dir(destPath), os.ModePerm); err != nil {
return "", fmt.Errorf("failed to create directories: %v", err)
}

View File

@@ -6,7 +6,7 @@ import (
"html/template"
"io"
"log"
"path/filepath"
"path"
"regexp"
"strings"
@@ -219,7 +219,7 @@ func renderHookListItem(w io.Writer, node ast.Node, entering bool) (ast.WalkStat
}
func createBlockquoteStart(alert string) (string, error) {
lp := filepath.Join("templates/alert", fmt.Sprintf("%s.html", alert))
lp := path.Join("templates/alert", fmt.Sprintf("%s.html", alert))
tmpl, err := template.ParseFS(defaults.Templates, lp)
if err != nil {
return "", err
@@ -241,7 +241,7 @@ func renderMermaid(content string, darkmode bool) (string, error) {
Content: content,
Darkmode: darkmode,
}
lp := filepath.Join("templates/mermaid/mermaid.html")
lp := path.Join("templates/mermaid/mermaid.html")
tmpl, err := template.ParseFS(defaults.Templates, lp)
if err != nil {
return "", err

View File

@@ -7,7 +7,7 @@ import (
"log"
"net/http"
"net/url"
"path/filepath"
"path"
"regexp"
"text/template"
@@ -21,8 +21,8 @@ type htmlStruct struct {
}
func (client *Client) Serve(file string) error {
directory := filepath.Dir(file)
filename := filepath.Base(file)
directory := path.Dir(file)
filename := path.Base(file)
reload := reload.New(directory)
reload.Log = log.New(io.Discard, "", 0)