commit e8315f073d6ef3a4c806ff7f85901948f786e42d
parent cc20b320a662cc4baf8b7557a7ae9e437b5551b7
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date: Sun, 20 Feb 2022 16:05:32 -0800
Ignore non ORG files in the org directory, refactor routing
Diffstat:
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
@@ -1,22 +1,30 @@
class PostsController < ApplicationController
def index
+ @posts = Post.where(where: '')
end
+ # Blog in /posts/
def blog_index
- end
-
- def esoteric
+ @posts = Post.where(where: 'posts')
end
def show
- @post = Post.find(params[:url]) rescue not_found
+ @post = Post.find_by(where: 'posts', url: params[:url]) rescue not_found
end
+ # Get "rolling" front page items
def front_show
- @post = Post.find_by(url: params[:url]) rescue not_found
+ @post = Post.find_by(where: '', url: params[:url]) rescue not_found
render 'show'
end
+ # Secret Blog in /esoteric/
+ def esoteric
+ #TODO
+ end
+
def esoteric_show
+ @post = Post.find_by(where: 'esoteric', url: params[:url]) rescue not_found
+ render 'show'
end
end
diff --git a/config/application.rb b/config/application.rb
@@ -31,6 +31,9 @@ def get_org_path(file_path)
end
def remove_org_from_db(file_path)
+ # Check to see if we're actually getting an org file.
+ return if File.extname(file_path) != '.org'
+
dir_name = File.dirname(get_org_path file_path)
dir_name = dir_name == '.' ? '' : dir_name
url = CGI.escape(File.basename(file_path, '.*'))
@@ -43,6 +46,9 @@ def remove_org_from_db(file_path)
end
def add_org_to_db(file_path)
+ # Check to see if we're actually getting an org file.
+ return if File.extname(file_path) != '.org'
+
# TODO get a description
title = org_get_title file_path
dir_name = File.dirname(get_org_path file_path)