BuildDate, footer styling
This commit is contained in:
@@ -7,7 +7,9 @@ go mod tidy
|
|||||||
```bash
|
```bash
|
||||||
export YTDLP_SITE_ADMIN_INITIAL_PASSWORD=abc123
|
export YTDLP_SITE_ADMIN_INITIAL_PASSWORD=abc123
|
||||||
export YTDLP_SITE_SESSION_AUTH_KEY=v9qpt37hc4qpmhf
|
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
|
## Environment Variables
|
||||||
|
11
config.go
11
config.go
@@ -7,6 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var GitSHA string
|
var GitSHA string
|
||||||
|
var BuildDate string
|
||||||
|
|
||||||
func getDataDir() string {
|
func getDataDir() string {
|
||||||
value, exists := os.LookupEnv("YTDLP_SITE_DATA_DIR")
|
value, exists := os.LookupEnv("YTDLP_SITE_DATA_DIR")
|
||||||
@@ -54,11 +55,17 @@ func getSecure() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getGitSHA() string {
|
func getGitSHA() string {
|
||||||
|
|
||||||
if GitSHA == "" {
|
if GitSHA == "" {
|
||||||
return "<not provided>"
|
return "<not provided>"
|
||||||
} else {
|
} else {
|
||||||
return GitSHA
|
return GitSHA
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getBuildDate() string {
|
||||||
|
if BuildDate == "" {
|
||||||
|
return "<not provided>"
|
||||||
|
} else {
|
||||||
|
return BuildDate
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
16
handlers.go
16
handlers.go
@@ -17,6 +17,18 @@ import (
|
|||||||
"gorm.io/gorm"
|
"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 ytdlpAudioOptions = []string{"-f", "bestvideo[height<=1080]+bestaudio/best[height<=1080]"}
|
||||||
var ytdlpVideoOptions = []string{"-f", "bestaudio"}
|
var ytdlpVideoOptions = []string{"-f", "bestaudio"}
|
||||||
|
|
||||||
@@ -625,7 +637,7 @@ func videosHandler(c echo.Context) error {
|
|||||||
return c.Render(http.StatusOK, "videos.html",
|
return c.Render(http.StatusOK, "videos.html",
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"videos": origs,
|
"videos": origs,
|
||||||
"build_id": getGitSHA(),
|
"Footer": makeFooter(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,7 +764,7 @@ func videoHandler(c echo.Context) error {
|
|||||||
"videos": videoURLs,
|
"videos": videoURLs,
|
||||||
"audios": audioURLs,
|
"audios": audioURLs,
|
||||||
"dataDir": dataDir,
|
"dataDir": dataDir,
|
||||||
"build_id": getGitSHA(),
|
"Footer": makeFooter(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,9 @@
|
|||||||
|
.footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
color: lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer a {
|
||||||
|
color: lightgray;
|
||||||
|
}
|
@@ -1,7 +1,11 @@
|
|||||||
{{define "footer"}}
|
{{define "footer"}}
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
|
<div class="build-date">
|
||||||
|
Build Date: {{.Footer.BuildDate}}
|
||||||
|
</div>
|
||||||
<div class="build-id">
|
<div class="build-id">
|
||||||
Build ID: <a href="https://github.com/cwpearson/ytdlp-site/compare/{{.build_id}}..master">{{.build_id}}</a>
|
Build ID: <a
|
||||||
|
href="https://github.com/cwpearson/ytdlp-site/compare/{{.Footer.BuildId}}..master">{{.Footer.BuildId}}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Reference in New Issue
Block a user