Shiz innit

This commit is contained in:
Maximilian Friedersdorff 2025-06-01 21:27:08 +01:00
parent 3ad3666002
commit 2c0a3c7d80
8 changed files with 25 additions and 14 deletions

View file

@ -6,6 +6,7 @@ import (
"log"
"net/http"
"os"
"path"
"path/filepath"
"github.com/pelletier/go-toml/v2"
@ -19,6 +20,12 @@ type Asset struct {
func (asset *Asset) FetchIfNotExists(staticPath string) {
destPath := filepath.Join(staticPath, asset.Path)
err := os.MkdirAll(path.Dir(destPath), os.ModeDir|0777)
if err != nil {
log.Printf("Couldn't create parent dirs of %s\n", destPath)
panic(err)
}
out, err := os.OpenFile(
destPath,
os.O_WRONLY|os.O_CREATE|os.O_EXCL,
@ -75,6 +82,8 @@ func LoadConfig(path string) {
log.Fatal(err)
}
os.Mkdir(Conf.Static.Dir, os.FileMode(750))
for _, asset := range Conf.Static.Assets {
asset.FetchIfNotExists(Conf.Static.Dir)
}

View file

@ -10,7 +10,7 @@ import (
"os"
"path/filepath"
"gitea.gwairfelin.com/max/gonotes/internal/conf"
"forgejo.gwairfelin.com/max/gonotes/internal/conf"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
)

View file

@ -7,10 +7,10 @@ import (
"path/filepath"
"strings"
urls "gitea.gwairfelin.com/max/gispatcho"
"gitea.gwairfelin.com/max/gonotes/internal/conf"
"gitea.gwairfelin.com/max/gonotes/internal/notes"
"gitea.gwairfelin.com/max/gonotes/internal/templ"
urls "forgejo.gwairfelin.com/max/gispatcho"
"forgejo.gwairfelin.com/max/gonotes/internal/conf"
"forgejo.gwairfelin.com/max/gonotes/internal/notes"
"forgejo.gwairfelin.com/max/gonotes/internal/templ"
)
var myurls urls.URLs
@ -55,7 +55,7 @@ func edit(w http.ResponseWriter, r *http.Request) {
}
urlSave := myurls.Reverse("save", urls.Repl{"note": title})
context := templ.Ctx{"note": note, "urlSave": urlSave}
context := templ.Ctx{"note": note, "urlSave": urlSave, "text": string(note.Body)}
err = templ.RenderTemplate(w, "edit.tmpl.html", context)
if err != nil {
log.Print(err.Error())

View file

@ -6,7 +6,7 @@ import (
"os"
"path/filepath"
"gitea.gwairfelin.com/max/gonotes/internal/conf"
"forgejo.gwairfelin.com/max/gonotes/internal/conf"
)
type Ctx map[string]any