mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
rdf date & content
This commit is contained in:
parent
d308bb64c2
commit
f8455236dc
@ -20,8 +20,8 @@ type rdfItem struct {
|
||||
Link string `xml:"link"`
|
||||
Description string `xml:"description"`
|
||||
|
||||
DublinCoreDate string `xml:"http://purl.org/dc/elements/1.1/ date"`
|
||||
DublinCoreContent string `xml:"http://purl.org/rss/1.0/modules/content/ encoded"`
|
||||
DublinCoreDate string `xml:"http://purl.org/dc/elements/1.1/ date"`
|
||||
ContentEncoded string `xml:"http://purl.org/rss/1.0/modules/content/ encoded"`
|
||||
}
|
||||
|
||||
func ParseRDF(r io.Reader) (*Feed, error) {
|
||||
@ -38,9 +38,11 @@ func ParseRDF(r io.Reader) (*Feed, error) {
|
||||
}
|
||||
for _, srcitem := range srcfeed.Items {
|
||||
dstfeed.Items = append(dstfeed.Items, Item{
|
||||
GUID: srcitem.Link,
|
||||
URL: srcitem.Link,
|
||||
Title: srcitem.Title,
|
||||
GUID: srcitem.Link,
|
||||
URL: srcitem.Link,
|
||||
Date: dateParse(srcitem.DublinCoreDate),
|
||||
Title: srcitem.Title,
|
||||
Content: srcitem.ContentEncoded,
|
||||
})
|
||||
}
|
||||
return dstfeed, nil
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRDFFeed(t *testing.T) {
|
||||
@ -52,3 +53,29 @@ func TestRDFFeed(t *testing.T) {
|
||||
t.Fatal("invalid rdf")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRDFExtensions(t *testing.T) {
|
||||
have, _ := Parse(strings.NewReader(`
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rdf:RDF xmlns="http://purl.org/rss/1.0/"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/">
|
||||
<item>
|
||||
<dc:date>2006-01-02T15:04:05-07:00</dc:date>
|
||||
<content:encoded><![CDATA[test]]></content:encoded>
|
||||
</item>
|
||||
</rdf:RDF>
|
||||
`))
|
||||
date, _ := time.Parse(time.RFC1123Z, time.RFC1123Z)
|
||||
want := &Feed{
|
||||
Items: []Item{
|
||||
{Content: "test", Date: date},
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(want, have) {
|
||||
t.Logf("want: %#v", want)
|
||||
t.Logf("have: %#v", have)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user