More fixing
This commit is contained in:
+2
-2
@@ -3,8 +3,8 @@ internal/database/comfychan.db
|
|||||||
tmp
|
tmp
|
||||||
out
|
out
|
||||||
|
|
||||||
web/static/media/posts/
|
media
|
||||||
web/static/media/posts/
|
|
||||||
# Devenv
|
# Devenv
|
||||||
.devenv*
|
.devenv*
|
||||||
devenv.local.nix
|
devenv.local.nix
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ db/seed:
|
|||||||
db/seed/f:
|
db/seed/f:
|
||||||
rm ./internal/database/comfychan.db && sqlite3 ./internal/database/comfychan.db < ./internal/database/seed.sql
|
rm ./internal/database/comfychan.db && sqlite3 ./internal/database/comfychan.db < ./internal/database/seed.sql
|
||||||
|
|
||||||
img/clear:
|
|
||||||
rm -rf ./web/static/media/posts || true
|
|
||||||
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o ./out/comfychan ./web
|
go build -o ./out/comfychan ./web
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ go 1.23.3
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/a-h/templ v0.3.857
|
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/go-chi/chi/v5 v5.2.1
|
||||||
github.com/mattn/go-sqlite3 v1.14.28
|
github.com/mattn/go-sqlite3 v1.14.28
|
||||||
|
golang.org/x/crypto v0.37.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ const FILE_MEM_LIMIT int64 = 10 << 20
|
|||||||
const MAX_REQUEST_BYTES int64 = FILE_MEM_LIMIT + (1 << 20)
|
const MAX_REQUEST_BYTES int64 = FILE_MEM_LIMIT + (1 << 20)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
POST_MEDIA_FULL_PATH = "web/static/media/posts/full"
|
POST_MEDIA_FULL_PATH = "media/posts/full"
|
||||||
POST_MEDIA_THUMB_PATH = "web/static/media/posts/thumb"
|
POST_MEDIA_THUMB_PATH = "media/posts/thumb"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MAX_THREAD_COUNT = 50
|
const MAX_THREAD_COUNT = 50
|
||||||
|
|||||||
+7
-4
@@ -75,10 +75,8 @@ func main() {
|
|||||||
dataDir = "." // for development
|
dataDir = "." // for development
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("DATADIR: ", dataDir)
|
|
||||||
|
|
||||||
util.POST_MEDIA_FULL_PATH = filepath.Join(dataDir, util.POST_MEDIA_FULL_PATH)
|
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.DATABASE_PATH = filepath.Join(dataDir, util.DATABASE_PATH)
|
||||||
util.STATIC_PATH = filepath.Join(dataDir, util.STATIC_PATH)
|
util.STATIC_PATH = filepath.Join(dataDir, util.STATIC_PATH)
|
||||||
|
|
||||||
@@ -94,9 +92,14 @@ func main() {
|
|||||||
|
|
||||||
r.Handle("/static/*",
|
r.Handle("/static/*",
|
||||||
disableCacheInDevMode(
|
disableCacheInDevMode(
|
||||||
http.StripPrefix("/static",
|
http.StripPrefix("/static/",
|
||||||
http.FileServer(http.Dir(util.STATIC_PATH)))))
|
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 vidEl = imgEl.parentElement.querySelector("video");
|
||||||
const closeVidBtn = imgEl.parentElement.querySelector(".link-button");
|
const closeVidBtn = imgEl.parentElement.querySelector(".link-button");
|
||||||
if (vidEl.style.display === "none") {
|
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 = "";
|
vidEl.style.display = "";
|
||||||
imgEl.style.display = "none";
|
imgEl.style.display = "none";
|
||||||
closeVidBtn.style.display = "";
|
closeVidBtn.style.display = "";
|
||||||
@@ -59,11 +59,11 @@ function togglePostFile(el) {
|
|||||||
else {
|
else {
|
||||||
if (imgEl.classList.contains("post-img-full")) {
|
if (imgEl.classList.contains("post-img-full")) {
|
||||||
imgEl.classList.remove("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 {
|
else {
|
||||||
imgEl.classList.add("post-img-full");
|
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
|
<img
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class="catalog-preview-img"
|
class="catalog-preview-img"
|
||||||
src={ fmt.Sprintf("/static/media/posts/thumb/%s",
|
src={ fmt.Sprintf("/media/posts/thumb/%s",
|
||||||
preview.ThumbPath) }
|
preview.ThumbPath) }
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ templ PostOriginal(post database.Post, thread database.Thread) {
|
|||||||
style=" display: none;"
|
style=" display: none;"
|
||||||
>[close]</span>
|
>[close]</span>
|
||||||
File:
|
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 }
|
{ post.MediaPath }
|
||||||
</a>
|
</a>
|
||||||
<div class="post-img-info">
|
<div class="post-img-info">
|
||||||
@@ -86,7 +86,7 @@ templ PostOriginal(post database.Post, thread database.Thread) {
|
|||||||
<img
|
<img
|
||||||
onclick="togglePostFile(this)"
|
onclick="togglePostFile(this)"
|
||||||
loading="lazy"
|
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-full={ post.MediaPath }
|
||||||
data-thumb={ post.ThumbPath }
|
data-thumb={ post.ThumbPath }
|
||||||
class="post-img"
|
class="post-img"
|
||||||
@@ -159,7 +159,7 @@ templ PostReply(post database.Post, threadContext ThreadContext) {
|
|||||||
style=" display: none;"
|
style=" display: none;"
|
||||||
>[close]</span>
|
>[close]</span>
|
||||||
File:
|
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 }
|
{ post.MediaPath }
|
||||||
</a>
|
</a>
|
||||||
<div class="post-img-info">
|
<div class="post-img-info">
|
||||||
@@ -169,7 +169,7 @@ templ PostReply(post database.Post, threadContext ThreadContext) {
|
|||||||
<img
|
<img
|
||||||
onclick="togglePostFile(this)"
|
onclick="togglePostFile(this)"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
src={ fmt.Sprintf("/static/media/posts/thumb/%s",
|
src={ fmt.Sprintf("/media/posts/thumb/%s",
|
||||||
post.ThumbPath) }
|
post.ThumbPath) }
|
||||||
data-full={ post.MediaPath }
|
data-full={ post.MediaPath }
|
||||||
data-thumb={ post.ThumbPath }
|
data-thumb={ post.ThumbPath }
|
||||||
|
|||||||
Reference in New Issue
Block a user