diff --git a/feed/export_test.go b/feed/export_test.go deleted file mode 100644 index c5d57e7..0000000 --- a/feed/export_test.go +++ /dev/null @@ -1,4 +0,0 @@ -package feed - -var FetchPage = fetchPage -var ParseTime = parseTime diff --git a/feed/feed.go b/feed/feed.go index 83bdc26..e95fd89 100644 --- a/feed/feed.go +++ b/feed/feed.go @@ -73,6 +73,9 @@ func parseTime(timestr string) (time.Time, error) { time.RFC3339Nano, time.DateTime, time.DateOnly, + "2006-01-02 15:04", + "2006-01-02T15:04:05", + "2006-01-02T15:04", } var pagetime time.Time var err error @@ -115,9 +118,10 @@ func (f *FeedItem) ParseContent(content string) error { } etitle, err := getHtmlElement(doc, "title") if err != nil { - return err + f.Title = "" + } else { + f.Title = etitle.FirstChild.Data } - f.Title = etitle.FirstChild.Data var articleBuilder strings.Builder html.Render(&articleBuilder, earticle) diff --git a/feed/feed_test.go b/feed/feed_test.go index 93d5b5f..a5cbf2e 100644 --- a/feed/feed_test.go +++ b/feed/feed_test.go @@ -3,50 +3,65 @@ package feed_test import ( "testing" "time" - "git.32bit.cafe/yequari/webweav.ing/feed" + "git.32bit.cafe/yequari/webweav.ing/feed" ) -func TestArticleParse(t *testing.T) { - testDate, err := time.Parse("2006-Jan-02", "2004-May-14") +func TestTimeParsing(t *testing.T) { + testDate, err := time.Parse("2006-Jan-02 15:04:05 -7", "2004-May-14 07:30:55 -7") if err != nil { t.Errorf("creating test date failed: %s", err) } + var tests = []struct { name string input string - want_time *time.Time - want_article string + format string }{ { - "article stripped out of basic HTML", - "