diff --git a/v5.rb b/v5.rb
index 1bdfc4e..38a77d0 100755
--- a/v5.rb
+++ b/v5.rb
@@ -4,7 +4,7 @@ require 'erb'
require 'date'
class Page
- String @path
+ @path
@date
def initialize(path, date)
@path = path
diff --git a/views/blogpageERB.erb b/views/blogpageERB.erb
deleted file mode 100644
index 2591af3..0000000
--- a/views/blogpageERB.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-
- <%= ERB.new(File.read(file)).result(binding) %>
-
-
- <%= date %>
-
- Article Page
-
-
\ No newline at end of file
diff --git a/views/blogpageMD.erb b/views/blogwindow.erb
similarity index 56%
rename from views/blogpageMD.erb
rename to views/blogwindow.erb
index 480eb67..2d1c65a 100644
--- a/views/blogpageMD.erb
+++ b/views/blogwindow.erb
@@ -1,5 +1,9 @@
- <%= markdown(File.read(file)) %>
+ <% if file.end_with?(".md") %>
+ <%= markdown(File.read(file)) %>
+ <% elsif file.end_with?(".erb") %>
+ <%= ERB.new(File.read(file)).result(binding) %>
+ <% end %>
diff --git a/views/folderpage.erb b/views/folderpage.erb
index 38458b7..015520f 100644
--- a/views/folderpage.erb
+++ b/views/folderpage.erb
@@ -15,10 +15,10 @@
<%= erb :topbar %>
<% folder = request.path_info[1..-1] %>
<% if !Dir.exists?(folder) %>
- <%= erb :noFolder, locals: {folder: folder} %>
+ <%= erb :throwError, locals: {errorcode: "404", error: "Folder not found", errordescriptor: "No folder called " + folder.capitalize, returntarget: "home"} %>
<% else %>
<% if Dir.children("./" + folder).empty? %>
- <%= erb :noFile, locals: {file: folder } %>
+ <%= erb :throwError, locals: {errorcode: "404", error: "File not found", errordescriptor: "No files in " + folder.capitalize, returntarget: "home"} %>
<% else %>
<%= erb :index, locals: {folders: [folder], searchquery: ""} %>
<%= erb :search, locals: {folder: folder} %>
diff --git a/views/index.erb b/views/index.erb
index 38b533f..87b4b45 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -17,12 +17,16 @@
<% end %>
<% end %>
+<% if contentsArray.empty? %>
+ <%= erb :throwError, locals: {errorcode: "404", error: "No result", errordescriptor: "No pages matching " + searchquery, returntarget: origin} %>
+<% 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")} %>
+ <%= erb :blogwindow, 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")} %>
+ <%= erb :blogwindow, locals: {file: "./" + content.getpath, date: content.getdate.strftime("%Y.%m.%d")} %>
<% end %>
<% end %>
\ No newline at end of file
diff --git a/views/searchpage.erb b/views/searchpage.erb
index 52bf32b..788e074 100644
--- a/views/searchpage.erb
+++ b/views/searchpage.erb
@@ -21,15 +21,15 @@
<%= erb :searchTopBar, locals: {folder: folder} %>
<%= erb :searchbar, locals: {folder: folder} %>
<% if folder == "all" %>
- <%= erb :index, locals: {folders: ["media", "technology", "news"], searchquery: searchquery} %>
+ <%= erb :index, locals: {folders: ["all", "media", "technology", "news"], searchquery: searchquery, origin: "search/" + "all"} %>
<% else %>
<% if !Dir.exists?(folder) %>
- <%= erb :noFolder, locals: {folder: folder} %>
+ <%= erb :throwError, locals: {errorcode: "404", error: "Folder not found", errordescriptor: "No folder called " + folder.capitalize, returntarget: "search"} %>
<% else %>
<% if Dir.children("./" + folder).empty? %>
- <%= erb :noFile, locals: {file: folder } %>
+ <%= erb :throwError, locals: {errorcode: "404", error: "File not found", errordescriptor: "No files in " + folder.capitalize, returntarget: "search"} %>
<% else %>
- <%= erb :index, locals: {folders: [folder], searchquery: searchquery} %>
+ <%= erb :index, locals: {folders: [folder], searchquery: searchquery, origin: "search/" + folder} %>
<% end %>
<% end %>
<% end %>
diff --git a/views/throwError.erb b/views/throwError.erb
new file mode 100644
index 0000000..e46c741
--- /dev/null
+++ b/views/throwError.erb
@@ -0,0 +1,8 @@
+
\ No newline at end of file