Sorting by date instead of alphabetically
parent
868ecad8df
commit
e6cc63c2c1
@ -1,18 +1,22 @@
|
||||
<% contents = Dir.children("./" + folder).grep(/#{searchquery}/) %>
|
||||
<% contentsArray = Array.new %>
|
||||
<% contents.each do |content| %>
|
||||
<% if content.end_with?(".erb") %>
|
||||
<% file = content %>
|
||||
<% if File.exists?("./" + folder + "/" + file + ".meta") %>
|
||||
<%= erb :blogpageERB, locals: {file: "./" + folder + "/" + content, meta: "./" + folder + "/" + file + ".meta"} %>
|
||||
<% if content.end_with?(".erb") || content.end_with?(".md") %>
|
||||
<% if File.exists?("./" + folder + "/" + content + ".meta") %>
|
||||
<% newPage = Page.new(content, DateTime.parse(File.read("./" + folder + "/" + content + ".meta"), "%Y.%m.%d")) %>
|
||||
<% else %>
|
||||
<%= erb :blogpageERB, locals: {file: "./" + folder+ "/" + content} %>
|
||||
<% end %>
|
||||
<% elsif content.end_with?(".md") %>
|
||||
<% file = content %>
|
||||
<% if File.exists?("./" + folder + "/" + file + ".meta") %>
|
||||
<%= erb :blogpageMD, locals: {file: "./" + folder + "/" + content, meta: "./" + folder + "/" + file + ".meta"} %>
|
||||
<% else %>
|
||||
<%= erb :blogpageMD, locals: {file: "./" + folder + "/" + content} %>
|
||||
<% 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: "./" + folder + "/" + content.getpath, date: content.getdate.strftime("%Y.%m.%d")} %>
|
||||
<% elsif content.getpath.end_with?(".md") %>
|
||||
<%= erb :blogpageMD, locals: {file: "./" + folder + "/" + content.getpath, date: content.getdate.strftime("%Y.%m.%d")} %>
|
||||
<% end %>
|
||||
<% end %>
|
@ -1,11 +1,9 @@
|
||||
<div class="section section<%= rand(1..3) %>">
|
||||
<%= ERB.new(File.read(file)).result(binding) %>
|
||||
<span class="seemore">
|
||||
<% if defined?(meta) %>
|
||||
<b>
|
||||
<span class="seedate"><%= File.read(meta) %></span>
|
||||
<span class="seedate"><%= date %></span>
|
||||
</b>
|
||||
<% end %>
|
||||
<a class="seemorelink" href="/<%= file %>">Article Page</a>
|
||||
</span>
|
||||
</div>
|
@ -1,11 +1,10 @@
|
||||
<div class="section section<%= rand(1..3) %>">
|
||||
<%= markdown(File.read(file)) %>
|
||||
<span class="seemore">
|
||||
<% if defined?(meta) %>
|
||||
<span class="seemore">
|
||||
<b>
|
||||
<span class="seedate"><%= File.read(meta) %></span>
|
||||
<span class="seedate"><%= date %></span>
|
||||
</b>
|
||||
<% end %>
|
||||
<a class="seemorelink" href="/<%= file %>">Article Page</a>
|
||||
</span>
|
||||
</div>
|
@ -1,18 +1,23 @@
|
||||
<% contentsArray = Array.new %>
|
||||
|
||||
<% contents = Dir.children("." + request.path_info)%>
|
||||
<% contents.each do |content| %>
|
||||
<% if content.end_with?(".erb") %>
|
||||
<% file = content %>
|
||||
<% if File.exists?("." + request.path_info + "/" + file + ".meta") %>
|
||||
<%= erb :blogpageERB, locals: {file: "." + request.path_info + "/" + content, meta: "." + request.path_info + "/" + file + ".meta"} %>
|
||||
<% 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 %>
|
||||
<%= erb :blogpageERB, locals: {file: "." + request.path_info + "/" + content} %>
|
||||
<% end %>
|
||||
<% elsif content.end_with?(".md") %>
|
||||
<% file = content %>
|
||||
<% if File.exists?("." + request.path_info + "/" + file + ".meta") %>
|
||||
<%= erb :blogpageMD, locals: {file: "." + request.path_info + "/" + content, meta: "." + request.path_info + "/" + file + ".meta"} %>
|
||||
<% else %>
|
||||
<%= erb :blogpageMD, locals: {file: "." + request.path_info + "/" + content} %>
|
||||
<% 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 %>
|
@ -1,23 +1,27 @@
|
||||
<% foldersOfInterest = ["media", "technology", "news"] %>
|
||||
<% contentsArray = Array.new %>
|
||||
<% foldersOfInterest.each do |folder| %>
|
||||
<% if Dir.exists? folder %>
|
||||
<% contents =Dir.children("./" + folder) %>
|
||||
<% contents = Dir.children("./" + folder)%>
|
||||
<% contents.each do |content| %>
|
||||
<% if content.end_with?(".erb") %>
|
||||
<% file = content %>
|
||||
<% if File.exists?("./" + folder + "/" + file + ".meta") %>
|
||||
<%= erb :blogpageERB, locals: {file: "./" + folder+ "/" + content, meta: "./" + folder + "/" + file + ".meta"} %>
|
||||
<% else %>
|
||||
<%= erb :blogpageERB, locals: {file: "./" + folder + "/" + content} %>
|
||||
<% end %>
|
||||
<% elsif content.end_with?(".md") %>
|
||||
<% file = content %>
|
||||
<% if File.exists?("./" + folder+ "/" + file + ".meta") %>
|
||||
<%= erb :blogpageMD, locals: {file: "./" + folder + "/" + content, meta: "./" + folder + "/" + file + ".meta"} %>
|
||||
<% if content.end_with?(".erb") || content.end_with?(".md") %>
|
||||
<% if File.exists?("./" + folder + "/" + content + ".meta") %>
|
||||
<% newPage = Page.new(folder + "/" + content, DateTime.parse(File.read("./" + folder + "/" + content + ".meta"), "%Y.%m.%d")) %>
|
||||
<% else %>
|
||||
<%= erb :blogpageMD, locals: {file: "./" + folder + "/" + content} %>
|
||||
<% newPage = Page.new(folder + "/" + content, DateTime.parse("1970.01.01", "%Y.%m.%d")) %>
|
||||
<% end %>
|
||||
<% contentsArray.push(newPage) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% contentsArray.sort_by! { |page| page.getdate } %>
|
||||
|
||||
<% contentsArray.reverse.each do |content| %>
|
||||
<% if content.getpath.end_with?(".erb") %>
|
||||
<%= erb :blogpageERB, locals: {file: "./" + content.getpath, date: content.getdate.strftime("%Y.%m.%d")} %>
|
||||
<% elsif content.getpath.end_with?(".md") %>
|
||||
<%= erb :blogpageMD, locals: {file: "./" + content.getpath, date: content.getdate.strftime("%Y.%m.%d")} %>
|
||||
<% end %>
|
||||
<% end %>
|
Loading…
Reference in New Issue