Change page title based on current page (#269)

This commit is contained in:
Riccardo Graziosi
2024-01-26 17:35:00 +01:00
committed by GitHub
parent a7d67652bf
commit fadd577db8
8 changed files with 41 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ class BoardsController < ApplicationController
def show
@board = Board.find(params[:id])
@page_title = @board.name
end
def create

View File

@@ -62,6 +62,8 @@ class PostsController < ApplicationController
@post_statuses = PostStatus.select(:id, :name, :color).order(order: :asc)
@board = @post.board
@page_title = @post.title.length > 60 ? @post.title.slice(0, 60) + "..." : @post.title
respond_to do |format|
format.html

View File

@@ -2,6 +2,8 @@ class RegistrationsController < Devise::RegistrationsController
# Needed to have Current.tenant available in Devise's controllers
prepend_before_action :load_tenant_data
before_action :load_oauths, only: [:new]
before_action :set_page_title_new, only: [:new]
before_action :set_page_title_edit, only: [:edit]
# Override destroy to soft delete
def destroy
@@ -12,4 +14,14 @@ class RegistrationsController < Devise::RegistrationsController
yield resource if block_given?
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
end
private
def set_page_title_new
@page_title = t('common.forms.auth.sign_up')
end
def set_page_title_edit
@page_title = t('common.forms.auth.profile_settings')
end
end

View File

@@ -2,4 +2,11 @@ class SessionsController < Devise::SessionsController
# Needed to have Current.tenant available in Devise's controllers
prepend_before_action :load_tenant_data
before_action :load_oauths, only: [:new]
before_action :set_page_title, only: [:new]
private
def set_page_title
@page_title = t('common.forms.auth.log_in')
end
end

View File

@@ -6,6 +6,8 @@ class SiteSettingsController < ApplicationController
before_action :authenticate_moderator,
only: [:users]
before_action :set_page_title
def general
end
@@ -27,4 +29,10 @@ class SiteSettingsController < ApplicationController
def users
end
private
def set_page_title
@page_title = t('header.menu.site_settings')
end
end

View File

@@ -5,14 +5,17 @@ class StaticPagesController < ApplicationController
@board = Board.find_by(id: Current.tenant.tenant_setting.root_board_id)
if @board
@page_title = @board.name
render 'boards/show'
else
@page_title = t('roadmap.title')
get_roadmap_data
render 'static_pages/roadmap'
end
end
def roadmap
@page_title = t('roadmap.title')
get_roadmap_data
end

View File

@@ -0,0 +1,7 @@
<%= @page_title %>
<% if @tenant %>
<% if @page_title %>
<%= " | " %>
<% end %>
<%= @tenant.site_name %>
<% end %>

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title><%= @tenant ? @tenant.site_name : @page_title %></title>
<title><%= render 'layouts/page_title' %></title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>