mirror of
https://github.com/go-shiori/shiori.git
synced 2024-11-13 04:35:28 +08:00
Use git submodule
This commit is contained in:
parent
bb0d9439f2
commit
6ee5c22ae6
4 changed files with 4 additions and 1268 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "readability"]
|
||||
path = readability
|
||||
url = https://github.com/RadhiFadlillah/go-readability
|
1
readability
Submodule
1
readability
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 7283f7b58bc8f5fbc02b05e45faf37267e30dd42
|
1195
readability/read.go
1195
readability/read.go
File diff suppressed because it is too large
Load diff
|
@ -1,73 +0,0 @@
|
|||
package readability
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
func createDocFromFile(path string) (*goquery.Document, error) {
|
||||
// Open file
|
||||
src, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer src.Close()
|
||||
|
||||
// Create document
|
||||
return goquery.NewDocumentFromReader(src)
|
||||
}
|
||||
|
||||
func hashNode(node *goquery.Selection) string {
|
||||
if node == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
html, _ := node.Html()
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(html)))
|
||||
}
|
||||
|
||||
func strLen(str string) int {
|
||||
return utf8.RuneCountInString(str)
|
||||
}
|
||||
|
||||
func findSeparator(str string, separators ...string) (int, string) {
|
||||
words := strings.Fields(str)
|
||||
for i, word := range words {
|
||||
for _, separator := range separators {
|
||||
if word == separator {
|
||||
return i, separator
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1, ""
|
||||
}
|
||||
|
||||
func hasSeparator(str string, separators ...string) bool {
|
||||
idx, _ := findSeparator(str, separators...)
|
||||
return idx != -1
|
||||
}
|
||||
|
||||
func removeSeparator(str string, separators ...string) string {
|
||||
words := strings.Fields(str)
|
||||
finalWords := []string{}
|
||||
|
||||
for _, word := range words {
|
||||
for _, separator := range separators {
|
||||
if word != separator {
|
||||
finalWords = append(finalWords, word)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strings.Join(finalWords, " ")
|
||||
}
|
||||
|
||||
func normalizeText(str string) string {
|
||||
return strings.Join(strings.Fields(str), " ")
|
||||
}
|
Loading…
Reference in a new issue