diff --git a/README.md b/README.md index 52d0864..4d5ceb2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ go mod tidy ```bash export YTDLP_SITE_ADMIN_INITIAL_PASSWORD=abc123 export YTDLP_SITE_SESSION_AUTH_KEY=v9qpt37hc4qpmhf -go run *.go +go run \ + -ldflags "-X main.GitSHA=$(git rev-parse HEAD)" -ldflags "-X main.BuilDate=$(date)" \ + *.go ``` ## Environment Variables diff --git a/config.go b/config.go index 9318e8c..0c1679b 100644 --- a/config.go +++ b/config.go @@ -7,6 +7,7 @@ import ( ) var GitSHA string +var BuildDate string func getDataDir() string { value, exists := os.LookupEnv("YTDLP_SITE_DATA_DIR") @@ -54,11 +55,17 @@ func getSecure() bool { } func getGitSHA() string { - if GitSHA == "" { return "" } else { return GitSHA } - +} + +func getBuildDate() string { + if BuildDate == "" { + return "" + } else { + return BuildDate + } } diff --git a/handlers.go b/handlers.go index f5a04b2..18cf67f 100644 --- a/handlers.go +++ b/handlers.go @@ -17,6 +17,18 @@ import ( "gorm.io/gorm" ) +type Footer struct { + BuildDate string + BuildId string +} + +func makeFooter() Footer { + return Footer{ + BuildDate: getBuildDate(), + BuildId: getGitSHA(), + } +} + var ytdlpAudioOptions = []string{"-f", "bestvideo[height<=1080]+bestaudio/best[height<=1080]"} var ytdlpVideoOptions = []string{"-f", "bestaudio"} @@ -624,8 +636,8 @@ func videosHandler(c echo.Context) error { db.Where("user_id = ?", userID).Find(&origs) return c.Render(http.StatusOK, "videos.html", map[string]interface{}{ - "videos": origs, - "build_id": getGitSHA(), + "videos": origs, + "Footer": makeFooter(), }) } @@ -752,7 +764,7 @@ func videoHandler(c echo.Context) error { "videos": videoURLs, "audios": audioURLs, "dataDir": dataDir, - "build_id": getGitSHA(), + "Footer": makeFooter(), }) } diff --git a/static/style/footer.css b/static/style/footer.css index e69de29..19ef0b6 100644 --- a/static/style/footer.css +++ b/static/style/footer.css @@ -0,0 +1,9 @@ +.footer { + display: flex; + justify-content: space-evenly; + color: lightgray; +} + +.footer a { + color: lightgray; +} \ No newline at end of file diff --git a/templates/footer.html b/templates/footer.html index 6b28394..7e318d2 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,7 +1,11 @@ {{define "footer"}} {{end}}