31 lines
442 B
Go
31 lines
442 B
Go
package sriracha
|
|
|
|
import "io"
|
|
|
|
type Post struct {
|
|
ID int
|
|
Thread int
|
|
Name string
|
|
Email string
|
|
Subject string
|
|
Message string
|
|
}
|
|
|
|
type renderPostData struct {
|
|
Post *Post
|
|
BaseURL string
|
|
}
|
|
|
|
func (p *Post) render(w io.Writer) error {
|
|
return templates.ExecuteTemplate(w, "post.gohtml", renderPostData{
|
|
Post: p,
|
|
BaseURL: "/",
|
|
})
|
|
}
|
|
|
|
func (p *Post) ThreadID() int {
|
|
if p.Thread == 0 {
|
|
return p.ID
|
|
}
|
|
return p.Thread
|
|
}
|