mirror of
https://github.com/NohamR/papeer.git
synced 2026-05-25 12:27:20 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
108e1bdd1a |
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -9,16 +9,6 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.17
|
|
||||||
- name: Install kindlegen
|
|
||||||
run: |
|
|
||||||
curl -L https://github.com/lapwat/papeer/releases/download/kindlegen/kindlegen_linux_2.6_i386_v2_9.tar.gz > kindlegen.tar.gz
|
|
||||||
tar xzvf kindlegen.tar.gz
|
|
||||||
chmod +x kindlegen
|
|
||||||
mv kindlegen /usr/local/bin
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Test
|
- name: Test
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ go get -u github.com/lapwat/papeer
|
|||||||
```sh
|
```sh
|
||||||
# use platform=darwin for MacOS
|
# use platform=darwin for MacOS
|
||||||
platform=linux
|
platform=linux
|
||||||
release=0.5.2
|
release=0.5.0
|
||||||
|
|
||||||
# download and extract
|
# download and extract
|
||||||
curl -L https://github.com/lapwat/papeer/releases/download/v$release/papeer-v$release-$platform-amd64.tar.gz > papeer.tar.gz
|
curl -L https://github.com/lapwat/papeer/releases/download/v$release/papeer-v$release-$platform-amd64.tar.gz > papeer.tar.gz
|
||||||
@@ -151,7 +151,7 @@ sudo mv papeer /usr/local/bin
|
|||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
Download [latest release](https://github.com/lapwat/papeer/releases/download/v0.5.2/papeer-v0.5.2-windows-amd64.exe.zip).
|
Download [latest release](https://github.com/lapwat/papeer/releases/download/v0.5.0/papeer-v0.5.0-windows-amd64.exe.zip).
|
||||||
|
|
||||||
## MOBI support
|
## MOBI support
|
||||||
|
|
||||||
|
|||||||
@@ -398,11 +398,11 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
|||||||
selector = "a"
|
selector = "a"
|
||||||
selectorSet = false
|
selectorSet = false
|
||||||
}
|
}
|
||||||
|
|
||||||
pathLinks := map[string][]link{}
|
pathLinks := map[string][]link{}
|
||||||
pathCount := map[string]int{}
|
pathCount := map[string]int{}
|
||||||
pathMax = ""
|
pathMax = ""
|
||||||
|
|
||||||
// visit and count link classes
|
// visit and count link classes
|
||||||
c := colly.NewCollector()
|
c := colly.NewCollector()
|
||||||
c.OnHTML(selector, func(e *colly.HTMLElement) {
|
c.OnHTML(selector, func(e *colly.HTMLElement) {
|
||||||
@@ -410,34 +410,34 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
|||||||
text := strings.TrimSpace(e.Text)
|
text := strings.TrimSpace(e.Text)
|
||||||
path := GetPath(e.DOM)
|
path := GetPath(e.DOM)
|
||||||
key := path
|
key := path
|
||||||
|
|
||||||
if selectorSet {
|
if selectorSet {
|
||||||
|
|
||||||
// if selector is set, we use the selector specified by the user
|
// if selector is set, we use the selector specified by the user
|
||||||
|
|
||||||
key = selector
|
key = selector
|
||||||
pathLinks[key] = append(pathLinks[key], NewLink(href, text))
|
pathLinks[key] = append(pathLinks[key], NewLink(href, text))
|
||||||
pathCount[key] += 1
|
pathCount[key] += 1
|
||||||
pathMax = key
|
pathMax = key
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// if selector is not set, we compute the selector ourselves
|
// if selector is not set, we compute the selector ourselves
|
||||||
|
|
||||||
class := e.Attr("class")
|
class := e.Attr("class")
|
||||||
// include the element class to make sure we have the same exact path for every link in the table of content
|
// include the element class to make sure we have the same exact path for every link in the table of content
|
||||||
key = fmt.Sprintf("%s.%s", path, class)
|
key = fmt.Sprintf("%s.%s", path, class)
|
||||||
|
|
||||||
// we count this key if the link text is not empty
|
// we count this key if the link text is not empty
|
||||||
if text != "" {
|
if text != "" {
|
||||||
pathLinks[key] = append(pathLinks[key], NewLink(href, text))
|
pathLinks[key] = append(pathLinks[key], NewLink(href, text))
|
||||||
pathCount[key] += len(text)
|
pathCount[key] += len(text)
|
||||||
|
|
||||||
if pathCount[key] > pathCount[pathMax] {
|
if pathCount[key] > pathCount[pathMax] {
|
||||||
pathMax = key
|
pathMax = key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
c.Visit(url.String())
|
c.Visit(url.String())
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ var listCmd = &cobra.Command{
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
links, path, home, err := book.GetLinks(base, listOpts.Selector[0], listOpts.limit, listOpts.offset, listOpts.reverse, listOpts.include)
|
links, path, _, err := book.GetLinks(base, listOpts.Selector[0], listOpts.limit, listOpts.offset, listOpts.reverse, listOpts.include)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -80,8 +80,6 @@ var listCmd = &cobra.Command{
|
|||||||
t.Style().Options.SeparateColumns = false
|
t.Style().Options.SeparateColumns = false
|
||||||
t.Style().Options.SeparateHeader = false
|
t.Style().Options.SeparateHeader = false
|
||||||
|
|
||||||
t.SetTitle(home.Name())
|
|
||||||
|
|
||||||
// format selector path
|
// format selector path
|
||||||
pathArray := strings.Split(path, "<")
|
pathArray := strings.Split(path, "<")
|
||||||
// reverse path
|
// reverse path
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ var versionCmd = &cobra.Command{
|
|||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Print the version number of papeer",
|
Short: "Print the version number of papeer",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
fmt.Println("papeer v0.5.2")
|
fmt.Println("papeer v0.5.0")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
13
release.sh
13
release.sh
@@ -14,14 +14,15 @@ do
|
|||||||
platform_split=(${platform//\// })
|
platform_split=(${platform//\// })
|
||||||
GOOS=${platform_split[0]}
|
GOOS=${platform_split[0]}
|
||||||
GOARCH=${platform_split[1]}
|
GOARCH=${platform_split[1]}
|
||||||
|
output_name=papeer
|
||||||
|
|
||||||
if [ $GOOS = "windows" ]; then
|
if [ $GOOS = "windows" ]; then
|
||||||
env GOOS=$GOOS GOARCH=$GOARCH go build -o papeer.exe
|
env GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name.exe"
|
||||||
zip "papeer-v$version-$GOOS-$GOARCH.exe.zip" papeer.exe
|
zip "$output_name-v$version-$GOOS-$GOARCH.exe.zip" "$output_name.exe"
|
||||||
rm papeer.exe
|
rm "$output_name.exe"
|
||||||
else
|
else
|
||||||
env GOOS=$GOOS GOARCH=$GOARCH go build -o papeer
|
env GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name"
|
||||||
tar czvf "papeer-v$version-$GOOS-$GOARCH.tar.gz" papeer
|
tar czvf "$output_name-v$version-$GOOS-$GOARCH.tar.gz" "$output_name"
|
||||||
rm papeer
|
rm "$output_name"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user