mirror of
https://github.com/NohamR/papeer.git
synced 2026-05-25 20:00:47 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4521497d12 |
11
book/link.go
11
book/link.go
@@ -1,10 +1,13 @@
|
|||||||
package book
|
package book
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type link struct {
|
type link struct {
|
||||||
Href string `json:"url"`
|
Href string `json:"url"`
|
||||||
Text string `json:"name"`
|
Text string `json:"name"`
|
||||||
|
Date *time.Time `json:"date"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLink(href, text string) link {
|
func NewLink(href, text string, date *time.Time) link {
|
||||||
return link{href, text}
|
return link{href, text, date}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
links = append(links, NewLink(u.String(), item.Title))
|
links = append(links, NewLink(u.String(), item.Title, item.PublishedParsed))
|
||||||
}
|
}
|
||||||
|
|
||||||
pathMax = "RSS"
|
pathMax = "RSS"
|
||||||
@@ -405,7 +405,7 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
|||||||
// 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, &time.Time{}))
|
||||||
pathCount[key] += 1
|
pathCount[key] += 1
|
||||||
pathMax = key
|
pathMax = key
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
|||||||
|
|
||||||
// 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, &time.Time{}))
|
||||||
pathCount[key] += len(text)
|
pathCount[key] += len(text)
|
||||||
|
|
||||||
if pathCount[key] > pathCount[pathMax] {
|
if pathCount[key] > pathCount[pathMax] {
|
||||||
@@ -449,7 +449,7 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
|||||||
|
|
||||||
// include home page
|
// include home page
|
||||||
if include {
|
if include {
|
||||||
l := NewLink(url.String(), home.Name())
|
l := NewLink(url.String(), home.Name(), &time.Time{})
|
||||||
links = append([]link{l}, links...)
|
links = append([]link{l}, links...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.8.0")
|
fmt.Println("papeer v0.8.1")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user