<% contentsArray = Array.new %> <% contents = Dir.children("." + request.path_info)%> <% contents.each do |content| %> <% if content.end_with?(".erb") || content.end_with?(".md") %> <% if File.exists?("." + request.path_info + "/" + content + ".meta") %> <% newPage = Page.new(content, DateTime.parse(File.read("." + request.path_info + "/" + content + ".meta"), "%Y.%m.%d")) %> <% else %> <% newPage = Page.new(content, DateTime.parse("1970.01.01", "%Y.%m.%d")) %> <% end %> <% contentsArray.push(newPage) %> <% end %> <% end %> <% contentsArray.sort_by! { |page| page.getdate } %> <% contentsArray.reverse.each do |content| %> <% if content.getpath.end_with?(".erb") %> <%= erb :blogpageERB, locals: {file: "." + request.path_info + "/" + content.getpath, date: content.getdate.strftime("%Y.%m.%d")} %> <% elsif content.getpath.end_with?(".md") %> <%= erb :blogpageMD, locals: {file: "." + request.path_info + "/" + content.getpath, date: content.getdate.strftime("%Y.%m.%d")} %> <% end %> <% end %>