Skip to content

Commit

Permalink
custom path based frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopiovanello committed Dec 5, 2024
1 parent 0946d37 commit 8a82e51
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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/).
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
downloaderPath string
sessionFilePath string
localDatabasePath string
frontendPath string

requireAuth bool
username string
Expand Down Expand Up @@ -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")
Expand All @@ -69,6 +71,10 @@ func main() {
log.Fatalln(err)
}

if frontendPath != "" {
frontend = os.DirFS(frontendPath)
}

c := config.Instance()

{
Expand Down
30 changes: 15 additions & 15 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 8a82e51

Please sign in to comment.