options.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package itashi
  2. import "text/template"
  3. type ShelfHome struct {
  4. Items []Option
  5. Tasks TaskShelf
  6. TaskTempl *template.Template
  7. }
  8. // Return a list of the options as strings for the UI to render
  9. func (s ShelfHome) OptionList() []string {
  10. var optnames []string
  11. for i := range s.Items {
  12. optnames = append(optnames, s.Items[i].Name)
  13. }
  14. return optnames
  15. }
  16. type Option struct {
  17. Name string // the display name in the UI
  18. Template *template.Template // The template to render in the Render() func
  19. }
  20. // Render the template stored in the Template struct field
  21. func (o Option) Render() string {
  22. return "This is a placeholder"
  23. }
  24. // Create the task shelf homepage
  25. func GetShelfHome(save string) ShelfHome {
  26. return ShelfHome{
  27. Items: GetOptions(),
  28. Tasks: NewFilesystemShelf(save),
  29. }
  30. }
  31. // Removing this from GetShelfHome to allow for indirecting the data feed
  32. func GetOptions() []Option {
  33. var opts []Option
  34. opts = append(opts, Option{Name: "Add task to your shelf"})
  35. opts = append(opts, Option{Name: "Edit Task"})
  36. opts = append(opts, Option{Name: "Move task to done pile"})
  37. opts = append(opts, Option{Name: "View my shelf"})
  38. return opts
  39. }