31 lines
676 B
Go
31 lines
676 B
Go
package models
|
|
|
|
import (
|
|
"path/filepath"
|
|
"time"
|
|
)
|
|
|
|
// Photo represents a photo with its metadata.
|
|
type Photo struct {
|
|
Date time.Time
|
|
Year string
|
|
Filename string
|
|
Description string
|
|
FullPath string
|
|
}
|
|
|
|
// DateString returns the date formatted as YYYY-MM-DD.
|
|
func (p *Photo) DateString() string {
|
|
return p.Date.Format("2006-01-02")
|
|
}
|
|
|
|
// URLPath returns the URL path to access this photo.
|
|
func (p *Photo) URLPath() string {
|
|
return filepath.Join("/photos", p.Year, p.Filename)
|
|
}
|
|
|
|
// ThumbURLPath returns the URL path to access this photo's thumbnail.
|
|
func (p *Photo) ThumbURLPath() string {
|
|
return filepath.Join("/photos/thumb", p.Year, p.Filename)
|
|
}
|