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