From 9fbe52dd219c5f11ebee0243da4d08574cc761c5 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sun, 19 Jan 2025 03:30:18 +0300 Subject: [PATCH] Create user comments controller base class --- app/controllers/users/comments_controller.rb | 18 ++++++++++++++++++ .../users/diary_comments_controller.rb | 17 +---------------- .../index.html.erb | 0 config/locales/en.yml | 6 ++++-- 4 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 app/controllers/users/comments_controller.rb rename app/views/users/{diary_comments => comments}/index.html.erb (100%) diff --git a/app/controllers/users/comments_controller.rb b/app/controllers/users/comments_controller.rb new file mode 100644 index 000000000..06d2d7f4d --- /dev/null +++ b/app/controllers/users/comments_controller.rb @@ -0,0 +1,18 @@ +module Users + class CommentsController < ApplicationController + include UserMethods + include PaginationMethods + + layout "site" + + before_action :authorize_web + before_action :set_locale + before_action :check_database_readable + + authorize_resource + + before_action :lookup_user + + allow_thirdparty_images + end +end diff --git a/app/controllers/users/diary_comments_controller.rb b/app/controllers/users/diary_comments_controller.rb index 5e6a55202..8f41e509f 100644 --- a/app/controllers/users/diary_comments_controller.rb +++ b/app/controllers/users/diary_comments_controller.rb @@ -1,20 +1,5 @@ module Users - class DiaryCommentsController < ApplicationController - include UserMethods - include PaginationMethods - - layout "site" - - before_action :authorize_web - before_action :set_locale - before_action :check_database_readable - - authorize_resource - - before_action :lookup_user - - allow_thirdparty_images - + class DiaryCommentsController < CommentsController def index @title = t ".title", :user => @user.display_name diff --git a/app/views/users/diary_comments/index.html.erb b/app/views/users/comments/index.html.erb similarity index 100% rename from app/views/users/diary_comments/index.html.erb rename to app/views/users/comments/index.html.erb diff --git a/config/locales/en.yml b/config/locales/en.yml index 747c23c83..247416b7d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2872,12 +2872,14 @@ en: user: summary_html: "%{name} created from %{ip_address} on %{date}" summary_no_ip_html: "%{name} created on %{date}" - diary_comments: + comments: index: - title: "Diary Comments added by %{user}" heading_html: "%{user}'s Comments" diary_entries: "Diary entries" no_comments: "No comments" + diary_comments: + index: + title: "Diary Comments added by %{user}" page: post: Post when: When -- 2.39.5