Skip to content
This repository was archived by the owner on Dec 13, 2025. It is now read-only.

Commit 0b53e95

Browse files
authored
Enhancements and various Fixes (#165)
* fix expire data calculation, fixes #162 * add shipping price, if any. fixes #164 * add gh-dash config * add logo source * fix #163: used invalid key for type attribute, fixed switch
1 parent e95bdad commit 0b53e95

File tree

6 files changed

+126
-12
lines changed

6 files changed

+126
-12
lines changed

.gh-dash.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
prSections:
2+
- title: Responsible PRs
3+
filters: repo:tlinden/kleingebaeck is:open NOT dependabot
4+
layout:
5+
repoName:
6+
hidden: true
7+
8+
- title: Responsible Dependabot PRs
9+
filters: repo:tlinden/kleingebaeck is:open dependabot
10+
layout:
11+
repoName:
12+
hidden: true
13+
14+
issuesSections:
15+
- title: Responsible Issues
16+
filters: is:open repo:tlinden/kleingebaeck -author:@me
17+
layout:
18+
repoName:
19+
hidden: true
20+
21+
- title: Note-to-Self Issues
22+
filters: is:open repo:tlinden/kleingebaeck author:@me
23+
layout:
24+
creator:
25+
hidden: true
26+
repoName:
27+
hidden: true
28+
29+
defaults:
30+
preview:
31+
open: false
32+
width: 100
33+
34+
keybindings:
35+
universal:
36+
- key: "shift+down"
37+
builtin: pageDown
38+
- key: "shift+up"
39+
builtin: pageUp
40+
prs:
41+
- key: g
42+
name: gitu
43+
command: >
44+
cd {{.RepoPath}} && /home/scip/bin/gitu
45+
- key: M
46+
name: squash-merge
47+
command: gh pr merge --rebase --squash --admin --repo {{.RepoName}} {{.PrNumber}}
48+
- key: i
49+
name: show ci checks
50+
command: gh pr checks --repo {{.RepoName}} {{.PrNumber}} | glow -p
51+
- key: e
52+
name: edit pr
53+
command: ~/.config/gh-dash/edit-gh-pr {{.RepoName}} {{.PrNumber}}
54+
- key: E
55+
name: open repo in emacs
56+
command: emacsclient {{.RepoPath}} &
57+
issues:
58+
- key: v
59+
name: view
60+
command: gh issue view --repo {{.RepoName}} {{.IssueNumber}} | glow -p
61+
- key: l
62+
name: add label
63+
command: gh issue --repo {{.RepoName}} edit {{.IssueNumber}} --add-label $(gum choose bug enhancement question dependencies wontfix)
64+
- key: L
65+
name: remove label
66+
command: gh issue --repo {{.RepoName}} edit {{.IssueNumber}} --remove-label $(gum choose bug enhancement question dependencies wontfix)
67+
- key: E
68+
name: open repo in emacs
69+
command: emacsclient {{.RepoPath}} &
70+
71+
theme:
72+
ui:
73+
sectionsShowCount: true
74+
table:
75+
compact: false
76+
showSeparator: true
77+
colors:
78+
text:
79+
primary: "#E2E1ED"
80+
secondary: "#6770cb"
81+
inverted: "#242347"
82+
faint: "#b0793b"
83+
warning: "#E0AF68"
84+
success: "#3DF294"
85+
background:
86+
selected: "#1B1B33"
87+
border:
88+
primary: "#383B5B"
89+
secondary: "#39386B"
90+
faint: "#8d3e0b"
91+
92+
repoPaths:
93+
:owner/:repo: ~/dev/:repo
94+
95+
pager:
96+
diff: delta
134 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ somewhat like this:
201201
```default
202202
Title: A book I sell
203203
Price: 99 € VB
204+
Shipping: 6,90 €
204205
Id: 1919191919
205206
Category: Sachbücher
206207
Condition: Sehr Gut

ad.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Ad struct {
4444
Created string `goquery:"#viewad-extra-info,text"`
4545
Text string `goquery:"p#viewad-description-text,html"`
4646
Images []string `goquery:".galleryimage-element img,[src]"`
47+
Shipping string `goquery:".boxedarticle--details--shipping,text"` // not always filled
4748
Expire string
4849

4950
// runtime computed
@@ -61,6 +62,8 @@ func (ad *Ad) LogValue() slog.Value {
6162
slog.String("categorytree", strings.Join(ad.CategoryTree, "+")),
6263
slog.String("created", ad.Created),
6364
slog.String("expire", ad.Expire),
65+
slog.String("shipping", ad.Shipping),
66+
slog.String("details", ad.Details),
6467
)
6568
}
6669

@@ -84,7 +87,7 @@ func (ad *Ad) CalculateExpire() {
8487
if ad.Created != "" {
8588
ts, err := time.Parse("02.01.2006", ad.Created)
8689
if err == nil {
87-
ad.Expire = ts.AddDate(0, ExpireMonths, ExpireDays).Format("02.01.2006")
90+
ad.Expire = ts.AddDate(0, 0, ExpireDays).Format("02.01.2006")
8891
}
8992
}
9093
}
@@ -138,14 +141,23 @@ func (ad *Ad) DecodeAttributes() {
138141

139142
ad.Attributes = attrmap
140143

141-
switch {
142-
case Exists(ad.Attributes, "Zustand"):
144+
if Exists(ad.Attributes, "Zustand") {
143145
ad.Condition = ad.Attributes["Zustand"]
144-
case Exists(ad.Attributes, "Farbe"):
146+
}
147+
148+
if Exists(ad.Attributes, "Farbe") {
145149
ad.Color = ad.Attributes["Farbe"]
146-
case Exists(ad.Attributes, "Art"):
147-
ad.Type = ad.Attributes["Type"]
148-
case Exists(ad.Attributes, "Material"):
150+
}
151+
152+
if Exists(ad.Attributes, "Art") {
153+
ad.Type = ad.Attributes["Art"]
154+
}
155+
156+
if Exists(ad.Attributes, "Material") {
149157
ad.Material = ad.Attributes["Material"]
150158
}
159+
160+
slog.Debug("parsed attributes", "attributes", ad.Attributes)
161+
162+
ad.Shipping = strings.Replace(ad.Shipping, "+ Versand ab ", "", 1)
151163
}

config.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
)
3535

3636
const (
37-
VERSION string = "0.3.21"
37+
VERSION string = "0.3.22"
3838
Baseuri string = "https://www.kleinanzeigen.de"
3939
Listuri string = "/s-bestandsliste.html"
4040
Defaultdir string = "."
@@ -47,11 +47,11 @@ const (
4747
"Created: {{.Created}}\nExpire: {{.Expire}}\n\n{{.Text}}\n"
4848
4949
*/
50-
DefaultTemplate string = "Title: {{.Title}}\nPrice: {{.Price}}\nId: {{.ID}}\n" +
50+
DefaultTemplate string = "Title: {{.Title}}\nPrice: {{.Price}}\nShipping: {{.Shipping}}\nId: {{.ID}}\n" +
5151
"Category: {{.Category}}\nCondition: {{.Condition}}\nType: {{.Type}}\nColor: {{.Color}}\n" +
5252
"Created: {{.Created}}\nExpire: {{.Expire}}\n\n{{.Text}}\n"
5353

54-
DefaultTemplateWin string = "Title: {{.Title}}\r\nPrice: {{.Price}}\r\nId: {{.ID}}\r\n" +
54+
DefaultTemplateWin string = "Title: {{.Title}}\r\nPrice: {{.Price}}\r\nShipping: {{.Shipping}}\r\nId: {{.ID}}\r\n" +
5555
"Category: {{.Category}}\r\nCondition: {{.Condition}}\r\nType: {{.Type}}\r\nColor: {{.Color}}\r\n" +
5656
"Created: {{.Created}}\r\nExpires: {{.Expire}}\r\n\r\n{{.Text}}\r\n"
5757

@@ -69,8 +69,12 @@ const (
6969
// we extract the slug from the uri
7070
SlugURIPartNum int = 6
7171

72-
ExpireMonths int = 2
73-
ExpireDays int = 1
72+
// We have to calculate the ad expiry because the real value can
73+
// only be seen by logged in users. The initial ad lifetime is 120
74+
// days. It can be extended by the user 8 days before expire by 60
75+
// days. But this is unknown to us, so we'll stick with our 120
76+
// days. They may be wrong for older ads. Don't rely on it!
77+
ExpireDays int = 120
7478

7579
WIN string = "windows"
7680
)

example.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ outdir = "test"
2121
template="""
2222
Title: {{.Title}}
2323
Price: {{.Price}}
24+
Shipping: {{.Shipping}}
2425
Id: {{.Id}}
2526
Category: {{.Category}}
2627
Condition: {{.Condition}}

0 commit comments

Comments
 (0)