Archive => Search, refactoring

main
Astoria 2 years ago
parent 08b948bb16
commit 418e7a38f6

12
v5.rb

@ -68,16 +68,16 @@ get '/news/*' do
erb :blogpage
end
get '/archive' do
erb :archivepage, locals: {folder: "all", searchquery: ""}
get '/search' do
erb :searchpage, locals: {folder: "all", searchquery: ""}
end
get '/archive/' do
erb :archivepage, locals: {folder: "all", searchquery: ""}
get '/search/' do
erb :searchpage, locals: {folder: "all", searchquery: ""}
end
get '/archive/:folder' do
erb :archivepage, locals: {folder: params["folder"].downcase, searchquery: params["search"]}
get '/search/:folder' do
erb :searchpage, locals: {folder: params["folder"].downcase, searchquery: params["search"]}
end
get '/about' do

@ -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,5 +1,5 @@
<%
folders =["Media", "Technology", "News"]
folders =["Media", "Technology", "News", "Search"]
%>
<ul class="blogbox">
<% folders.each do |folder| %>

@ -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 %>

@ -12,25 +12,17 @@
<body>
<%= erb :asidemenu %>
<div class="content">
<% if Dir.exist?("." + request.path_info) %>
<% if !Dir.children("." + request.path_info).grep(/erb/).empty? || !Dir.children("." + request.path_info).grep(/md/).empty? %>
<div class="section homesection center">
<a href="/<%= request.path_info[1..-1] %>"><span class="homemessage"><%= title %> </span></a>
<% if File.exists?("." + request.path_info + "/tagline") %>
<br>
<% file = File.open("." + request.path_info + "/tagline") %>
<span class="homesubmessage"><%= file.read %></span>
<% end %>
</div>
<%= erb :folderIndex %>
<%= erb :folderArchive, locals: {folder: request.path_info, title: title} %>
<%= erb :topbar %>
<% folder = request.path_info[1..-1] %>
<% if !Dir.exists?(folder) %>
<%= erb :noFolder, locals: {folder: folder} %>
<% else %>
<% if Dir.children("./" + folder).empty? %>
<%= erb :noFile, locals: {file: folder } %>
<% else %>
<%= erb :topbar %>
<%= erb :noFile %>
<%= erb :index, locals: {folders: [folder], searchquery: ""} %>
<%= erb :search, locals: {folder: folder} %>
<% end %>
<% else %>
<%= erb :topbar %>
<%= erb :noFolder %>
<% end %>
</div>
<%= erb :bottom %>

@ -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 %>

@ -12,8 +12,8 @@
<%= erb :asidemenu %>
<div class="content">
<%= erb :homeImage %>
<%= erb :homeIndex %>
<%= erb :homeArchive %>
<%= erb :index, locals: {folders: ["media", "technology", "news"], searchquery: ""} %>
<%= erb :search, locals: {folder: "All"} %>
</div>
<%= erb :bottom %>
</body>

@ -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 %>

@ -5,7 +5,7 @@
404 - File not found. Press left mouse button to continue.
<br>
<br>
Guru Meditation: No Content
Guru Meditation: No Content in <%= file %>
</span>
</a>
</div>

@ -5,7 +5,7 @@
404 - Folder not found. Press left mouse button to continue.
<br>
<br>
Guru Meditation: No Content
Guru Meditation: No Folder called <%= folder %>
</span>
</div>
</div>

@ -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>

@ -3,7 +3,7 @@
<b>
<a href="/home">Home</a>
>
<a href="/archive">Archive</a>
<a href="/search">Search</a>
>
<a href="/archive/<%= folder %>"><%=folder.capitalize %></a>
</b>

@ -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…
Cancel
Save