Archive => Search, refactoring
parent
08b948bb16
commit
418e7a38f6
@ -1,22 +0,0 @@
|
||||
<% contents = Dir.children("./" + folder).grep(/#{searchquery}/) %>
|
||||
<% contentsArray = Array.new %>
|
||||
<% contents.each do |content| %>
|
||||
<% 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 %>
|
||||
<% 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,44 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<% if folder == "all" %>
|
||||
<% doAllFolder = true %>
|
||||
<% title = "Archive" %>
|
||||
<% else %>
|
||||
<% doAllFolder = false %>
|
||||
<% title = "Archive - " + folder.capitalize %>
|
||||
<% end %>
|
||||
<head>
|
||||
<title><%= title %></title>
|
||||
<meta name="description" content="broken-moon.net - <%= title %>" />
|
||||
<meta name="keywords" content="<%= title.downcase %>" />
|
||||
<meta property="og:url" content="http://broken-moon.net/<%= title.downcase %>" />
|
||||
<meta property="og:title" content="<%= title %>" />
|
||||
<%= erb :headerBoilerplate %>
|
||||
</head>
|
||||
<body>
|
||||
<%= erb :asidemenu %>
|
||||
<div class="content">
|
||||
<%= erb :archiveTopBar, locals: {folder: folder} %>
|
||||
<%= erb :searchbar, locals: {folder: folder} %>
|
||||
<% if folder == "all" %>
|
||||
<% foldersOfInterest = ["media", "technology", "news"] %>
|
||||
<% foldersOfInterest.each do |multiFolder| %>
|
||||
<% if Dir.exist?("./" + multiFolder) %>
|
||||
<% if !Dir.children("./" + multiFolder).grep(/erb/).grep(/#{searchquery}/).empty? || !Dir.children("./" + multiFolder).grep(/md/).grep(/#{searchquery}/).empty? %>
|
||||
<%= erb :archiveFolderIndex, locals: {folder: multiFolder, searchquery: searchquery} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% elsif Dir.exist?("./" + folder) %>
|
||||
<% if !Dir.children("./" + folder).grep(/erb/).grep(/#{searchquery}/).empty? || !Dir.children("./" + folder).grep(/md/).grep(/#{searchquery}/).empty? %>
|
||||
<%= erb :archiveFolderIndex, locals: {folder: folder, searchquery: searchquery} %>
|
||||
<% else %>
|
||||
<%= erb :noFile %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= erb :noFolder %>
|
||||
<% end %>
|
||||
<%# searchquery %>
|
||||
</div>
|
||||
<%= erb :bottom %>
|
||||
</body>
|
@ -1,7 +0,0 @@
|
||||
<div class="section numlist center>
|
||||
<span class="homesubmessage">
|
||||
<b>
|
||||
<a href="/archive<%= folder %>">Search <%= title %> Posts<a>
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
@ -1,23 +0,0 @@
|
||||
<% 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 %>
|
@ -1,7 +0,0 @@
|
||||
<div class="section numlist center">
|
||||
<span class="homesubmessage">
|
||||
<b>
|
||||
<a href="/archive/all">Search All Posts</a>
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
@ -1,27 +0,0 @@
|
||||
<% foldersOfInterest = ["media", "technology", "news"] %>
|
||||
<% contentsArray = Array.new %>
|
||||
<% foldersOfInterest.each do |folder| %>
|
||||
<% if Dir.exists? folder %>
|
||||
<% contents = Dir.children("./" + folder)%>
|
||||
<% contents.each do |content| %>
|
||||
<% 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 %>
|
||||
<% 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 %>
|
@ -0,0 +1,28 @@
|
||||
<% contentsArray = Array.new %>
|
||||
<% folders.each do |folder| %>
|
||||
<% if Dir.exists? folder %>
|
||||
<% contents = Dir.children("./" + folder).grep(/#{searchquery}/) %>
|
||||
<% if !contents.empty? %>
|
||||
<% contents.each do |content| %>
|
||||
<% 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 %>
|
||||
<% newPage = Page.new(folder + "/" + content, DateTime.parse("1970.01.01", "%Y.%m.%d")) %>
|
||||
<% end %>
|
||||
<% contentsArray.push(newPage) %>
|
||||
<% 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 %>
|
@ -0,0 +1,7 @@
|
||||
<div class="section numlist center">
|
||||
<span class="homesubmessage">
|
||||
<b>
|
||||
<a href="/search/<%= folder.downcase %>">Search <%= folder.capitalize %> Posts</a>
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<% if folder == "all" %>
|
||||
<% doAllFolder = true %>
|
||||
<% title = "Archive" %>
|
||||
<% else %>
|
||||
<% doAllFolder = false %>
|
||||
<% title = "Archive - " + folder.capitalize %>
|
||||
<% end %>
|
||||
<head>
|
||||
<title><%= title %></title>
|
||||
<meta name="description" content="broken-moon.net - <%= title %>" />
|
||||
<meta name="keywords" content="<%= title.downcase %>" />
|
||||
<meta property="og:url" content="http://broken-moon.net/<%= title.downcase %>" />
|
||||
<meta property="og:title" content="<%= title %>" />
|
||||
<%= erb :headerBoilerplate %>
|
||||
</head>
|
||||
<body>
|
||||
<%= erb :asidemenu %>
|
||||
<div class="content">
|
||||
<%= erb :searchTopBar, locals: {folder: folder} %>
|
||||
<%= erb :searchbar, locals: {folder: folder} %>
|
||||
<% if folder == "all" %>
|
||||
<%= erb :index, locals: {folders: ["media", "technology", "news"], searchquery: searchquery} %>
|
||||
<% else %>
|
||||
<% if !Dir.exists?(folder) %>
|
||||
<%= erb :noFolder, locals: {folder: folder} %>
|
||||
<% else %>
|
||||
<% if Dir.children("./" + folder).empty? %>
|
||||
<%= erb :noFile, locals: {file: folder } %>
|
||||
<% else %>
|
||||
<%= erb :index, locals: {folders: [folder], searchquery: searchquery} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%# searchquery %>
|
||||
</div>
|
||||
<%= erb :bottom %>
|
||||
</body>
|
Loading…
Reference in New Issue