blog_post.go 713 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package fetdata
  2. import (
  3. "html/template"
  4. "time"
  5. )
  6. type BlogPost struct {
  7. id int
  8. user int
  9. name string
  10. alias string
  11. content string
  12. datetime int
  13. active int
  14. }
  15. func (this *BlogPost) Id() int {
  16. return this.id
  17. }
  18. func (this *BlogPost) Name() string {
  19. return this.name
  20. }
  21. func (this *BlogPost) Alias() string {
  22. return this.alias
  23. }
  24. func (this *BlogPost) Permalink() string {
  25. return "/blog/" + this.alias + "/"
  26. }
  27. func (this *BlogPost) Content() template.HTML {
  28. return template.HTML(this.content)
  29. }
  30. func (this *BlogPost) DateTime() int {
  31. return this.datetime
  32. }
  33. func (this *BlogPost) DateTimeFormat(format string) string {
  34. return time.Unix(int64(this.datetime), 0).Format(format)
  35. }