More fixing
This commit is contained in:
+2
-2
@@ -3,8 +3,8 @@ internal/database/comfychan.db
|
||||
tmp
|
||||
out
|
||||
|
||||
web/static/media/posts/
|
||||
web/static/media/posts/
|
||||
media
|
||||
|
||||
# Devenv
|
||||
.devenv*
|
||||
devenv.local.nix
|
||||
|
||||
@@ -19,10 +19,6 @@ db/seed:
|
||||
db/seed/f:
|
||||
rm ./internal/database/comfychan.db && sqlite3 ./internal/database/comfychan.db < ./internal/database/seed.sql
|
||||
|
||||
img/clear:
|
||||
rm -rf ./web/static/media/posts || true
|
||||
|
||||
|
||||
build:
|
||||
go build -o ./out/comfychan ./web
|
||||
|
||||
|
||||
@@ -4,12 +4,10 @@ go 1.23.3
|
||||
|
||||
require (
|
||||
github.com/a-h/templ v0.3.857
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/go-chi/chi/v5 v5.2.1
|
||||
github.com/mattn/go-sqlite3 v1.14.28
|
||||
golang.org/x/crypto v0.37.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/disintegration/imaging v1.6.2 // indirect
|
||||
golang.org/x/crypto v0.37.0 // indirect
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
|
||||
)
|
||||
require golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
|
||||
|
||||
@@ -23,8 +23,8 @@ const FILE_MEM_LIMIT int64 = 10 << 20
|
||||
const MAX_REQUEST_BYTES int64 = FILE_MEM_LIMIT + (1 << 20)
|
||||
|
||||
var (
|
||||
POST_MEDIA_FULL_PATH = "web/static/media/posts/full"
|
||||
POST_MEDIA_THUMB_PATH = "web/static/media/posts/thumb"
|
||||
POST_MEDIA_FULL_PATH = "media/posts/full"
|
||||
POST_MEDIA_THUMB_PATH = "media/posts/thumb"
|
||||
)
|
||||
|
||||
const MAX_THREAD_COUNT = 50
|
||||
|
||||
+7
-4
@@ -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"))))))
|
||||
|
||||
// -----------------
|
||||
|
||||
// -----------------
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user