Initial implementation
This commit is contained in:
30
internal/models/photo.go
Normal file
30
internal/models/photo.go
Normal file
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user