diff --git a/Dockerfile b/Dockerfile index ea866d24..861a3740 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ RUN apk --no-cache add ca-certificates python3 py3-pip ffmpeg tzdata \ COPY --from=builder /usr/bin/yt-dlp /usr/local/bin/youtube-dl COPY --from=builder /build/bin/podsync /app/podsync +COPY --from=builder /build/html/index.html /app/html/index.html ENTRYPOINT ["/app/podsync"] CMD ["--no-banner"] diff --git a/cmd/podsync/main.go b/cmd/podsync/main.go index 19c68091..f9f8ed92 100644 --- a/cmd/podsync/main.go +++ b/cmd/podsync/main.go @@ -125,9 +125,9 @@ func main() { var storage fs.Storage switch cfg.Storage.Type { case "local": - storage, err = fs.NewLocal(cfg.Storage.Local.DataDir) + storage, err = fs.NewLocal(cfg.Storage.Local.DataDir, cfg.Server.WebUIEnabled) case "s3": - storage, err = fs.NewS3(cfg.Storage.S3) + storage, err = fs.NewS3(cfg.Storage.S3) // serving files from S3 is not supported, so no WebUI either default: log.Fatalf("unknown storage type: %s", cfg.Storage.Type) } diff --git a/config.toml.example b/config.toml.example index 611a8c46..539735f3 100644 --- a/config.toml.example +++ b/config.toml.example @@ -17,6 +17,8 @@ hostname = "https://my.test.host:4443" bind_address = "172.20.10.2" # Specify path for reverse proxy and only [A-Za-z0-9] path = "test" +# Optional. Enable Web UI. Feeds have to be include in OPML file to appear (see below) +web_ui = true # Optional. If you want to use TLS you must set the TLS flag and path to the certificate file and private key file. tls = true certificate_path = "/var/www/cert.pem" diff --git a/html/index.html b/html/index.html new file mode 100755 index 00000000..e7846dda --- /dev/null +++ b/html/index.html @@ -0,0 +1,776 @@ + + + + + + Podsync + + + + + + + + + +
+ +
+
+

+ + Latest Episodes +

+
+
+ + +
+
+

Loading episodes from feeds...

+
+ + + + + +
+ +
+
+ + + + + + + + diff --git a/pkg/fs/local.go b/pkg/fs/local.go index 8fef7106..4046f5c1 100644 --- a/pkg/fs/local.go +++ b/pkg/fs/local.go @@ -18,14 +18,18 @@ type LocalConfig struct { // Local implements local file storage type Local struct { - rootDir string + rootDir string + WebUIEnabled bool } -func NewLocal(rootDir string) (*Local, error) { - return &Local{rootDir: rootDir}, nil +func NewLocal(rootDir string, webUIEnabled bool) (*Local, error) { + return &Local{rootDir: rootDir, WebUIEnabled: webUIEnabled}, nil } func (l *Local) Open(name string) (http.File, error) { + if name == "/index.html" && l.WebUIEnabled { + return os.Open("./html/index.html") + } path := filepath.Join(l.rootDir, name) return os.Open(path) } diff --git a/pkg/fs/local_test.go b/pkg/fs/local_test.go index 4329886e..9157450f 100644 --- a/pkg/fs/local_test.go +++ b/pkg/fs/local_test.go @@ -15,7 +15,7 @@ var ( ) func TestNewLocal(t *testing.T) { - local, err := NewLocal("") + local, err := NewLocal("", false) assert.NoError(t, err) assert.NotNil(t, local) } @@ -24,7 +24,7 @@ func TestLocal_Create(t *testing.T) { tmpDir, err := os.MkdirTemp("", "") assert.NoError(t, err) - stor, err := NewLocal(tmpDir) + stor, err := NewLocal(tmpDir, false) assert.NoError(t, err) written, err := stor.Create(testCtx, "1/test", bytes.NewBuffer([]byte{1, 5, 7, 8, 3})) @@ -42,7 +42,7 @@ func TestLocal_Size(t *testing.T) { defer os.RemoveAll(tmpDir) - stor, err := NewLocal(tmpDir) + stor, err := NewLocal(tmpDir, false) assert.NoError(t, err) _, err = stor.Create(testCtx, "1/test", bytes.NewBuffer([]byte{1, 5, 7, 8, 3})) @@ -54,7 +54,7 @@ func TestLocal_Size(t *testing.T) { } func TestLocal_NoSize(t *testing.T) { - stor, err := NewLocal("") + stor, err := NewLocal("", false) assert.NoError(t, err) _, err = stor.Size(testCtx, "1/test") @@ -65,7 +65,7 @@ func TestLocal_Delete(t *testing.T) { tmpDir, err := os.MkdirTemp("", "") assert.NoError(t, err) - stor, err := NewLocal(tmpDir) + stor, err := NewLocal(tmpDir, false) assert.NoError(t, err) _, err = stor.Create(testCtx, "1/test", bytes.NewBuffer([]byte{1, 5, 7, 8, 3})) diff --git a/services/web/server.go b/services/web/server.go index ee6eb1c5..211bf9b5 100644 --- a/services/web/server.go +++ b/services/web/server.go @@ -31,6 +31,8 @@ type Config struct { // DataDir is a path to a directory to keep XML feeds and downloaded episodes, // that will be available to user via web server for download. DataDir string `toml:"data_dir"` + // WebUIEnabled is a flag indicating if web UI is enabled + WebUIEnabled bool `toml:"web_ui"` } func New(cfg Config, storage http.FileSystem) *Server {