tangled
alpha
login
or
join now
arabica.social
/
arabica
7
fork
atom
Coffee journaling on ATProto (alpha)
alpha.arabica.social
coffee
7
fork
atom
overview
issues
pulls
pipelines
feat: add variety field to bean lexicon
pdewey.com
3 weeks ago
cbb46761
1798130b
verified
This commit was signed with the committer's
known signature
.
pdewey.com
SSH Key Fingerprint:
SHA256:ePOVkJstqVLchGK8m9/OGQG+aFNHD5XN3xjvW9wKCA4=
+43
8 changed files
expand all
collapse all
unified
split
internal
atproto
records.go
store.go
handlers
entities.go
models
models.go
web
components
dialog_modals.templ
entity_tables.templ
pages
bean_view.templ
lexicons
social.arabica.alpha.bean.json
+6
internal/atproto/records.go
···
169
169
if bean.Origin != "" {
170
170
record["origin"] = bean.Origin
171
171
}
172
172
+
if bean.Variety != "" {
173
173
+
record["variety"] = bean.Variety
174
174
+
}
172
175
if bean.RoastLevel != "" {
173
176
record["roastLevel"] = bean.RoastLevel
174
177
}
···
224
227
// Optional fields
225
228
if origin, ok := record["origin"].(string); ok {
226
229
bean.Origin = origin
230
230
+
}
231
231
+
if variety, ok := record["variety"].(string); ok {
232
232
+
bean.Variety = variety
227
233
}
228
234
if roastLevel, ok := record["roastLevel"].(string); ok {
229
235
bean.RoastLevel = roastLevel
+2
internal/atproto/store.go
···
517
517
beanModel := &models.Bean{
518
518
Name: bean.Name,
519
519
Origin: bean.Origin,
520
520
+
Variety: bean.Variety,
520
521
RoastLevel: bean.RoastLevel,
521
522
Process: bean.Process,
522
523
Description: bean.Description,
···
664
665
beanModel := &models.Bean{
665
666
Name: bean.Name,
666
667
Origin: bean.Origin,
668
668
+
Variety: bean.Variety,
667
669
RoastLevel: bean.RoastLevel,
668
670
Process: bean.Process,
669
671
Description: bean.Description,
+2
internal/handlers/entities.go
···
164
164
req = models.CreateBeanRequest{
165
165
Name: r.FormValue("name"),
166
166
Origin: r.FormValue("origin"),
167
167
+
Variety: r.FormValue("variety"),
167
168
RoastLevel: r.FormValue("roast_level"),
168
169
Process: r.FormValue("process"),
169
170
Description: r.FormValue("description"),
···
292
293
req = models.UpdateBeanRequest{
293
294
Name: r.FormValue("name"),
294
295
Origin: r.FormValue("origin"),
296
296
+
Variety: r.FormValue("variety"),
295
297
RoastLevel: r.FormValue("roast_level"),
296
298
Process: r.FormValue("process"),
297
299
Description: r.FormValue("description"),
+10
internal/models/models.go
···
14
14
MaxNotesLength = 2000
15
15
MaxOriginLength = 200
16
16
MaxRoastLevelLength = 100
17
17
+
MaxVarietyLength = 200
17
18
MaxProcessLength = 100
18
19
MaxMethodLength = 100
19
20
MaxGrindSizeLength = 100
···
44
45
RKey string `json:"rkey"` // Record key (AT Protocol or stringified ID for SQLite)
45
46
Name string `json:"name"`
46
47
Origin string `json:"origin"`
48
48
+
Variety string `json:"variety"`
47
49
RoastLevel string `json:"roast_level"`
48
50
Process string `json:"process"`
49
51
Description string `json:"description"`
···
136
138
type CreateBeanRequest struct {
137
139
Name string `json:"name"`
138
140
Origin string `json:"origin"`
141
141
+
Variety string `json:"variety"`
139
142
RoastLevel string `json:"roast_level"`
140
143
Process string `json:"process"`
141
144
Description string `json:"description"`
···
169
172
type UpdateBeanRequest struct {
170
173
Name string `json:"name"`
171
174
Origin string `json:"origin"`
175
175
+
Variety string `json:"variety"`
172
176
RoastLevel string `json:"roast_level"`
173
177
Process string `json:"process"`
174
178
Description string `json:"description"`
···
247
251
if len(r.Origin) > MaxOriginLength {
248
252
return ErrOriginTooLong
249
253
}
254
254
+
if len(r.Variety) > MaxVarietyLength {
255
255
+
return ErrFieldTooLong
256
256
+
}
250
257
if len(r.RoastLevel) > MaxRoastLevelLength {
251
258
return ErrFieldTooLong
252
259
}
···
269
276
}
270
277
if len(r.Origin) > MaxOriginLength {
271
278
return ErrOriginTooLong
279
279
+
}
280
280
+
if len(r.Variety) > MaxVarietyLength {
281
281
+
return ErrFieldTooLong
272
282
}
273
283
if len(r.RoastLevel) > MaxRoastLevelLength {
274
284
return ErrFieldTooLong
+9
internal/web/components/dialog_modals.templ
···
83
83
required
84
84
class="w-full form-input"
85
85
/>
86
86
+
<input
87
87
+
type="text"
88
88
+
name="variety"
89
89
+
value={ getStringValue(bean, "variety") }
90
90
+
placeholder="Variety (e.g. SL28, Typica, Gesha)"
91
91
+
class="w-full form-input"
92
92
+
/>
86
93
<select
87
94
name="roaster_rkey"
88
95
class="w-full form-input"
···
599
606
return e.Name
600
607
case "origin":
601
608
return e.Origin
609
609
+
case "variety":
610
610
+
return e.Variety
602
611
case "process":
603
612
return e.Process
604
613
case "description":
+8
internal/web/components/entity_tables.templ
···
27
27
}
28
28
<th class="table-th whitespace-nowrap">🏷️ Name</th>
29
29
<th class="table-th whitespace-nowrap">📍 Origin</th>
30
30
+
<th class="table-th whitespace-nowrap">🌿 Variety</th>
30
31
<th class="table-th whitespace-nowrap">☕ Roaster</th>
31
32
<th class="table-th whitespace-nowrap">🔥 Roast Level</th>
32
33
<th class="table-th whitespace-nowrap">🌱 Process</th>
···
56
57
}
57
58
</td>
58
59
<td class="px-6 py-4 text-sm text-brown-900">{ bean.Origin }</td>
60
60
+
<td class="px-6 py-4 text-sm text-brown-900">
61
61
+
if bean.Variety != "" {
62
62
+
{ bean.Variety }
63
63
+
} else {
64
64
+
<span class="text-brown-400">-</span>
65
65
+
}
66
66
+
</td>
59
67
<td class="px-6 py-4 text-sm text-brown-900">
60
68
if bean.Roaster != nil && bean.Roaster.Name != "" {
61
69
{ bean.Roaster.Name }
+1
internal/web/pages/bean_view.templ
···
58
58
}
59
59
<div class="grid grid-cols-2 gap-4">
60
60
@components.DetailField(components.DetailFieldProps{Label: "📍 Origin", Value: props.Bean.Origin})
61
61
+
@components.DetailField(components.DetailFieldProps{Label: "🌿 Variety", Value: props.Bean.Variety})
61
62
@components.DetailField(components.DetailFieldProps{Label: "🔥 Roast Level", Value: props.Bean.RoastLevel})
62
63
@components.DetailField(components.DetailFieldProps{Label: "🌱 Process", Value: props.Bean.Process})
63
64
if props.Bean.Closed {
+5
lexicons/social.arabica.alpha.bean.json
···
20
20
"maxLength": 200,
21
21
"description": "Geographic origin of the beans (e.g., 'Ethiopia', 'Colombia')"
22
22
},
23
23
+
"variety": {
24
24
+
"type": "string",
25
25
+
"maxLength": 200,
26
26
+
"description": "Coffee variety (e.g., 'SL28', 'Typica', 'Gesha', 'Caturra')"
27
27
+
},
23
28
"roastLevel": {
24
29
"type": "string",
25
30
"maxLength": 100,