diff --git a/README.md b/README.md index a505d2fc..852d5a22 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,8 @@ Usage yt-dlp-webui: session file path (default ".") -user string Username required for auth + -web string + frontend web resources path ``` ### Config file @@ -197,6 +199,9 @@ queue_size: 4 # min. 2 # [optional] Path where the sqlite database will be created/opened (default: "./local.db") #local_database_path + +# [optional] Path where a custom frontend will be loaded (instead of the embedded one) +#frontend_path: ./web/solid-frontend ``` ### Systemd integration @@ -262,6 +267,22 @@ It is **planned** to also expose a **gRPC** server. For more information open an issue on GitHub and I will provide more info ASAP. +## Custom frontend +To load a custom frontend you need to specify its path either in the config file ([see config file](#config-file)) or via flags. + +The frontend needs to follow this structure: +``` +path/to/my/frontend +├── assets +│ ├── js-chunk-1.js (example) +│ ├── js-chunk-2.js (example) +│ ├── style.css (example) +└── index.html +``` + +`assets` is where the resources will be loaded. +`index.html` is the entrypoint. + ## Nix This repo adds support for Nix(OS) in various ways through a `flake-parts` flake. For more info, please refer to the [official documentation](https://nixos.org/learn/). diff --git a/main.go b/main.go index 5647ec02..ca361b05 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ var ( downloaderPath string sessionFilePath string localDatabasePath string + frontendPath string requireAuth bool username string @@ -52,6 +53,7 @@ func init() { flag.StringVar(&downloaderPath, "driver", "yt-dlp", "yt-dlp executable path") flag.StringVar(&sessionFilePath, "session", ".", "session file path") flag.StringVar(&localDatabasePath, "db", "local.db", "local database path") + flag.StringVar(&frontendPath, "web", "", "frontend web resources path") flag.BoolVar(&enableFileLogging, "fl", false, "enable outputting logs to a file") flag.StringVar(&logFile, "lf", "yt-dlp-webui.log", "set log file location") @@ -69,6 +71,10 @@ func main() { log.Fatalln(err) } + if frontendPath != "" { + frontend = os.DirFS(frontendPath) + } + c := config.Instance() { diff --git a/server/config/config.go b/server/config/config.go index dff680d4..c36f3f46 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -9,26 +9,26 @@ import ( ) type Config struct { - LogPath string `yaml:"log_path"` - EnableFileLogging bool `yaml:"enable_file_logging"` - BaseURL string `yaml:"base_url"` - Host string `yaml:"host"` - Port int `yaml:"port"` - DownloadPath string `yaml:"downloadPath"` - DownloaderPath string `yaml:"downloaderPath"` - RequireAuth bool `yaml:"require_auth"` - Username string `yaml:"username"` - Password string `yaml:"password"` - QueueSize int `yaml:"queue_size"` - LocalDatabasePath string `yaml:"local_database_path"` - SessionFilePath string `yaml:"session_file_path"` - path string - + LogPath string `yaml:"log_path"` + EnableFileLogging bool `yaml:"enable_file_logging"` + BaseURL string `yaml:"base_url"` + Host string `yaml:"host"` + Port int `yaml:"port"` + DownloadPath string `yaml:"downloadPath"` + DownloaderPath string `yaml:"downloaderPath"` + RequireAuth bool `yaml:"require_auth"` + Username string `yaml:"username"` + Password string `yaml:"password"` + QueueSize int `yaml:"queue_size"` + LocalDatabasePath string `yaml:"local_database_path"` + SessionFilePath string `yaml:"session_file_path"` + path string // private UseOpenId bool `yaml:"use_openid"` OpenIdProviderURL string `yaml:"openid_provider_url"` OpenIdClientId string `yaml:"openid_client_id"` OpenIdClientSecret string `yaml:"openid_client_secret"` OpenIdRedirectURL string `yaml:"openid_redirect_url"` + FrontendPath string `yaml:"frontend_path"` } var (