path fixing
This commit is contained in:
@@ -22,8 +22,10 @@ import (
|
|||||||
const FILE_MEM_LIMIT int64 = 10 << 20
|
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)
|
||||||
|
|
||||||
const POST_MEDIA_FULL_PATH = "web/static/media/posts/full"
|
var (
|
||||||
const POST_MEDIA_THUMB_PATH = "web/static/media/posts/thumb"
|
POST_MEDIA_FULL_PATH = "web/static/media/posts/full"
|
||||||
|
POST_MEDIA_THUMB_PATH = "web/static/media/posts/thumb"
|
||||||
|
)
|
||||||
|
|
||||||
const MAX_THREAD_COUNT = 50
|
const MAX_THREAD_COUNT = 50
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ import (
|
|||||||
|
|
||||||
const DevMode = false
|
const DevMode = false
|
||||||
|
|
||||||
|
var (
|
||||||
|
STATIC_PATH = "web/static"
|
||||||
|
DATABASE_PATH = "internal/database/comfychan.db"
|
||||||
|
)
|
||||||
|
|
||||||
func FormatBytes(bytes int64) string {
|
func FormatBytes(bytes int64) string {
|
||||||
const (
|
const (
|
||||||
KB = 1 << 10 // 1024
|
KB = 1 << 10 // 1024
|
||||||
|
|||||||
+23
-9
@@ -4,6 +4,16 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"mime/multipart"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dominicf2001/comfychan/internal/database"
|
"github.com/dominicf2001/comfychan/internal/database"
|
||||||
"github.com/dominicf2001/comfychan/internal/util"
|
"github.com/dominicf2001/comfychan/internal/util"
|
||||||
"github.com/dominicf2001/comfychan/web/views"
|
"github.com/dominicf2001/comfychan/web/views"
|
||||||
@@ -12,14 +22,6 @@ import (
|
|||||||
"github.com/go-chi/chi/v5/middleware"
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"mime/multipart"
|
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func AdminOnlyMiddleware(next http.Handler) http.Handler {
|
func AdminOnlyMiddleware(next http.Handler) http.Handler {
|
||||||
@@ -66,6 +68,18 @@ func main() {
|
|||||||
// SETUP
|
// SETUP
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
|
// init paths
|
||||||
|
|
||||||
|
dataDir := os.Getenv("COMFYCHAN_DATA_DIR")
|
||||||
|
if dataDir == "" {
|
||||||
|
dataDir = "." // for development
|
||||||
|
}
|
||||||
|
|
||||||
|
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.DATABASE_PATH = filepath.Join(dataDir, util.DATABASE_PATH)
|
||||||
|
util.STATIC_PATH = filepath.Join(dataDir, util.STATIC_PATH)
|
||||||
|
|
||||||
db, err := sql.Open("sqlite3", "internal/database/comfychan.db")
|
db, err := sql.Open("sqlite3", "internal/database/comfychan.db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@@ -79,7 +93,7 @@ func main() {
|
|||||||
r.Handle("/static/*",
|
r.Handle("/static/*",
|
||||||
disableCacheInDevMode(
|
disableCacheInDevMode(
|
||||||
http.StripPrefix("/static",
|
http.StripPrefix("/static",
|
||||||
http.FileServer(http.Dir("web/static")))))
|
http.FileServer(http.Dir(util.STATIC_PATH)))))
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user