All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m52s
- Register a new route `GET /d/{boxID}/scene/{fileID}` to serve video scene previews.
- Implement the `VideoScenesPreview` handler to serve existing previews or generate them on-demand.
- Add helper functions to analyze video frames (e.g., luma calculation to filter out dark frames) and render the final scene thumbnail.
- Update the `fileView` struct to include scene URL and status fields.
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package handlers
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// RobotsTxt serves /robots.txt dynamically so the Sitemap URL reflects the
|
|
// configured base URL rather than a hard-coded placeholder.
|
|
func (a *App) RobotsTxt(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
|
w.Header().Set("Cache-Control", "public, max-age=86400")
|
|
fmt.Fprintf(w, `User-agent: *
|
|
Allow: /
|
|
|
|
# Private routes — do not crawl
|
|
Disallow: /admin/
|
|
Disallow: /api/
|
|
Disallow: /app/
|
|
Disallow: /account/
|
|
Disallow: /d/*/f/*/download
|
|
Disallow: /d/*/zip
|
|
Disallow: /d/*/thumb/
|
|
Disallow: /d/*/scene/
|
|
Disallow: /d/*/og-image.jpg
|
|
Disallow: /d/*/unlock
|
|
Disallow: /d/*/manage/
|
|
|
|
Sitemap: %s/sitemap.xml
|
|
`, strings.TrimRight(siteBaseURL(r, a.cfg.BaseURL), "/"))
|
|
}
|
|
|
|
// SitemapXML serves a minimal /sitemap.xml containing only the public,
|
|
// indexable homepage. Box/file pages are noindex and deliberately excluded.
|
|
func (a *App) SitemapXML(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/xml; charset=utf-8")
|
|
w.Header().Set("Cache-Control", "public, max-age=3600")
|
|
baseURL := strings.TrimRight(siteBaseURL(r, a.cfg.BaseURL), "/")
|
|
lastMod := time.Now().UTC().Format("2006-01-02")
|
|
fmt.Fprintf(w, `<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
<url>
|
|
<loc>%s/</loc>
|
|
<lastmod>%s</lastmod>
|
|
<changefreq>weekly</changefreq>
|
|
<priority>1.0</priority>
|
|
</url>
|
|
</urlset>
|
|
`, baseURL, lastMod)
|
|
}
|
|
|
|
func siteBaseURL(r *http.Request, configured string) string {
|
|
if configured != "" {
|
|
return configured
|
|
}
|
|
return absoluteURL(r, "/")
|
|
}
|