mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2025-12-16 03:51:02 +01:00
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
This commit is contained in:
96
.gh-dash.yml
Normal file
96
.gh-dash.yml
Normal file
@@ -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
|
||||
BIN
.github/assets/kleingebaecklogo.xcf
vendored
Normal file
BIN
.github/assets/kleingebaecklogo.xcf
vendored
Normal file
Binary file not shown.
@@ -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
|
||||
|
||||
26
ad.go
26
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)
|
||||
}
|
||||
|
||||
14
config.go
14
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"
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ outdir = "test"
|
||||
template="""
|
||||
Title: {{.Title}}
|
||||
Price: {{.Price}}
|
||||
Shipping: {{.Shipping}}
|
||||
Id: {{.Id}}
|
||||
Category: {{.Category}}
|
||||
Condition: {{.Condition}}
|
||||
|
||||
Reference in New Issue
Block a user