Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 45 additions & 12 deletions feedparser/lib/feedparser/builder/microformats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ def build_feed( h )

feed = Feed.new
feed.format = 'html'

### todo: add
## - feed.title
## - feed.url
## - feed.feed_url
## - feed.summary
## - feed.authors
## etc.
feed.title = hy.title
feed.url = hy.url
feed.feed_url = hy.feed_url
feed.summary = hy.summary
feed.authors = hy.authors

hy.entries.each do |entry|
feed.items << build_item( entry )
Expand All @@ -55,9 +52,7 @@ def build_author( hy )
author = Author.new

author.name = hy.name

## todo - add:
## author.url
author.url = hy.url

author
end
Expand Down Expand Up @@ -91,10 +86,25 @@ def build_item( hy )


class HyFeed
attr_accessor :name
attr_accessor :summary

attr_accessor :url

attr_accessor :authors
attr_accessor :entries

# note: title is an alias for name
alias :title :name
alias :title= :name=

# note: in h-feeds, the feed url is the same as the site url
alias :feed_url :url
alias :feed_url= :url=

def initialize
@entries = []
@entries = []
@authors = []
end
end # class HyFeed

Expand Down Expand Up @@ -178,6 +188,28 @@ def build_feed( h )

feed = HyFeed.new

props = h['properties']

if props['name']
feed.name = props['name'].join( ' ')
end

url_str = props.fetch( 'url', [] )[0]
if url_str
entry.url = url_str
end

if props['summary']
entry.summary = props['summary'].join( ' ' )
end

if props['author']
props['author'].each do |author_hash|
pp author_hash
entry.authors << build_author( author_hash )
end
end

h['children'].each_with_index do |item_hash,i|
puts "item #{i+1}:"
pp item_hash
Expand Down Expand Up @@ -252,6 +284,7 @@ def build_author( h )

author.name = h['value']

## todo: read author url
## todo/fix: -- note: for now skip possible embedded h-card
author
end # method build_author
Expand Down