4 Commits

Author SHA1 Message Date
lapwat
91d126a667 bump version 2022-03-13 14:29:00 +01:00
lapwat
4d6171544d add ci (#2)
* add ci

* format code

* update go version

* update go file

* add kindlegen

* update go file

* update go file

* test ci

* multiline run

* edit go file

* fix tar

* mv kindlegen to usr local bin
2022-03-13 12:36:58 +01:00
lapwat
53d0dd1360 ls command prints title 2022-03-13 11:52:29 +01:00
lapwat
13c9138d01 handle RSS feed 2022-03-02 19:13:43 +01:00
6 changed files with 33 additions and 22 deletions

View File

@@ -9,6 +9,16 @@ 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

View File

@@ -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.0 release=0.5.2
# 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.0/papeer-v0.5.0-windows-amd64.exe.zip). Download [latest release](https://github.com/lapwat/papeer/releases/download/v0.5.2/papeer-v0.5.2-windows-amd64.exe.zip).
## MOBI support ## MOBI support

View File

@@ -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())

View File

@@ -69,7 +69,7 @@ var listCmd = &cobra.Command{
log.Fatal(err) log.Fatal(err)
} }
links, path, _, err := book.GetLinks(base, listOpts.Selector[0], listOpts.limit, listOpts.offset, listOpts.reverse, listOpts.include) links, path, home, 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,6 +80,8 @@ 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

View File

@@ -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.0") fmt.Println("papeer v0.5.2")
}, },
} }

View File

@@ -14,15 +14,14 @@ 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 "$output_name.exe" env GOOS=$GOOS GOARCH=$GOARCH go build -o papeer.exe
zip "$output_name-v$version-$GOOS-$GOARCH.exe.zip" "$output_name.exe" zip "papeer-v$version-$GOOS-$GOARCH.exe.zip" papeer.exe
rm "$output_name.exe" rm papeer.exe
else else
env GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name" env GOOS=$GOOS GOARCH=$GOARCH go build -o papeer
tar czvf "$output_name-v$version-$GOOS-$GOARCH.tar.gz" "$output_name" tar czvf "papeer-v$version-$GOOS-$GOARCH.tar.gz" papeer
rm "$output_name" rm papeer
fi fi
done done