1 Commits

Author SHA1 Message Date
lapwat
108e1bdd1a handle RSS feed, add CI 2022-03-02 19:06:55 +01:00
6 changed files with 22 additions and 33 deletions

View File

@@ -9,16 +9,6 @@ jobs:
test:
runs-on: ubuntu-latest
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
uses: actions/checkout@v2
- name: Test

View File

@@ -138,7 +138,7 @@ go get -u github.com/lapwat/papeer
```sh
# use platform=darwin for MacOS
platform=linux
release=0.5.2
release=0.5.0
# download and extract
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
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

View File

@@ -398,11 +398,11 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
selector = "a"
selectorSet = false
}
pathLinks := map[string][]link{}
pathCount := map[string]int{}
pathMax = ""
// visit and count link classes
c := colly.NewCollector()
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)
path := GetPath(e.DOM)
key := path
if selectorSet {
// if selector is set, we use the selector specified by the user
key = selector
pathLinks[key] = append(pathLinks[key], NewLink(href, text))
pathCount[key] += 1
pathMax = key
} else {
// if selector is not set, we compute the selector ourselves
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
key = fmt.Sprintf("%s.%s", path, class)
// we count this key if the link text is not empty
if text != "" {
pathLinks[key] = append(pathLinks[key], NewLink(href, text))
pathCount[key] += len(text)
if pathCount[key] > pathCount[pathMax] {
pathMax = key
}
}
}
})
c.Visit(url.String())

View File

@@ -69,7 +69,7 @@ var listCmd = &cobra.Command{
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 {
log.Fatal(err)
}
@@ -80,8 +80,6 @@ var listCmd = &cobra.Command{
t.Style().Options.SeparateColumns = false
t.Style().Options.SeparateHeader = false
t.SetTitle(home.Name())
// format selector path
pathArray := strings.Split(path, "<")
// reverse path

View File

@@ -14,6 +14,6 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of papeer",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("papeer v0.5.2")
fmt.Println("papeer v0.5.0")
},
}

View File

@@ -14,14 +14,15 @@ do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=papeer
if [ $GOOS = "windows" ]; then
env GOOS=$GOOS GOARCH=$GOARCH go build -o papeer.exe
zip "papeer-v$version-$GOOS-$GOARCH.exe.zip" papeer.exe
rm papeer.exe
env GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name.exe"
zip "$output_name-v$version-$GOOS-$GOARCH.exe.zip" "$output_name.exe"
rm "$output_name.exe"
else
env GOOS=$GOOS GOARCH=$GOARCH go build -o papeer
tar czvf "papeer-v$version-$GOOS-$GOARCH.tar.gz" papeer
rm papeer
env GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name"
tar czvf "$output_name-v$version-$GOOS-$GOARCH.tar.gz" "$output_name"
rm "$output_name"
fi
done