Compare commits

..

2 Commits

Author SHA1 Message Date
ngn
7755d6c2fe
fix code formatting
All checks were successful
Build and publish the docker image / build (push) Successful in 1m2s
Signed-off-by: ngn <ngn@ngn.tf>
2025-04-05 23:51:03 +03:00
ngn
06fa48351b
add renovate config
Signed-off-by: ngn <ngn@ngn.tf>
2025-04-05 23:50:38 +03:00
8 changed files with 211 additions and 207 deletions

View File

@ -15,7 +15,7 @@ var Dicts []dictionary = []dictionary{
{ShortName: "EN-FR", Name: "French - English", Url: "/french-english"}, {ShortName: "EN-FR", Name: "French - English", Url: "/french-english"},
} }
func find_dict(sn string) (*dictionary) { func find_dict(sn string) *dictionary {
for i := range Dicts { for i := range Dicts {
if Dicts[i].ShortName == sn { if Dicts[i].ShortName == sn {
return &Dicts[i] return &Dicts[i]
@ -25,7 +25,7 @@ func find_dict(sn string) (*dictionary) {
return nil return nil
} }
func (d *dictionary) Path(term string) string{ func (d *dictionary) Path(term string) string {
term_escaped := url.PathEscape(term) term_escaped := url.PathEscape(term)
return d.Url + "/" + term_escaped return d.Url + "/" + term_escaped
} }

View File

@ -19,7 +19,7 @@ type Translation struct {
} }
func (t *Translation) getSuggestions(doc *goquery.Document) error { func (t *Translation) getSuggestions(doc *goquery.Document) error {
doc.Find(".suggestion-list li").Each(func(_ int, sel *goquery.Selection){ doc.Find(".suggestion-list li").Each(func(_ int, sel *goquery.Selection) {
if link := sel.Find("a"); link != nil { if link := sel.Find("a"); link != nil {
t.Suggestions = append(t.Suggestions, link.Text()) t.Suggestions = append(t.Suggestions, link.Text())
} }
@ -29,7 +29,7 @@ func (t *Translation) getSuggestions(doc *goquery.Document) error {
} }
func (t *Translation) getEntry(tds *goquery.Selection) { func (t *Translation) getEntry(tds *goquery.Selection) {
if tds == nil || tds.Length() < 4{ if tds == nil || tds.Length() < 4 {
return return
} }
@ -38,7 +38,7 @@ func (t *Translation) getEntry(tds *goquery.Selection) {
index int = 0 index int = 0
) )
tds.Each(func(_ int,sel *goquery.Selection){ tds.Each(func(_ int, sel *goquery.Selection) {
if index < 1 || index > 3 { if index < 1 || index > 3 {
index++ index++
return return
@ -58,7 +58,7 @@ func (t *Translation) getEntry(tds *goquery.Selection) {
entries = append(entries, Entry{ entries = append(entries, Entry{
Text: text, Text: text,
}) })
}else { } else {
entries = append(entries, Entry{ entries = append(entries, Entry{
Text: text, Text: text,
Detail: detail.Text(), Detail: detail.Text(),
@ -72,7 +72,7 @@ func (t *Translation) getEntry(tds *goquery.Selection) {
} }
func (t *Translation) getEntries(trs *goquery.Selection) { func (t *Translation) getEntries(trs *goquery.Selection) {
trs.Each(func(_ int, sel *goquery.Selection){ trs.Each(func(_ int, sel *goquery.Selection) {
tds := sel.Find("td") tds := sel.Find("td")
if tds == nil { if tds == nil {
@ -81,7 +81,7 @@ func (t *Translation) getEntries(trs *goquery.Selection) {
if class, ok := tds.Last().Attr("class"); !ok { if class, ok := tds.Last().Attr("class"); !ok {
return return
}else if !strings.Contains(class, "rc4 hidden-xs"){ } else if !strings.Contains(class, "rc4 hidden-xs") {
return return
} }
@ -102,7 +102,7 @@ func (t *Translation) GetResults(doc *goquery.Document) error {
return fmt.Errorf("failed to get table body") return fmt.Errorf("failed to get table body")
} }
trs.First().Find("th").Each(func(_ int, sel *goquery.Selection){ trs.First().Find("th").Each(func(_ int, sel *goquery.Selection) {
if sel.Text() != "" { if sel.Text() != "" {
t.Fields = append(t.Fields, sel.Text()) t.Fields = append(t.Fields, sel.Text())
} }

4
renovate.json Normal file
View File

@ -0,0 +1,4 @@
{
"extends": ["config:recommended"],
"prHourlyLimit": 20
}

View File

@ -16,8 +16,8 @@ func Render(c *fiber.Ctx, template string, data fiber.Map) error {
return c.Render(template, data) return c.Render(template, data)
} }
func RenderError(c *fiber.Ctx, code int, err... error) error { func RenderError(c *fiber.Ctx, code int, err ...error) error {
if code == 500 && len(err) > 0 && err[0] != nil{ if code == 500 && len(err) > 0 && err[0] != nil {
log.Printf("server error: %s", err[0].Error()) log.Printf("server error: %s", err[0].Error())
} }