Commit 6c94812
Changed files (5)
cmd/web/handlers.go
@@ -1,6 +1,8 @@
package main
import (
+ "html/template"
+ "log"
"net/http"
"regexp"
)
@@ -14,32 +16,21 @@ func home(w http.ResponseWriter, r *http.Request) {
// submitForm displays the email submission form for scheduling purchase reminders
func submitForm(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Server", "buylater.email")
- w.Header().Add("Content-Type", "text/html; charset=utf-8")
- w.Write([]byte(`
-<!DOCTYPE html>
-<html>
-<head><title>Submit - buylater.email</title></head>
-<body>
- <h1>Schedule Your Purchase Reminder</h1>
- <form action="/submit" method="POST">
- <label for="email">Your Email:</label>
- <input type="email" id="email" name="email" required><br><br>
-
- <label for="url">Product URL:</label>
- <input type="url" id="url" name="url" required><br><br>
-
- <label for="delay">Remind me in:</label>
- <select id="delay" name="delay">
- <option value="3days">3 days</option>
- <option value="1week">1 week</option>
- <option value="2weeks">2 weeks</option>
- <option value="1month">1 month</option>
- </select><br><br>
-
- <button type="submit">Schedule Reminder</button>
- </form>
-</body>
-</html>`))
+
+ // Parse the template file
+ ts, err := template.ParseFiles("./ui/html/pages/submit.tmpl")
+ if err != nil {
+ log.Println(err.Error())
+ http.Error(w, "Internal Server Error", 500)
+ return
+ }
+
+ // Execute the template and write to ResponseWriter
+ err = ts.Execute(w, nil)
+ if err != nil {
+ log.Println(err.Error())
+ http.Error(w, "Internal Server Error", 500)
+ }
}
// processSubmit handles the form submission and schedules the email reminder
docs/rfd/002/README.md
@@ -120,21 +120,16 @@ git diff --staged # Returns empty (no staged changes)
```
Task [X.Y]: [Brief description of changes]
-See: docs/todo/task_[X.Y].md
-
- [Bulleted list of key changes made]
- [Focus on what was implemented/fixed]
-๐ค Generated with [Claude Code](https://claude.ai/code)
-
-Co-Authored-By: Claude <noreply@anthropic.com>
+See: docs/todo/task_[X.Y].md
```
**Commit Message Guidelines:**
- **First line**: Task number and brief description of what was implemented
-- **Second line**: Reference to the detailed task document for full context
- **Body**: Bulleted list of specific changes made during implementation
-- **Footer**: Standard Claude Code attribution and co-authoring
+- **Footer**: Reference to the detailed task document for full context
## Documentation Updates
docs/CLAUDE.md
@@ -26,17 +26,26 @@ This is a Go web application for "buylater.email" - an email-based delayed grati
- Goals: No passwords, no app, no fluff - extremely lightweight and fast
- Target: Profitability at 1,000 users/month with minimal infrastructure
+## Workflow Reminders
+
+**IMPORTANT**: Always follow RFD 002 workflow process:
+1. Create task branch before starting work (`git checkout -b task/X.Y`)
+2. Make incremental commits during development
+3. Follow proper commit message format from RFD 002 (Task X.Y: description, bullets, See: reference)
+4. Request human verification before marking tasks complete
+5. Update project_plan.md status when tasks are completed
+
## Development Commands
### Running the Application
```bash
-go run main.go
+go run cmd/web/*.go
```
The server starts on port 4000.
### Building the Application
```bash
-go build
+go build ./cmd/web
```
### Testing
@@ -63,16 +72,27 @@ go mod download # Download dependencies
## Architecture
### Current Structure
-- **main.go**: Entry point containing a basic HTTP server with three route handlers:
- - `/` - Home page handler
- - `/buygone/view` - View specific BuyGone item
- - `/buygone/create` - Create new BuyGone item form
+```
+buylater/
+โโโ cmd/
+โ โโโ web/
+โ โโโ main.go - Application entry point
+โ โโโ handlers.go - HTTP handler functions
+โโโ internal/ - Internal packages (future)
+โโโ ui/
+โ โโโ html/ - HTML templates
+โ โ โโโ pages/ - Page templates
+โ โโโ static/ - Static assets (future)
+โโโ docs/ - Documentation and RFDs
+โโโ go.mod
+```
### Key Concepts
- The application uses Go's standard `net/http` package for web functionality
-- Currently implements a simple ServeMux for routing
-- All handlers are placeholder implementations that return basic text responses
-- No database, templating, or advanced features implemented yet
+- Follows proper Go project layout with cmd/web structure
+- Uses html/template package for rendering HTML templates
+- Handlers separated from main application logic
+- Template files organized in ui/html directory structure
### Documentation
- `docs/lets-go/` - "Let's Go" tutorial materials for learning Go web development
docs/project_plan.md
@@ -14,6 +14,7 @@ Phase 1 lays the groundwork by methodically working through the Let's Go book, c
| 1.4 | Wildcard Routes and Token Management | Completed | Medium | 2.4 | [task_1.4.md](todo/task_1.4.md) |
| 1.5 | HTTP Method-Based Routing | Completed | Medium | 2.5 | [task_1.5.md](todo/task_1.5.md) |
| 1.6 | Custom Response Headers and Status Codes | Completed | Small | 2.6 | [task_1.6.md](todo/task_1.6.md) |
+| 1.7 | Project Structure and Organization | Completed | Medium | 2.7 | [task_1.7.md](todo/task_1.7.md) |
## Status Legend
- **Completed** - Implemented and verified
ui/html/pages/submit.tmpl
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head><title>Submit - buylater.email</title></head>
+<body>
+ <h1>Schedule Your Purchase Reminder</h1>
+ <form action="/submit" method="POST">
+ <label for="email">Your Email:</label>
+ <input type="email" id="email" name="email" required><br><br>
+
+ <label for="url">Product URL:</label>
+ <input type="url" id="url" name="url" required><br><br>
+
+ <label for="delay">Remind me in:</label>
+ <select id="delay" name="delay">
+ <option value="3days">3 days</option>
+ <option value="1week">1 week</option>
+ <option value="2weeks">2 weeks</option>
+ <option value="1month">1 month</option>
+ </select><br><br>
+
+ <button type="submit">Schedule Reminder</button>
+ </form>
+</body>
+</html>
\ No newline at end of file