summaryrefslogtreecommitdiff
path: root/page.go
diff options
context:
space:
mode:
Diffstat (limited to 'page.go')
-rw-r--r--page.go40
1 files changed, 29 insertions, 11 deletions
diff --git a/page.go b/page.go
index c3ab160..bae3e7c 100644
--- a/page.go
+++ b/page.go
@@ -4,31 +4,50 @@ type Service struct {
Db Database
}
+type DateInfo struct {
+ Date string
+ Tomorrow string
+ Yesterday string
+}
+
type EntryPage struct {
- Entry *Entry
+ Entry *Entry
Detached bool
Tracking *Entry
}
type RootPage struct {
- Entry *EntryPage
+ Entry *EntryPage
Entries []*Entry
}
+type TasksPage struct {
+ Tasks []*Task
+}
+
func NewService(db Database) *Service {
- return &Service {
+ return &Service{
Db: db,
}
}
+func (srv *Service) GetTasksPage() (*TasksPage, error) {
+ tasks, err := srv.Db.GetTasks()
+ if err != nil {
+ return nil, err
+ }
+ return &TasksPage{
+ Tasks: tasks,
+ }, nil
+}
func (srv *Service) GetEntryPage(detached *Entry) (*EntryPage, error) {
tracking, err := srv.Db.GetTracking()
if err != nil {
return nil, err
}
-
- page := &EntryPage {
- Entry: tracking,
+
+ page := &EntryPage{
+ Entry: tracking,
Detached: false,
Tracking: tracking,
}
@@ -38,7 +57,6 @@ func (srv *Service) GetEntryPage(detached *Entry) (*EntryPage, error) {
page.Detached = true
}
-
return page, nil
}
@@ -47,13 +65,13 @@ func (srv *Service) GetRootPage() (*RootPage, error) {
if err != nil {
return nil, err
}
- tasks, err := srv.Db.GetTasks()
+ entries, err := srv.Db.GetEntries()
if err != nil {
return nil, err
}
- return &RootPage {
- Entry: entry,
- Entries: tasks,
+ return &RootPage{
+ Entry: entry,
+ Entries: entries,
}, nil
}