Feed fixes

main
Astoria 2 years ago
parent b206070606
commit 1b004404b4

@ -76,7 +76,8 @@ get '/contact' do
end
get '/feed' do
erb :feed, locals: {folders: ["media", "technology", "news"]}
content_type 'application/rss+xml'
return ERB.new(File.read("./views/feed.erb"), trim_mode: "-").result(binding)
end
not_found do

@ -1,34 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Broken Moon Network</title>
<link>https://www.broken-moon.net</link>
<description>A personal project of Astoria.</description>
<% pageArray = Array.new %>
<% folders.each do |folder| %>
<% if Dir.exists? folder %>
<% contents = Dir.children("./" + folder) %>
<% if !contents.empty? %>
<% contents.each do |content| %>
<% begin %>
<% newPage = Page.new(folder + "/" + content) %>
<% rescue %>
<% puts "bad times at " + content %>
<% else %>
<% pageArray.push(newPage) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% pageArray.sort_by! { |page| page.get_date } %>
<% pageArray.reverse.each do | page | %>
<%= page.get_feed_entry %>
<% end %>
<%- pageArray = Array.new -%>
<%- folders = ["media", "technology", "news"] -%>
<%- folders.each do |folder| -%>
<%- if Dir.exists? folder -%>
<%- contents = Dir.children("./" + folder) -%>
<%- if !contents.empty? -%>
<%- contents.each do |content| -%>
<%- begin -%>
<%- newPage = Page.new(folder + "/" + content) -%>
<%- rescue -%>
<%- puts "bad times at " + content -%>
<%- else -%>
<%- pageArray.push(newPage) -%>
<%- end -%>
<%- end -%>
<%- end -%>
<%- end -%>
<%- end -%>
<%- pageArray.sort_by! { |page| page.get_date } -%>
<%- pageArray.reverse.each do | page | -%>
<%=- page.get_feed_entry %>
<%- end -%>
</channel>
</rss>
Loading…
Cancel
Save