mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Add support for Dublin Core date in RDF feeds
This commit is contained in:
parent
15202b8675
commit
dcbb5047b1
2 changed files with 73 additions and 1 deletions
|
@ -10,7 +10,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/miniflux/miniflux/crypto"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
"github.com/miniflux/miniflux/model"
|
||||
"github.com/miniflux/miniflux/reader/date"
|
||||
"github.com/miniflux/miniflux/reader/sanitizer"
|
||||
"github.com/miniflux/miniflux/url"
|
||||
)
|
||||
|
@ -54,6 +56,7 @@ type rdfItem struct {
|
|||
Link string `xml:"link"`
|
||||
Description string `xml:"description"`
|
||||
Creator string `xml:"creator"`
|
||||
Date string `xml:"date"`
|
||||
}
|
||||
|
||||
func (r *rdfItem) Transform() *model.Entry {
|
||||
|
@ -63,10 +66,24 @@ func (r *rdfItem) Transform() *model.Entry {
|
|||
entry.URL = r.Link
|
||||
entry.Content = r.Description
|
||||
entry.Hash = getHash(r)
|
||||
entry.Date = time.Now()
|
||||
entry.Date = getDate(r)
|
||||
return entry
|
||||
}
|
||||
|
||||
func getDate(r *rdfItem) time.Time {
|
||||
if r.Date != "" {
|
||||
result, err := date.Parse(r.Date)
|
||||
if err != nil {
|
||||
logger.Error("rdf: %v", err)
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
func getHash(r *rdfItem) string {
|
||||
value := r.Link
|
||||
if value == "" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue