More fixing

This commit is contained in:
Dominic Ferrando
2025-04-24 23:39:29 -04:00
parent 723e9257d2
commit 768f0cec61
8 changed files with 22 additions and 25 deletions
+7 -4
View File
@@ -75,10 +75,8 @@ func main() {
dataDir = "." // for development
}
log.Println("DATADIR: ", dataDir)
util.POST_MEDIA_FULL_PATH = filepath.Join(dataDir, util.POST_MEDIA_FULL_PATH)
util.POST_MEDIA_THUMB_PATH = filepath.Join(dataDir, util.POST_MEDIA_FULL_PATH)
util.POST_MEDIA_THUMB_PATH = filepath.Join(dataDir, util.POST_MEDIA_THUMB_PATH)
util.DATABASE_PATH = filepath.Join(dataDir, util.DATABASE_PATH)
util.STATIC_PATH = filepath.Join(dataDir, util.STATIC_PATH)
@@ -94,9 +92,14 @@ func main() {
r.Handle("/static/*",
disableCacheInDevMode(
http.StripPrefix("/static",
http.StripPrefix("/static/",
http.FileServer(http.Dir(util.STATIC_PATH)))))
r.Handle("/media/*",
disableCacheInDevMode(
http.StripPrefix("/media/",
http.FileServer(http.Dir(filepath.Join(dataDir, "media"))))))
// -----------------
// -----------------
+3 -3
View File
@@ -44,7 +44,7 @@ function togglePostFile(el) {
const vidEl = imgEl.parentElement.querySelector("video");
const closeVidBtn = imgEl.parentElement.querySelector(".link-button");
if (vidEl.style.display === "none") {
vidEl.src = "/static/media/posts/full/" + imgEl.dataset.full;
vidEl.src = "/media/posts/full/" + imgEl.dataset.full;
vidEl.style.display = "";
imgEl.style.display = "none";
closeVidBtn.style.display = "";
@@ -59,11 +59,11 @@ function togglePostFile(el) {
else {
if (imgEl.classList.contains("post-img-full")) {
imgEl.classList.remove("post-img-full");
imgEl.src = "/static/media/posts/thumb/" + imgEl.dataset.thumb;
imgEl.src = "/media/posts/thumb/" + imgEl.dataset.thumb;
}
else {
imgEl.classList.add("post-img-full");
imgEl.src = "/static/media/posts/full/" + imgEl.dataset.full;
imgEl.src = "/media/posts/full/" + imgEl.dataset.full;
}
}
}
+1 -1
View File
@@ -92,7 +92,7 @@ templ ThreadsCatalog(previews []CatalogThreadPreview, catalogContext CatalogCont
<img
loading="lazy"
class="catalog-preview-img"
src={ fmt.Sprintf("/static/media/posts/thumb/%s",
src={ fmt.Sprintf("/media/posts/thumb/%s",
preview.ThumbPath) }
/>
</a>
+4 -4
View File
@@ -76,7 +76,7 @@ templ PostOriginal(post database.Post, thread database.Thread) {
style=" display: none;"
>[close]</span>
File:
<a href={ templ.URL("/static/media/posts/full/" + post.MediaPath) } class="post-filename">
<a href={ templ.URL("/media/posts/full/" + post.MediaPath) } class="post-filename">
{ post.MediaPath }
</a>
<div class="post-img-info">
@@ -86,7 +86,7 @@ templ PostOriginal(post database.Post, thread database.Thread) {
<img
onclick="togglePostFile(this)"
loading="lazy"
src={ fmt.Sprintf("/static/media/posts/thumb/%s", post.ThumbPath) }
src={ fmt.Sprintf("/media/posts/thumb/%s", post.ThumbPath) }
data-full={ post.MediaPath }
data-thumb={ post.ThumbPath }
class="post-img"
@@ -159,7 +159,7 @@ templ PostReply(post database.Post, threadContext ThreadContext) {
style=" display: none;"
>[close]</span>
File:
<a href={ templ.URL("/static/media/posts/full/" + post.MediaPath) } class="post-filename">
<a href={ templ.URL("/media/posts/full/" + post.MediaPath) } class="post-filename">
{ post.MediaPath }
</a>
<div class="post-img-info">
@@ -169,7 +169,7 @@ templ PostReply(post database.Post, threadContext ThreadContext) {
<img
onclick="togglePostFile(this)"
loading="lazy"
src={ fmt.Sprintf("/static/media/posts/thumb/%s",
src={ fmt.Sprintf("/media/posts/thumb/%s",
post.ThumbPath) }
data-full={ post.MediaPath }
data-thumb={ post.ThumbPath }