~bouncepaw/betula

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH betula] Refactoring: move states to const group of values

Details
Message ID
<169264134292.9744.11183402937166117354-0@git.sr.ht>
DKIM signature
missing
Download raw message
Patch: +29 -25
From: Danila Gorelko <danila@danilax86.space>

---
 readpage/workers.go | 54 ++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/readpage/workers.go b/readpage/workers.go
index 97050e7..f4ed747 100644
--- a/readpage/workers.go
+++ b/readpage/workers.go
@@ -7,26 +7,33 @@ import (
	"net/url"
)

const (
	stateLooking = iota
	stateFound
	stateFoundText
)

const (
	stateNotSure = iota
	stateSure
)

func listenForTitle(nodes chan *html.Node, data *FoundData) {
	state := 0
	// 0 looking
	// 1 found
	state := stateLooking
	for n := range nodes {
		if state == 0 {
		if state == stateLooking {
			if n.Type == html.ElementNode && n.Data == "title" {
				data.title = n.FirstChild.Data
				state = 1
				state = stateFound
			}
		}
	}
}

func listenForBookmarkOf(nodes chan *html.Node, data *FoundData) {
	state := 0
	// 0 looking
	// 1 found
	state := stateLooking
	for n := range nodes {
		if state == 1 {
		if state == stateFound {
			continue
		}

@@ -48,25 +55,22 @@ func listenForBookmarkOf(nodes chan *html.Node, data *FoundData) {
			}

			data.BookmarkOf = uri
			state = 1
			state = stateFound
		}
	}
}

func listenForPostName(nodes chan *html.Node, data *FoundData) {
	state := 0
	// 0 nothing found yet
	// 1 found a p-name
	// 2 found the p-name's text
	state := stateLooking
	for n := range nodes {
		switch {
		case state == 2:
		case state == stateFoundText:
			continue
		case state == 1 && n.Type == html.TextNode:
		case state == stateFound && n.Type == html.TextNode:
			data.PostName = n.Data
			state = 2
		case state == 0 && nodeHasClass(n, "p-name"):
			state = 1
			state = stateFoundText
		case state == stateLooking && nodeHasClass(n, "p-name"):
			state = stateFound
		}
	}
}
@@ -81,9 +85,9 @@ func listenForTags(nodes chan *html.Node, data *FoundData) {
}

func listenForMycomarkup(nodes chan *html.Node, data *FoundData) {
	state := 0 // 0 looking 1 found
	state := stateLooking
	for n := range nodes {
		if state == 1 {
		if state == stateFound {
			continue
		}

@@ -124,22 +128,22 @@ func listenForMycomarkup(nodes chan *html.Node, data *FoundData) {
}

func listenForHFeed(nodes chan *html.Node, data *FoundData) {
	state := 0 // 0 not sure 1 sure
	state := stateNotSure
	for n := range nodes {
		if state == 1 {
		if state == stateSure {
			continue
		}

		if nodeHasClass(n, "h-feed") {
			data.IsHFeed = true
			state = 1
			state = stateSure
			continue
		}

		// If we've found an h-entry, then it's highly-highly unlikely that the
		// document is an h-feed. At least in Betula.
		if nodeHasClass(n, "h-entry") {
			state = 1
			state = stateSure
		}
	}
}
-- 
2.38.5

[betula/patches/.build.yml] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CUYFC9623YIN.EQ6PLPRDXNH4@cirno2>
In-Reply-To
<169264134292.9744.11183402937166117354-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
betula/patches/.build.yml: FAILED in 2m50s

[Refactoring: move states to const group of values][0] from [~danilax86][1]

[0]: https://lists.sr.ht/~bouncepaw/betula/patches/43857
[1]: danila@danilax86.space

✗ #1044913 FAILED betula/patches/.build.yml https://builds.sr.ht/~bouncepaw/job/1044913
Details
Message ID
<2DED67DE-A010-47F2-BA2B-45CA24A5E8D3@ya.ru>
In-Reply-To
<169264134292.9744.11183402937166117354-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
LGTM. Applied. Thanks!
Reply to thread Export thread (mbox)