mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 18:00:37 +01:00
79494047b0
* Show commit status icon in commits table * Add comments * Fix icons * Few more places where commit table is displayed * Change integration test to use goquery for parsing html * Add integration tests for commit table and status icons * Fix status to return lates status correctly on all databases * Rewrote lates commit status selects
34 lines
758 B
Go
34 lines
758 B
Go
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package integrations
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
)
|
|
|
|
type HtmlDoc struct {
|
|
doc *goquery.Document
|
|
}
|
|
|
|
func NewHtmlParser(content []byte) (*HtmlDoc, error) {
|
|
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(content))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &HtmlDoc{doc: doc}, nil
|
|
}
|
|
|
|
func (doc *HtmlDoc) GetInputValueById(id string) string {
|
|
text, _ := doc.doc.Find("#" + id).Attr("value")
|
|
return text
|
|
}
|
|
|
|
func (doc *HtmlDoc) GetInputValueByName(name string) string {
|
|
text, _ := doc.doc.Find("input[name=\"" + name + "\"]").Attr("value")
|
|
return text
|
|
}
|