From 6e2cb00008cbf09e556b00f87603797fcaa47e09 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 16 Apr 2018 05:37:14 -0700 Subject: Depenancy upgrades and movign to dep. (#8630) --- vendor/github.com/dyatlov/go-opengraph/.gitignore | 24 ---- vendor/github.com/dyatlov/go-opengraph/README.md | 118 ------------------- .../dyatlov/go-opengraph/examples/advanced.go | 58 --------- .../dyatlov/go-opengraph/examples/simple.go | 27 ----- .../dyatlov/go-opengraph/opengraph/opengraph.go | 3 +- .../go-opengraph/opengraph/opengraph_test.go | 131 --------------------- 6 files changed, 1 insertion(+), 360 deletions(-) delete mode 100644 vendor/github.com/dyatlov/go-opengraph/.gitignore delete mode 100644 vendor/github.com/dyatlov/go-opengraph/README.md delete mode 100644 vendor/github.com/dyatlov/go-opengraph/examples/advanced.go delete mode 100644 vendor/github.com/dyatlov/go-opengraph/examples/simple.go delete mode 100644 vendor/github.com/dyatlov/go-opengraph/opengraph/opengraph_test.go (limited to 'vendor/github.com/dyatlov') diff --git a/vendor/github.com/dyatlov/go-opengraph/.gitignore b/vendor/github.com/dyatlov/go-opengraph/.gitignore deleted file mode 100644 index daf913b1b..000000000 --- a/vendor/github.com/dyatlov/go-opengraph/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/dyatlov/go-opengraph/README.md b/vendor/github.com/dyatlov/go-opengraph/README.md deleted file mode 100644 index 8c8e00212..000000000 --- a/vendor/github.com/dyatlov/go-opengraph/README.md +++ /dev/null @@ -1,118 +0,0 @@ -Go OpenGraph -=== - -Parses given html data into Facebook OpenGraph structure. - -To download and install this package run: - -`go get github.com/dyatlov/go-opengraph/opengraph` - -Methods: - - * `NewOpenGraph()` - create a new OpenGraph instance - * `ProcessHTML(buffer io.Reader) error` - process given html into underlying data structure - * `ProcessMeta(metaAttrs map[string]string)` - add data to the structure based on meta attributes - * `ToJSON() (string, error)` - return JSON representation of data or error - * `String() string` - return JSON representation of structure - -Source docs: http://godoc.org/github.com/dyatlov/go-opengraph/opengraph - -If you just need to parse an OpenGraph data from HTML then method `ProcessHTML` is your needed one. - -Example: - -```go -package main - -import ( - "fmt" - "strings" - - "github.com/dyatlov/go-opengraph/opengraph" -) - -func main() { - html := ` - - ` - - og := opengraph.NewOpenGraph() - err := og.ProcessHTML(strings.NewReader(html)) - - if err != nil { - fmt.Println(err) - return - } - - fmt.Printf("Type: %s\n", og.Type) - fmt.Printf("Title: %s\n", og.Title) - fmt.Printf("URL: %s\n", og.URL) - fmt.Printf("String/JSON Representation: %s\n", og) -} -``` - -If you have your own parsing engine and just need an intelligent OpenGraph parsing, then `ProcessMeta` is the method you need. -While using this method you don't need to reparse your parsed html again, just feed it with meta atributes as they appear and OpenGraph will be built based on the data. - -Example: - -```go -package main - -import ( - "fmt" - "strings" - - "github.com/dyatlov/go-opengraph/opengraph" - "golang.org/x/net/html" -) - -func main() { - h := ` - - ` - - og := opengraph.NewOpenGraph() - - doc, err := html.Parse(strings.NewReader(h)) - if err != nil { - fmt.Println(err) - return - } - - var parseHead func(*html.Node) - parseHead = func(n *html.Node) { - for c := n.FirstChild; c != nil; c = c.NextSibling { - if c.Type == html.ElementNode && c.Data == "meta" { - m := make(map[string]string) - for _, a := range c.Attr { - m[a.Key] = a.Val - } - - og.ProcessMeta(m) - } - } - } - - var f func(*html.Node) - f = func(n *html.Node) { - for c := n.FirstChild; c != nil; c = c.NextSibling { - if c.Type == html.ElementNode { - if c.Data == "head" { - parseHead(c) - continue - } else if c.Data == "body" { // OpenGraph is only in head, so we don't need body - break - } - } - f(c) - } - } - f(doc) - - fmt.Printf("Type: %s\n", og.Type) - fmt.Printf("Title: %s\n", og.Title) - fmt.Printf("URL: %s\n", og.URL) - fmt.Printf("String/JSON Representation: %s\n", og) -} -``` diff --git a/vendor/github.com/dyatlov/go-opengraph/examples/advanced.go b/vendor/github.com/dyatlov/go-opengraph/examples/advanced.go deleted file mode 100644 index e24b821e7..000000000 --- a/vendor/github.com/dyatlov/go-opengraph/examples/advanced.go +++ /dev/null @@ -1,58 +0,0 @@ -package main - -import ( - "fmt" - "strings" - - "github.com/dyatlov/go-opengraph/opengraph" - "golang.org/x/net/html" -) - -func main() { - h := ` - - ` - - og := opengraph.NewOpenGraph() - - doc, err := html.Parse(strings.NewReader(h)) - if err != nil { - fmt.Println(err) - return - } - - var parseHead func(*html.Node) - parseHead = func(n *html.Node) { - for c := n.FirstChild; c != nil; c = c.NextSibling { - if c.Type == html.ElementNode && c.Data == "meta" { - m := make(map[string]string) - for _, a := range c.Attr { - m[a.Key] = a.Val - } - - og.ProcessMeta(m) - } - } - } - - var f func(*html.Node) - f = func(n *html.Node) { - for c := n.FirstChild; c != nil; c = c.NextSibling { - if c.Type == html.ElementNode { - if c.Data == "head" { - parseHead(c) - continue - } else if c.Data == "body" { // OpenGraph is only in head, so we don't need body - break - } - } - f(c) - } - } - f(doc) - - fmt.Printf("Type: %s\n", og.Type) - fmt.Printf("Title: %s\n", og.Title) - fmt.Printf("URL: %s\n", og.URL) - fmt.Printf("String/JSON Representation: %s\n", og) -} diff --git a/vendor/github.com/dyatlov/go-opengraph/examples/simple.go b/vendor/github.com/dyatlov/go-opengraph/examples/simple.go deleted file mode 100644 index fa128cd43..000000000 --- a/vendor/github.com/dyatlov/go-opengraph/examples/simple.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "fmt" - "strings" - - "github.com/dyatlov/go-opengraph/opengraph" -) - -func main() { - html := ` - - ` - - og := opengraph.NewOpenGraph() - err := og.ProcessHTML(strings.NewReader(html)) - - if err != nil { - fmt.Println(err) - return - } - - fmt.Printf("Type: %s\n", og.Type) - fmt.Printf("Title: %s\n", og.Title) - fmt.Printf("URL: %s\n", og.URL) - fmt.Printf("String/JSON Representation: %s\n", og) -} diff --git a/vendor/github.com/dyatlov/go-opengraph/opengraph/opengraph.go b/vendor/github.com/dyatlov/go-opengraph/opengraph/opengraph.go index 5468d86bb..21eccf0ae 100644 --- a/vendor/github.com/dyatlov/go-opengraph/opengraph/opengraph.go +++ b/vendor/github.com/dyatlov/go-opengraph/opengraph/opengraph.go @@ -131,7 +131,6 @@ func (og *OpenGraph) ProcessHTML(buffer io.Reader) error { og.ProcessMeta(m) } } - return nil } // ProcessMeta processes meta attributes and adds them to Open Graph structure if they are suitable for that @@ -248,7 +247,7 @@ func (og *OpenGraph) processArticleMeta(metaAttrs map[string]string) { if err == nil { og.Article.ExpirationTime = &t } - case "article:secttion": + case "article:section": og.Article.Section = metaAttrs["content"] case "article:tag": og.Article.Tags = append(og.Article.Tags, metaAttrs["content"]) diff --git a/vendor/github.com/dyatlov/go-opengraph/opengraph/opengraph_test.go b/vendor/github.com/dyatlov/go-opengraph/opengraph/opengraph_test.go deleted file mode 100644 index 6af7f25d2..000000000 --- a/vendor/github.com/dyatlov/go-opengraph/opengraph/opengraph_test.go +++ /dev/null @@ -1,131 +0,0 @@ -package opengraph_test - -import ( - "strings" - "testing" - "time" - - "github.com/dyatlov/go-opengraph/opengraph" -) - -const html = ` - - - - - -WordPress › WordPress 4.3 “Billie” - - - - - - - - - - - - - - - ` - -func BenchmarkOpenGraph_ProcessHTML(b *testing.B) { - og := opengraph.NewOpenGraph() - b.ReportAllocs() - b.SetBytes(int64(len(html))) - for i := 0; i < b.N; i++ { - if err := og.ProcessHTML(strings.NewReader(html)); err != nil { - b.Fatal(err) - } - } -} - -func TestOpenGraphProcessHTML(t *testing.T) { - og := opengraph.NewOpenGraph() - err := og.ProcessHTML(strings.NewReader(html)) - - if err != nil { - t.Fatal(err) - } - - if og.Type != "article" { - t.Error("type parsed incorrectly") - } - - if len(og.Title) == 0 { - t.Error("title parsed incorrectly") - } - - if len(og.URL) == 0 { - t.Error("url parsed incorrectly") - } - - if len(og.Description) == 0 { - t.Error("description parsed incorrectly") - } - - if len(og.Images) == 0 { - t.Error("images parsed incorrectly") - } else { - if len(og.Images[0].URL) == 0 { - t.Error("image url parsed incorrectly") - } - } - - if len(og.Locale) == 0 { - t.Error("locale parsed incorrectly") - } - - if len(og.SiteName) == 0 { - t.Error("site name parsed incorrectly") - } - - if og.Article == nil { - t.Error("articles parsed incorrectly") - } else { - ev, _ := time.Parse(time.RFC3339, "2015-08-18T19:12:38+00:00") - if !og.Article.PublishedTime.Equal(ev) { - t.Error("article published time parsed incorrectly") - } - } -} - -func TestOpenGraphProcessMeta(t *testing.T) { - og := opengraph.NewOpenGraph() - - og.ProcessMeta(map[string]string{"property": "og:type", "content": "book"}) - - if og.Type != "book" { - t.Error("wrong og:type processing") - } - - og.ProcessMeta(map[string]string{"property": "book:isbn", "content": "123456"}) - - if og.Book == nil { - t.Error("wrong book type processing") - } else { - if og.Book.ISBN != "123456" { - t.Error("wrong book isbn processing") - } - } - - og.ProcessMeta(map[string]string{"property": "article:section", "content": "testsection"}) - - if og.Article != nil { - t.Error("article processed when it should not be") - } - - og.ProcessMeta(map[string]string{"property": "book:author:first_name", "content": "John"}) - - if og.Book != nil { - if len(og.Book.Authors) == 0 { - t.Error("book author was not processed") - } else { - if og.Book.Authors[0].FirstName != "John" { - t.Error("author first name was processed incorrectly") - } - } - } -} -- cgit v1.2.3-1-g7c22