Files
fnx_web/webcontroller/opengraph.go

39 lines
982 B
Go
Raw Normal View History

2017-12-17 18:10:59 +01:00
package webcontroller
import (
"fornaxian.com/pixeldrain-web/pixelapi"
)
// OGData holds all information needed to populate the various meta tags on the
// file and list viewer
type OGData struct {
Title string
Type string
SiteName string
Description string
URL string
Image string
}
// OpenGraphFromFile populates the OGData object from FileInfo
func OpenGraphFromFile(f pixelapi.FileInfo) (og OGData) {
og.Title = f.Name
og.Type = "website"
og.SiteName = "Pixeldrain"
og.Description = "View " + f.Name + " on Pixeldrain"
og.URL = "/u/" + f.ID
og.Image = "/api/file/" + f.ID + "/thumbnail"
return og
2017-12-17 18:10:59 +01:00
}
// OpenGraphFromList populates the OGData object from a List
func OpenGraphFromList(l pixelapi.List) (og OGData) {
og.Title = l.Title
og.Type = "website"
og.SiteName = "Pixeldrain"
og.Description = "View " + l.Title + " on Pixeldrain"
og.URL = "/l/" + l.ID
og.Image = "/api/file/" + l.Files[0].ID + "/thumbnail"
return og
2017-12-17 18:10:59 +01:00
}