Closed infominer33 closed 3 years ago
A feed item usually has at least two dates:
Here's the entry from the post from the youtube feed in xml:
<published>2019-11-29T04:05:38+00:00</published>
<updated>2020-08-25T23:25:40+00:00</updated>
As far as I can tell you sort by updated BUT in your template - please check - you print the published date and NOT the updated date - try to change to update to fix.
In the template, there doesn't seem to be any sorting method, but somehow they just automagically print in reverse chronological order.
<%
items = site.items.latest.limit(250)
ItemCursor.new( items ).each do |item, new_date, new_feed|
%>
<% if new_date %>
<h2 class='new-date'>
<%= item.published.strftime('%A, %d. %B %Y') %>
</h2>
<% else %>
<hr class='item-seperator'>
<% end %>
With a simple sort_by I can force these youtube feeds into shape :)
<%
items = site.items.latest.limit(250)
sorted = items.sort_by { |k| k["published"] }.reverse
ItemCursor.new( sorted ).each do |item, new_date, new_feed|
%>
that was too easy.. I still dont' get how they usually stay sort.. I suppose like you say by 'updated' but I think blog posts are more frequently updated than youtube videos, and I never seen this before.
Thanks for the update. I think inside latest the sort (auto-magically) happens. See https://github.com/feedreader/pluto/blob/master/newscast/lib/newscast.rb#L266 and this line if I am not mistaken:
rec.items.order(
Arel.sql( "coalesce(items.updated,items.published,'1970-01-01') desc" )
)
Cheers. Prosit 2021!
Trying to build a page for youtube feeds, but they don't print in chronological order:
This is with the same template that's running my other feeds that are coming out fine.
https://identosphere.net/blogcatcher/test/
I tried looking at the youtube feed, but nothing really jumps out at me why it shouldn't print correctly: