contented: move flag parsing, consts into block declaration

This commit is contained in:
mappu 2023-05-19 19:04:50 +12:00
parent 5ce06d6e6b
commit 77a4061cdd
2 changed files with 18 additions and 13 deletions

View File

@ -20,9 +20,12 @@ var staticAssets embed.FS
var SERVER_HEADER string = `contented/0.0.0-dev` var SERVER_HEADER string = `contented/0.0.0-dev`
const DEFAULT_MAX_CONCURRENT_THUMBS = 16 const (
DEFAULT_MAX_CONCURRENT_THUMBS = 16
const ALBUM_MIMETYPE = `contented/album` ALBUM_MIMETYPE = `contented/album`
)
type ServerPublicProperties struct { type ServerPublicProperties struct {
AppTitle string AppTitle string

View File

@ -12,17 +12,19 @@ import (
func main() { func main() {
cwd, _ := os.Getwd() cwd, _ := os.Getwd()
listenAddr := flag.String("listen", "127.0.0.1:80", "IP/Port to bind server") var (
dataDir := flag.String("data", cwd, "Directory for stored content") listenAddr = flag.String("listen", "127.0.0.1:80", "IP/Port to bind server")
dbPath := flag.String("db", "contented.db", "Path for metadata database") dataDir = flag.String("data", cwd, "Directory for stored content")
appTitle := flag.String("title", "contented", "Title used in web interface") dbPath = flag.String("db", "contented.db", "Path for metadata database")
maxUploadMb := flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)") appTitle = flag.String("title", "contented", "Title used in web interface")
maxUploadSpeed := flag.Int("speed", 0, "Maximum upload speed in bytes/sec (set zero for unlimited)") maxUploadMb = flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)")
trustXForwardedFor := flag.Bool("trustXForwardedFor", false, "Trust X-Forwarded-For reverse proxy headers") maxUploadSpeed = flag.Int("speed", 0, "Maximum upload speed in bytes/sec (set zero for unlimited)")
enableHomepage := flag.Bool("enableHomepage", true, "Enable homepage (disable for embedded use only)") trustXForwardedFor = flag.Bool("trustXForwardedFor", false, "Trust X-Forwarded-For reverse proxy headers")
enableUpload := flag.Bool("enableUpload", true, "Enable uploads (disable for read-only mode)") enableHomepage = flag.Bool("enableHomepage", true, "Enable homepage (disable for embedded use only)")
diskFilesWorldReadable := flag.Bool("diskFilesWorldReadable", false, "Save files as 0644 instead of 0600") enableUpload = flag.Bool("enableUpload", true, "Enable uploads (disable for read-only mode)")
maxConcurrentThumbs := flag.Int("concurrentthumbs", contented.DEFAULT_MAX_CONCURRENT_THUMBS, "Simultaneous thumbnail generation") diskFilesWorldReadable = flag.Bool("diskFilesWorldReadable", false, "Save files as 0644 instead of 0600")
maxConcurrentThumbs = flag.Int("concurrentthumbs", contented.DEFAULT_MAX_CONCURRENT_THUMBS, "Simultaneous thumbnail generation")
)
flag.Parse() flag.Parse()