-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
123 lines (98 loc) · 3.13 KB
/
Copy pathtypes.go
File metadata and controls
123 lines (98 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package main
import (
"fmt"
"time"
)
// ─── Feed Types ─────────────────────────────────────────────────────
type Feed int
const (
FeedTop Feed = iota
FeedNew
FeedAsk
FeedShow
FeedJobs
feedCount
)
var feedLabels = [feedCount]string{"Top", "New", "Ask", "Show", "Jobs"}
var feedBaseURLs = [feedCount]string{
"https://news.ycombinator.com/news",
"https://news.ycombinator.com/newest",
"https://news.ycombinator.com/ask",
"https://news.ycombinator.com/show",
"https://news.ycombinator.com/jobs",
}
// ─── Confirm Kind ───────────────────────────────────────────────────
type confirmKind int
const (
confirmUser confirmKind = iota
confirmDomain
)
// ─── View Mode ──────────────────────────────────────────────────────
type viewMode int
const (
modeStories viewMode = iota
modeComments
modeBlockList
modeSearch
modeBookmarks
)
// ─── Story ──────────────────────────────────────────────────────────
type Story struct {
ID int
Title string
URL string
Domain string
Score int
By string
TimeAgo string
Comments int
Page int // 1-indexed page number (set during search scraping)
PageRank int // 1-indexed rank within that page (set during search scraping)
}
func (s Story) hnURL() string {
return fmt.Sprintf("https://news.ycombinator.com/item?id=%d", s.ID)
}
func (s Story) linkURL() string {
if s.URL != "" {
return s.URL
}
return s.hnURL()
}
// ─── Bookmark ───────────────────────────────────────────────────────
type Bookmark struct {
Story Story
BookmarkedAt time.Time
}
// ─── Comment ────────────────────────────────────────────────────────
type Comment struct {
ID int
By string
TimeAgo string
Text string // plain text (for empty checks)
Spans []CommentSpan // rich formatted content
Depth int
Collapsed bool
}
// ─── Rich Text ──────────────────────────────────────────────────────
type SpanStyle int
const (
spanNormal SpanStyle = iota
spanItalic
spanCode
spanPreCode // code block — preserve whitespace
spanLink
)
type CommentSpan struct {
Text string
Style SpanStyle
URL string // only for spanLink
}
// richChunk is a styled fragment within a single rendered line.
type richChunk struct {
text string
style SpanStyle
}
// richLine is one rendered terminal line made of styled chunks.
type richLine struct {
chunks []richChunk
}