diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-06-29 07:09:43 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-06-29 07:09:43 +0000 |
| commit | dacb710fc4ea63baa05cc47016def3849b9db5fa (patch) | |
| tree | cc86831a3a9c950ec0909975ce77bdb485cf5589 /internal/handlers | |
| parent | 3b632feb80a1d6c95836981aad602e2dff4f6b63 (diff) | |
feat: add standalone task detail page for Android widget deep-links
Adds GET /task?id=xxx&source=xxx route that renders a full mobile-friendly
task detail page (session-protected). Widget task rows now open this page
when tapped. HandleUpdateTask redirects back to the page after a non-HTMX
save. Android: threads serverUrl through composable chain to TaskRow.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/handlers')
| -rw-r--r-- | internal/handlers/handlers.go | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 19d26be..0903cf3 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -814,6 +814,58 @@ func (h *Handler) HandleGetTaskDetail(w http.ResponseWriter, r *http.Request) { }{title, id, source, description}) } +// HandleTaskDetailPage renders a standalone full-page task detail view (used by Android widget deep-links). +func (h *Handler) HandleTaskDetailPage(w http.ResponseWriter, r *http.Request) { + id := r.URL.Query().Get("id") + source := r.URL.Query().Get("source") + + if id == "" || source == "" { + http.Error(w, "Missing id or source", http.StatusBadRequest) + return + } + + var title, description string + switch source { + case "todoist": + if tasks, err := h.store.GetTasks(); err == nil { + for _, t := range tasks { + if t.ID == id { + title, description = t.Content, t.Description + break + } + } + } + case "trello": + if boards, err := h.store.GetBoards(); err == nil { + for _, b := range boards { + for _, c := range b.Cards { + if c.ID == id { + title = c.Name + break + } + } + } + } + } + + if title == "" { + title = "Task" + } + + data := struct { + Title string + ID string + Source string + Description string + CSRFToken string + Saved bool + }{title, id, source, description, auth.GetCSRFTokenFromContext(r.Context()), r.URL.Query().Get("saved") == "1"} + + if err := h.renderer.Render(w, "task-detail-page.html", data); err != nil { + http.Error(w, "Failed to render template", http.StatusInternalServerError) + } +} + // HandleUpdateTask updates a task description func (h *Handler) HandleUpdateTask(w http.ResponseWriter, r *http.Request) { if err := r.ParseForm(); err != nil { @@ -846,7 +898,11 @@ func (h *Handler) HandleUpdateTask(w http.ResponseWriter, r *http.Request) { return } - w.WriteHeader(http.StatusOK) + if r.Header.Get("HX-Request") != "" { + w.WriteHeader(http.StatusOK) + } else { + http.Redirect(w, r, "/task?id="+id+"&source="+source+"&saved=1", http.StatusSeeOther) + } } // HandleTabTasks renders the unified Tasks tab (Todoist + Trello cards with due dates + Bugs + Google Tasks) |
