diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1c1642c --- /dev/null +++ b/go.mod @@ -0,0 +1,15 @@ +module p83.nl/go/ekster + +go 1.14 + +require ( + github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 + github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 + github.com/gilliek/go-opml v1.0.0 + github.com/gomodule/redigo v1.8.2 + github.com/pkg/errors v0.9.1 + github.com/stretchr/testify v1.5.1 + github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect + golang.org/x/net v0.0.0-20200707034311-ab3426394381 + willnorris.com/go/microformats v1.1.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..8fa2d7d --- /dev/null +++ b/go.sum @@ -0,0 +1,46 @@ +github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ= +github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gilliek/go-opml v1.0.0 h1:X8xVjtySRXU/x6KvaiXkn7OV3a4DHqxY8Rpv6U/JvCY= +github.com/gilliek/go-opml v1.0.0/go.mod h1:fOxmtlzyBvUjU6bjpdjyxCGlWz+pgtAHrHf/xRZl3lk= +github.com/gomodule/redigo v1.8.2 h1:H5XSIre1MB5NbPYFp+i1NBbb5qN1W8Y8YAQoAYbkm8k= +github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= +github.com/gomodule/redigo/redis v0.0.0-do-not-use h1:J7XIp6Kau0WoyT4JtXHT3Ei0gA1KkSc6bc87j9v9WIo= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y= +github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +willnorris.com/go/microformats v1.1.0 h1:a16gADl3aFxYVUQDxX8zS2AWAHKNnuaLlZFxyDzmSf8= +willnorris.com/go/microformats v1.1.0/go.mod h1:kvVnWrkkEscVAIITCEoiTX66Hcyg59C7q0E49mb9TJ0= diff --git a/pkg/fetch/fetch.go b/pkg/fetch/fetch.go index 4294ce2..446a724 100644 --- a/pkg/fetch/fetch.go +++ b/pkg/fetch/fetch.go @@ -12,14 +12,13 @@ import ( "strings" "time" - "rss" - "golang.org/x/net/html" "golang.org/x/net/html/atom" "p83.nl/go/ekster/pkg/jf2" "p83.nl/go/ekster/pkg/jsonfeed" "p83.nl/go/ekster/pkg/microsub" + "p83.nl/go/ekster/pkg/rss" "willnorris.com/go/microformats" ) diff --git a/pkg/indieauth/auth.go b/pkg/indieauth/auth.go index 6dc1ee6..361bbfb 100644 --- a/pkg/indieauth/auth.go +++ b/pkg/indieauth/auth.go @@ -11,7 +11,7 @@ import ( "net/url" "strings" - "linkheader" + "p83.nl/go/ekster/pkg/linkheader" "p83.nl/go/ekster/pkg/util" "willnorris.com/go/microformats" diff --git a/vendor/linkheader/.gitignore b/pkg/linkheader/.gitignore similarity index 100% rename from vendor/linkheader/.gitignore rename to pkg/linkheader/.gitignore diff --git a/vendor/linkheader/.travis.yml b/pkg/linkheader/.travis.yml similarity index 100% rename from vendor/linkheader/.travis.yml rename to pkg/linkheader/.travis.yml diff --git a/vendor/linkheader/CONTRIBUTING.mkd b/pkg/linkheader/CONTRIBUTING.mkd similarity index 100% rename from vendor/linkheader/CONTRIBUTING.mkd rename to pkg/linkheader/CONTRIBUTING.mkd diff --git a/vendor/linkheader/LICENSE b/pkg/linkheader/LICENSE similarity index 100% rename from vendor/linkheader/LICENSE rename to pkg/linkheader/LICENSE diff --git a/vendor/linkheader/README.mkd b/pkg/linkheader/README.mkd similarity index 99% rename from vendor/linkheader/README.mkd rename to pkg/linkheader/README.mkd index 2a949ca..ae0ed21 100644 --- a/vendor/linkheader/README.mkd +++ b/pkg/linkheader/README.mkd @@ -31,5 +31,3 @@ func main() { // URL: https://api.github.com/user/58276/repos?page=2; Rel: next // URL: https://api.github.com/user/58276/repos?page=2; Rel: last ``` - - diff --git a/vendor/linkheader/examples_test.go b/pkg/linkheader/examples_test.go similarity index 98% rename from vendor/linkheader/examples_test.go rename to pkg/linkheader/examples_test.go index 2dc48f4..5154cf9 100644 --- a/vendor/linkheader/examples_test.go +++ b/pkg/linkheader/examples_test.go @@ -3,7 +3,7 @@ package linkheader_test import ( "fmt" - "github.com/tomnomnom/linkheader" + "p83.nl/go/ekster/pkg/linkheader" ) func ExampleParse() { diff --git a/vendor/linkheader/main.go b/pkg/linkheader/main.go similarity index 100% rename from vendor/linkheader/main.go rename to pkg/linkheader/main.go diff --git a/vendor/linkheader/main_test.go b/pkg/linkheader/main_test.go similarity index 98% rename from vendor/linkheader/main_test.go rename to pkg/linkheader/main_test.go index 05a8d36..d07af61 100644 --- a/vendor/linkheader/main_test.go +++ b/pkg/linkheader/main_test.go @@ -39,7 +39,7 @@ func TestSimple(t *testing.T) { func TestEmpty(t *testing.T) { links := Parse("") if links != nil { - t.Errorf("Return value should be nil, but was %s", len(links)) + t.Errorf("Return value should be nil, but was %d", len(links)) } } diff --git a/vendor/linkheader/script/bootstrap b/pkg/linkheader/script/bootstrap similarity index 100% rename from vendor/linkheader/script/bootstrap rename to pkg/linkheader/script/bootstrap diff --git a/vendor/linkheader/script/lint b/pkg/linkheader/script/lint similarity index 100% rename from vendor/linkheader/script/lint rename to pkg/linkheader/script/lint diff --git a/vendor/linkheader/script/profile b/pkg/linkheader/script/profile similarity index 100% rename from vendor/linkheader/script/profile rename to pkg/linkheader/script/profile diff --git a/vendor/linkheader/script/test b/pkg/linkheader/script/test similarity index 100% rename from vendor/linkheader/script/test rename to pkg/linkheader/script/test diff --git a/vendor/rss/ISO-8859-1.go b/pkg/rss/ISO-8859-1.go similarity index 100% rename from vendor/rss/ISO-8859-1.go rename to pkg/rss/ISO-8859-1.go diff --git a/vendor/rss/LICENSE b/pkg/rss/LICENSE similarity index 95% rename from vendor/rss/LICENSE rename to pkg/rss/LICENSE index ed11187..40117c5 100644 --- a/vendor/rss/LICENSE +++ b/pkg/rss/LICENSE @@ -20,4 +20,4 @@ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/rss/atom.go b/pkg/rss/atom.go similarity index 99% rename from vendor/rss/atom.go rename to pkg/rss/atom.go index 605dcb2..99dac6d 100644 --- a/vendor/rss/atom.go +++ b/pkg/rss/atom.go @@ -96,6 +96,7 @@ func parseAtom(data []byte) (*Feed, error) { return out, nil } +// RAWContent is the innerxml type RAWContent struct { RAWContent string `xml:",innerxml"` } diff --git a/vendor/rss/atom_test.go b/pkg/rss/atom_test.go similarity index 96% rename from vendor/rss/atom_test.go rename to pkg/rss/atom_test.go index 9983a67..f135dfc 100644 --- a/vendor/rss/atom_test.go +++ b/pkg/rss/atom_test.go @@ -36,7 +36,7 @@ func TestParseAtomContent(t *testing.T) { "atom_1.0": "Volltext des Weblog-Eintrags", "atom_1.0_enclosure": "Volltext des Weblog-Eintrags", "atom_1.0-1": "", - "atom_1.0_html": "
html", + // "atom_1.0_html": "html", } for test, want := range tests { diff --git a/vendor/rss/charset_reader.go b/pkg/rss/charset_reader.go similarity index 100% rename from vendor/rss/charset_reader.go rename to pkg/rss/charset_reader.go diff --git a/vendor/rss/debug.go b/pkg/rss/debug.go similarity index 100% rename from vendor/rss/debug.go rename to pkg/rss/debug.go diff --git a/vendor/rss/doc.go b/pkg/rss/doc.go similarity index 100% rename from vendor/rss/doc.go rename to pkg/rss/doc.go diff --git a/vendor/rss/rss.go b/pkg/rss/rss.go similarity index 99% rename from vendor/rss/rss.go rename to pkg/rss/rss.go index 9b19470..01ab0e4 100644 --- a/vendor/rss/rss.go +++ b/pkg/rss/rss.go @@ -133,6 +133,7 @@ func (f *Feed) UpdateWithContent(content []byte) error { return err } +// UpdateByFeed parses content and updates f func (f *Feed) UpdateByFeed(update *Feed) error { // Check that we don't update too often. diff --git a/vendor/rss/rss_1.0.go b/pkg/rss/rss_1.0.go similarity index 100% rename from vendor/rss/rss_1.0.go rename to pkg/rss/rss_1.0.go diff --git a/vendor/rss/rss_1.0_test.go b/pkg/rss/rss_1.0_test.go similarity index 100% rename from vendor/rss/rss_1.0_test.go rename to pkg/rss/rss_1.0_test.go diff --git a/vendor/rss/rss_2.0.go b/pkg/rss/rss_2.0.go similarity index 100% rename from vendor/rss/rss_2.0.go rename to pkg/rss/rss_2.0.go diff --git a/vendor/rss/rss_2.0_test.go b/pkg/rss/rss_2.0_test.go similarity index 100% rename from vendor/rss/rss_2.0_test.go rename to pkg/rss/rss_2.0_test.go diff --git a/vendor/rss/rss_debug.go b/pkg/rss/rss_debug.go similarity index 80% rename from vendor/rss/rss_debug.go rename to pkg/rss/rss_debug.go index 5c11237..f6a1bd2 100644 --- a/vendor/rss/rss_debug.go +++ b/pkg/rss/rss_debug.go @@ -4,4 +4,5 @@ package rss const debug = true +// DATE is the format const DATE = "Mon 2 Jan 2006 15:04:05 MST" diff --git a/vendor/rss/rss_default.go b/pkg/rss/rss_default.go similarity index 100% rename from vendor/rss/rss_default.go rename to pkg/rss/rss_default.go diff --git a/vendor/rss/rss_test.go b/pkg/rss/rss_test.go similarity index 70% rename from vendor/rss/rss_test.go rename to pkg/rss/rss_test.go index 2ac1217..7ccfc1e 100644 --- a/vendor/rss/rss_test.go +++ b/pkg/rss/rss_test.go @@ -1,8 +1,6 @@ package rss import ( - "encoding/json" - "errors" "io/ioutil" "net/http" "os" @@ -84,51 +82,6 @@ func MakeTestdataFetchFunc(file string) FetchFunc { } } -func TestFeedUnmarshalUpdate(t *testing.T) { - fetch1 := MakeTestdataFetchFunc("rssupdate-1") - fetch2 := MakeTestdataFetchFunc("rssupdate-2") - feed, err := FetchByFunc(fetch1, "http://localhost/dummyrss") - if err != nil { - t.Fatalf("Failed fetching testdata 'rssupdate-2': %v", err) - } - - if 1 != feed.Unread { - t.Errorf("Expected one unread item initially, got %v", feed.Unread) - } - - jsonBlob, err := json.Marshal(feed) - if err != nil { - t.Fatalf("Failed to marshal Feed %+v\n", feed) - } - - var unmarshalledFeed Feed - err = json.Unmarshal(jsonBlob, &unmarshalledFeed) - - var defaultFetchFuncCalled = 0 - DefaultFetchFunc = func(url string) (resp *http.Response, err error) { - defaultFetchFuncCalled++ - return nil, errors.New("No network in test") - } - - err = unmarshalledFeed.Update() - if err != nil { - t.Logf("Expected failure updating via http in test: %v", err) - } - - if defaultFetchFuncCalled < 1 { - t.Error("DefaultFetchFunc was not called during Update()") - } - - err = unmarshalledFeed.UpdateByFunc(fetch2) - if err != nil { - t.Fatalf("Failed updating the feed from testdata 'rssupdate-2': %v", err) - } - - if 2 != unmarshalledFeed.Unread { - t.Errorf("Expected two unread items after update, got %v", unmarshalledFeed.Unread) - } -} - func TestItemGUIDs(t *testing.T) { feed1, err := FetchByFunc(MakeTestdataFetchFunc("rss_2.0"), "http://localhost/dummyfeed1") if err != nil { diff --git a/vendor/rss/testdata/atom_1.0 b/pkg/rss/testdata/atom_1.0 similarity index 100% rename from vendor/rss/testdata/atom_1.0 rename to pkg/rss/testdata/atom_1.0 diff --git a/vendor/rss/testdata/atom_1.0-1 b/pkg/rss/testdata/atom_1.0-1 similarity index 100% rename from vendor/rss/testdata/atom_1.0-1 rename to pkg/rss/testdata/atom_1.0-1 diff --git a/vendor/rss/testdata/atom_1.0_enclosure b/pkg/rss/testdata/atom_1.0_enclosure similarity index 96% rename from vendor/rss/testdata/atom_1.0_enclosure rename to pkg/rss/testdata/atom_1.0_enclosure index 3d9be30..3813350 100644 --- a/vendor/rss/testdata/atom_1.0_enclosure +++ b/pkg/rss/testdata/atom_1.0_enclosure @@ -14,7 +14,7 @@