commit 8ac137879f1822bfa707a16c23cea0717e8efdea
parent 733504a7fcc9acda78468921fa63dbd3018c7653
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date: Tue, 22 Feb 2022 03:16:57 -0800
Let rails handle errors, more front page items
Diffstat:
8 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -363,3 +363,5 @@ build-iPhoneSimulator/
/app/assets/images
/public/favicon32x32.ico
# End of https://www.toptal.com/developers/gitignore/api/yarn
+
+/app/orgs+
\ No newline at end of file
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
@@ -1,11 +1,5 @@
class ApplicationController < ActionController::Base
def not_found
raise ActionController::RoutingError.new('Not Found')
- rescue
- render_404
- end
-
- def render_404
- render file: "#{Rails.root}/public/404", status: :not_found
end
end
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
@@ -9,12 +9,12 @@ class PostsController < ApplicationController
end
def show
- @post = Post.find_by(where: 'posts', url: params[:url]) rescue not_found
+ (@post = Post.find_by(where: 'posts', url: params[:url])) or not_found
end
# Get "rolling" front page items
def front_show
- @post = Post.find_by(where: '', url: params[:url]) rescue not_found
+ (@post = Post.find_by(where: '', url: params[:url])) or not_found
render 'show'
end
@@ -24,7 +24,7 @@ class PostsController < ApplicationController
end
def esoteric_show
- @post = Post.find_by(where: 'esoteric', url: params[:url]) rescue not_found
+ (@post = Post.find_by(where: 'esoteric', url: params[:url])) or not_found
render 'show'
end
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
@@ -74,6 +74,7 @@
</a>
<%= image_tag '/res/stickies/chrmevil.webp', alt: 'Chrome is evil!' %>
+ <p><i>This website is dedicated to mankind.</i></p>
</footer>
</body>
</html>
diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb
@@ -1,4 +1,21 @@
<div class="ewin">
+ <pre>
+ ____ _
+| _ \ _ _ __ _ _ __ ( )___
+| |_) | | | |/ _` | '_ \|// __|
+| _ <| |_| | (_| | | | | \__ \
+|_| \_\\__, |\__,_|_| |_| |___/
+ |___/
+ _ _
+| | | | ___ _ __ ___ ___ _ __ __ _ __ _ ___
+| |_| |/ _ \| '_ ` _ \ / _ \ '_ \ / _` |/ _` |/ _ \
+| _ | (_) | | | | | | __/ |_) | (_| | (_| | __/
+|_| |_|\___/|_| |_| |_|\___| .__/ \__,_|\__, |\___|
+ |_| |___/
+ </pre>
+ <p>This website is a celebration of old computer technology.</p>
+</div>
+<div class="ewin">
<h3>Navigation</h3>
<ul>
<li><a href="/posts">Posts</a></li>
diff --git a/config/application.rb b/config/application.rb
@@ -86,8 +86,6 @@ module Site
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
- # Handle 404's by myself
- config.exceptions_app = self.routes
config.public_file_server.enabled = true
# Init the database
diff --git a/config/routes.rb b/config/routes.rb
@@ -9,8 +9,4 @@ Rails.application.routes.draw do
get '/esoteric/:url', to: 'posts#esoteric_show'
# Front page posts
get '/:url', to: 'posts#front_show'
- # Errors.
- get '/404', to: 'errors#not_found'
- get '/500', to: 'errors#not_found'
- get '/422', to: 'errors#not_found'
end
diff --git a/public/404.html b/public/404.html
@@ -0,0 +1 @@
+TEST TEST