diff --git a/v5.rb b/v5.rb
index b9689e2..1bdfc4e 100755
--- a/v5.rb
+++ b/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
diff --git a/views/archiveFolderIndex.erb b/views/archiveFolderIndex.erb
deleted file mode 100644
index 74f073c..0000000
--- a/views/archiveFolderIndex.erb
+++ /dev/null
@@ -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 %>
\ No newline at end of file
diff --git a/views/archivepage.erb b/views/archivepage.erb
deleted file mode 100644
index 3b2483a..0000000
--- a/views/archivepage.erb
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-<% if folder == "all" %>
- <% doAllFolder = true %>
- <% title = "Archive" %>
-<% else %>
- <% doAllFolder = false %>
- <% title = "Archive - " + folder.capitalize %>
-<% end %>
-
- <%= title %>
-
-
-
-
- <%= erb :headerBoilerplate %>
-
-
- <%= erb :asidemenu %>
-
- <%= 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 %>
-
- <%= erb :bottom %>
-
\ No newline at end of file
diff --git a/views/asideFolderBox.erb b/views/asideFolderBox.erb
index c8ff143..32706d0 100644
--- a/views/asideFolderBox.erb
+++ b/views/asideFolderBox.erb
@@ -1,5 +1,5 @@
<%
-folders =["Media", "Technology", "News"]
+folders =["Media", "Technology", "News", "Search"]
%>
<% folders.each do |folder| %>
diff --git a/views/folderArchive.erb b/views/folderArchive.erb
deleted file mode 100644
index 2abb05f..0000000
--- a/views/folderArchive.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-
\ No newline at end of file
diff --git a/views/folderIndex.erb b/views/folderIndex.erb
deleted file mode 100644
index 44b6f93..0000000
--- a/views/folderIndex.erb
+++ /dev/null
@@ -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 %>
\ No newline at end of file
diff --git a/views/folderpage.erb b/views/folderpage.erb
index 0a54234..38458b7 100644
--- a/views/folderpage.erb
+++ b/views/folderpage.erb
@@ -12,25 +12,17 @@
<%= erb :asidemenu %>
- <% if Dir.exist?("." + request.path_info) %>
- <% if !Dir.children("." + request.path_info).grep(/erb/).empty? || !Dir.children("." + request.path_info).grep(/md/).empty? %>
-
-
<%= title %>
- <% if File.exists?("." + request.path_info + "/tagline") %>
-
- <% file = File.open("." + request.path_info + "/tagline") %>
-
<%= file.read %>
- <% end %>
-
- <%= 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 %>
<%= erb :bottom %>
diff --git a/views/homeArchive.erb b/views/homeArchive.erb
deleted file mode 100644
index 41dd563..0000000
--- a/views/homeArchive.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-
\ No newline at end of file
diff --git a/views/homeIndex.erb b/views/homeIndex.erb
deleted file mode 100644
index d09d6cf..0000000
--- a/views/homeIndex.erb
+++ /dev/null
@@ -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 %>
\ No newline at end of file
diff --git a/views/homepage.erb b/views/homepage.erb
index 7ec77b2..6987959 100644
--- a/views/homepage.erb
+++ b/views/homepage.erb
@@ -12,8 +12,8 @@
<%= erb :asidemenu %>
<%= erb :homeImage %>
- <%= erb :homeIndex %>
- <%= erb :homeArchive %>
+ <%= erb :index, locals: {folders: ["media", "technology", "news"], searchquery: ""} %>
+ <%= erb :search, locals: {folder: "All"} %>
<%= erb :bottom %>
\ No newline at end of file
diff --git a/views/index.erb b/views/index.erb
new file mode 100644
index 0000000..38b533f
--- /dev/null
+++ b/views/index.erb
@@ -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 %>
\ No newline at end of file
diff --git a/views/noFile.erb b/views/noFile.erb
index 2c7ff10..3c8f77f 100644
--- a/views/noFile.erb
+++ b/views/noFile.erb
@@ -5,7 +5,7 @@
404 - File not found. Press left mouse button to continue.
- Guru Meditation: No Content
+ Guru Meditation: No Content in <%= file %>
diff --git a/views/noFolder.erb b/views/noFolder.erb
index dd5bfd2..105a29e 100644
--- a/views/noFolder.erb
+++ b/views/noFolder.erb
@@ -5,7 +5,7 @@
404 - Folder not found. Press left mouse button to continue.
- Guru Meditation: No Content
+ Guru Meditation: No Folder called <%= folder %>
\ No newline at end of file
diff --git a/views/search.erb b/views/search.erb
new file mode 100644
index 0000000..9af4f2d
--- /dev/null
+++ b/views/search.erb
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/views/archiveTopBar.erb b/views/searchTopBar.erb
similarity index 82%
rename from views/archiveTopBar.erb
rename to views/searchTopBar.erb
index c36716b..7d66872 100644
--- a/views/archiveTopBar.erb
+++ b/views/searchTopBar.erb
@@ -3,7 +3,7 @@
Home
>
- Archive
+ Search
>
<%=folder.capitalize %>
diff --git a/views/searchpage.erb b/views/searchpage.erb
new file mode 100644
index 0000000..52bf32b
--- /dev/null
+++ b/views/searchpage.erb
@@ -0,0 +1,39 @@
+
+
+<% if folder == "all" %>
+ <% doAllFolder = true %>
+ <% title = "Archive" %>
+<% else %>
+ <% doAllFolder = false %>
+ <% title = "Archive - " + folder.capitalize %>
+<% end %>
+
+ <%= title %>
+
+
+
+
+ <%= erb :headerBoilerplate %>
+
+
+ <%= erb :asidemenu %>
+
+ <%= 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 %>
+
+ <%= erb :bottom %>
+
\ No newline at end of file