ref: b4e4fc28cbe113df49a10bac4333d064aed989eb
parent: 7884414923b9cad4891457ecbd365348cf9b17b6
author: Philip Silva <[email protected]>
date: Fri Jan 1 19:29:39 EST 2021
InnerNodesToBox(..)
--- a/browser/browser.go
+++ b/browser/browser.go
@@ -626,26 +626,6 @@
}
}
-func RichInnerContentFrom(r int, b *Browser, n *nodes.Node) *Element {
- childrenAsEls := make([]*Element, 0, 1)
-
- for _, c := range n.Children {
- tmp := NodeToBox(r+1, b, c)
- if tmp != nil {
- numElements++
- el := NewElement(tmp, c)
- childrenAsEls = append(childrenAsEls, el)
- }
- }
- if len(childrenAsEls) == 0 {
- return nil
- } else if len(childrenAsEls) == 1 {
- return childrenAsEls[0]
- }
- res := Arrange(n, childrenAsEls...)
- return res
-}
-
type Table struct {
rows []*TableRow
}
@@ -872,7 +852,7 @@
n: n,
}
} else {
- innerContent = RichInnerContentFrom(r+1, b, n)
+ innerContent = InnerNodesToBox(r+1, b, n)
}
numElements++
@@ -910,7 +890,7 @@
n: n,
}
} else {
- innerContent = RichInnerContentFrom(r+1, b, n)
+ innerContent = InnerNodesToBox(r+1, b, n)
}
numElements++
@@ -919,13 +899,9 @@
n,
)
case "a":
- var href string
- for _, a := range n.Attrs {
- if a.Key == "href" {
- href = a.Val
- }
- }
+ var href = n.Attr("href")
var innerContent duit.UI
+
if nodes.IsPureTextContent(*n) {
innerContent = &ColoredLabel{
Label: &duit.Label{
@@ -935,9 +911,7 @@
n: n,
}
} else {
- // TODO: make blue borders and different
- // mouse cursor and actually clickable
- innerContent = RichInnerContentFrom(r+1, b, n)
+ innerContent = InnerNodesToBox(r+1, b, n)
}
numElements++
if innerContent == nil {
@@ -953,24 +927,7 @@
return el
default:
// Internal node object
- els := make([]*Element, 0, 10)
- for _, c := range n.Children {
- el := NodeToBox(r+1, b, c)
- if el != nil && !c.IsDisplayNone() {
- els = append(els, el)
- }
- }
-
- if len(els) == 0 {
- return nil
- } else if len(els) == 1 {
- return els[0]
- } else {
- for _, e := range els {
- _ = e
- }
- return Arrange(n, els...)
- }
+ return InnerNodesToBox(r+1, b, n)
}
} else if n.Type() == html.TextNode {
// Leaf text object
@@ -1001,6 +958,26 @@
} else {
return nil
}
+}
+
+func InnerNodesToBox(r int, b *Browser, n *nodes.Node) *Element {
+ childrenAsEls := make([]*Element, 0, len(n.Children))
+
+ for _, c := range n.Children {
+ el := NodeToBox(r+1, b, c)
+ if el != nil && !c.IsDisplayNone() {
+ numElements++
+ childrenAsEls = append(childrenAsEls, el)
+ }
+ }
+
+ if len(childrenAsEls) == 0 {
+ return nil
+ } else if len(childrenAsEls) == 1 {
+ return childrenAsEls[0]
+ }
+
+ return Arrange(n, childrenAsEls...)
}
func TraverseTree(ui duit.UI, f func(ui duit.UI)) {
--- a/package.rc
+++ b/package.rc
@@ -1,17 +1,27 @@
-rm -rf ./opossum-plan9-amd64
-mkdir ./opossum-plan9-amd64
-chmod +t ./opossum-plan9-amd64
-mkdir ./opossum-plan9-amd64/domino-lib
+name='opossum-plan9-amd64'
+rm -rf ./$name
+mkdir ./$name
+chmod +t ./$name
+mkdir ./$name/domino-lib
+
echo Compiling...
cd cmd/browse
-go build -o opossum-plan9-amd64.bin
+go build -o $name.bin
cd ../..
-mv cmd/browse/opossum-plan9-amd64.bin .
-mv opossum-plan9-amd64.bin ./opossum-plan9-amd64/
-cp README.md ./opossum-plan9-amd64/
-cp normalize.css ./opossum-plan9-amd64/
-dircp domino-lib ./opossum-plan9-amd64/domino-lib
-tar czf opossum-plan9-amd64.tgz opossum-plan9-amd64
-chmod +t opossum-plan9-amd64.tgz
-echo Created opossum-plan9-amd64.tgz
+mv cmd/browse/$name.bin .
+mv $name.bin ./$name/
+cp README.md ./$name/
+cp normalize.css ./$name/
+dircp domino-lib ./$name/domino-lib
+tar czf $name.tgz $name
+chmod +t $name.tgz
+echo Created $name.tgz
+tarball=`{pwd} ^ '/' ^ $name ^ '.tgz'
+
+echo Verifying $tarball ...
+mkdir -p /tmp/`{date -n}
+cd /tmp/`{date -n}
+tar xf $tarball
+cd $name
+./$name.bin