diff --git a/.gh-dash.yml b/.gh-dash.yml new file mode 100644 index 0000000..e62c39a --- /dev/null +++ b/.gh-dash.yml @@ -0,0 +1,96 @@ +prSections: + - title: Responsible PRs + filters: repo:tlinden/kleingebaeck is:open NOT dependabot + layout: + repoName: + hidden: true + + - title: Responsible Dependabot PRs + filters: repo:tlinden/kleingebaeck is:open dependabot + layout: + repoName: + hidden: true + +issuesSections: + - title: Responsible Issues + filters: is:open repo:tlinden/kleingebaeck -author:@me + layout: + repoName: + hidden: true + + - title: Note-to-Self Issues + filters: is:open repo:tlinden/kleingebaeck author:@me + layout: + creator: + hidden: true + repoName: + hidden: true + +defaults: + preview: + open: false + width: 100 + +keybindings: + universal: + - key: "shift+down" + builtin: pageDown + - key: "shift+up" + builtin: pageUp + prs: + - key: g + name: gitu + command: > + cd {{.RepoPath}} && /home/scip/bin/gitu + - key: M + name: squash-merge + command: gh pr merge --rebase --squash --admin --repo {{.RepoName}} {{.PrNumber}} + - key: i + name: show ci checks + command: gh pr checks --repo {{.RepoName}} {{.PrNumber}} | glow -p + - key: e + name: edit pr + command: ~/.config/gh-dash/edit-gh-pr {{.RepoName}} {{.PrNumber}} + - key: E + name: open repo in emacs + command: emacsclient {{.RepoPath}} & + issues: + - key: v + name: view + command: gh issue view --repo {{.RepoName}} {{.IssueNumber}} | glow -p + - key: l + name: add label + command: gh issue --repo {{.RepoName}} edit {{.IssueNumber}} --add-label $(gum choose bug enhancement question dependencies wontfix) + - key: L + name: remove label + command: gh issue --repo {{.RepoName}} edit {{.IssueNumber}} --remove-label $(gum choose bug enhancement question dependencies wontfix) + - key: E + name: open repo in emacs + command: emacsclient {{.RepoPath}} & + +theme: + ui: + sectionsShowCount: true + table: + compact: false + showSeparator: true + colors: + text: + primary: "#E2E1ED" + secondary: "#6770cb" + inverted: "#242347" + faint: "#b0793b" + warning: "#E0AF68" + success: "#3DF294" + background: + selected: "#1B1B33" + border: + primary: "#383B5B" + secondary: "#39386B" + faint: "#8d3e0b" + +repoPaths: + :owner/:repo: ~/dev/:repo + +pager: + diff: delta diff --git a/.github/assets/kleingebaecklogo.xcf b/.github/assets/kleingebaecklogo.xcf new file mode 100644 index 0000000..e17fdaf Binary files /dev/null and b/.github/assets/kleingebaecklogo.xcf differ diff --git a/README.md b/README.md index df58530..8dd0a8c 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,7 @@ somewhat like this: ```default Title: A book I sell Price: 99 € VB +Shipping: 6,90 € Id: 1919191919 Category: Sachbücher Condition: Sehr Gut diff --git a/ad.go b/ad.go index 2327efe..0d8408d 100644 --- a/ad.go +++ b/ad.go @@ -44,6 +44,7 @@ type Ad struct { Created string `goquery:"#viewad-extra-info,text"` Text string `goquery:"p#viewad-description-text,html"` Images []string `goquery:".galleryimage-element img,[src]"` + Shipping string `goquery:".boxedarticle--details--shipping,text"` // not always filled Expire string // runtime computed @@ -61,6 +62,8 @@ func (ad *Ad) LogValue() slog.Value { slog.String("categorytree", strings.Join(ad.CategoryTree, "+")), slog.String("created", ad.Created), slog.String("expire", ad.Expire), + slog.String("shipping", ad.Shipping), + slog.String("details", ad.Details), ) } @@ -84,7 +87,7 @@ func (ad *Ad) CalculateExpire() { if ad.Created != "" { ts, err := time.Parse("02.01.2006", ad.Created) if err == nil { - ad.Expire = ts.AddDate(0, ExpireMonths, ExpireDays).Format("02.01.2006") + ad.Expire = ts.AddDate(0, 0, ExpireDays).Format("02.01.2006") } } } @@ -138,14 +141,23 @@ func (ad *Ad) DecodeAttributes() { ad.Attributes = attrmap - switch { - case Exists(ad.Attributes, "Zustand"): + if Exists(ad.Attributes, "Zustand") { ad.Condition = ad.Attributes["Zustand"] - case Exists(ad.Attributes, "Farbe"): + } + + if Exists(ad.Attributes, "Farbe") { ad.Color = ad.Attributes["Farbe"] - case Exists(ad.Attributes, "Art"): - ad.Type = ad.Attributes["Type"] - case Exists(ad.Attributes, "Material"): + } + + if Exists(ad.Attributes, "Art") { + ad.Type = ad.Attributes["Art"] + } + + if Exists(ad.Attributes, "Material") { ad.Material = ad.Attributes["Material"] } + + slog.Debug("parsed attributes", "attributes", ad.Attributes) + + ad.Shipping = strings.Replace(ad.Shipping, "+ Versand ab ", "", 1) } diff --git a/config.go b/config.go index 8604948..299d280 100644 --- a/config.go +++ b/config.go @@ -34,7 +34,7 @@ import ( ) const ( - VERSION string = "0.3.21" + VERSION string = "0.3.22" Baseuri string = "https://www.kleinanzeigen.de" Listuri string = "/s-bestandsliste.html" Defaultdir string = "." @@ -47,11 +47,11 @@ const ( "Created: {{.Created}}\nExpire: {{.Expire}}\n\n{{.Text}}\n" */ - DefaultTemplate string = "Title: {{.Title}}\nPrice: {{.Price}}\nId: {{.ID}}\n" + + DefaultTemplate string = "Title: {{.Title}}\nPrice: {{.Price}}\nShipping: {{.Shipping}}\nId: {{.ID}}\n" + "Category: {{.Category}}\nCondition: {{.Condition}}\nType: {{.Type}}\nColor: {{.Color}}\n" + "Created: {{.Created}}\nExpire: {{.Expire}}\n\n{{.Text}}\n" - DefaultTemplateWin string = "Title: {{.Title}}\r\nPrice: {{.Price}}\r\nId: {{.ID}}\r\n" + + DefaultTemplateWin string = "Title: {{.Title}}\r\nPrice: {{.Price}}\r\nShipping: {{.Shipping}}\r\nId: {{.ID}}\r\n" + "Category: {{.Category}}\r\nCondition: {{.Condition}}\r\nType: {{.Type}}\r\nColor: {{.Color}}\r\n" + "Created: {{.Created}}\r\nExpires: {{.Expire}}\r\n\r\n{{.Text}}\r\n" @@ -69,8 +69,12 @@ const ( // we extract the slug from the uri SlugURIPartNum int = 6 - ExpireMonths int = 2 - ExpireDays int = 1 + // We have to calculate the ad expiry because the real value can + // only be seen by logged in users. The initial ad lifetime is 120 + // days. It can be extended by the user 8 days before expire by 60 + // days. But this is unknown to us, so we'll stick with our 120 + // days. They may be wrong for older ads. Don't rely on it! + ExpireDays int = 120 WIN string = "windows" ) diff --git a/example.conf b/example.conf index fd820e6..3b3fbb5 100644 --- a/example.conf +++ b/example.conf @@ -21,6 +21,7 @@ outdir = "test" template=""" Title: {{.Title}} Price: {{.Price}} +Shipping: {{.Shipping}} Id: {{.Id}} Category: {{.Category}} Condition: {{.Condition}}