mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 19:57:52 +01:00
Change page title based on current page (#269)
This commit is contained in:
committed by
GitHub
parent
a7d67652bf
commit
fadd577db8
@@ -11,6 +11,7 @@ class BoardsController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@board = Board.find(params[:id])
|
@board = Board.find(params[:id])
|
||||||
|
@page_title = @board.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ class PostsController < ApplicationController
|
|||||||
@post_statuses = PostStatus.select(:id, :name, :color).order(order: :asc)
|
@post_statuses = PostStatus.select(:id, :name, :color).order(order: :asc)
|
||||||
@board = @post.board
|
@board = @post.board
|
||||||
|
|
||||||
|
@page_title = @post.title.length > 60 ? @post.title.slice(0, 60) + "..." : @post.title
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ class RegistrationsController < Devise::RegistrationsController
|
|||||||
# Needed to have Current.tenant available in Devise's controllers
|
# Needed to have Current.tenant available in Devise's controllers
|
||||||
prepend_before_action :load_tenant_data
|
prepend_before_action :load_tenant_data
|
||||||
before_action :load_oauths, only: [:new]
|
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
|
# Override destroy to soft delete
|
||||||
def destroy
|
def destroy
|
||||||
@@ -12,4 +14,14 @@ class RegistrationsController < Devise::RegistrationsController
|
|||||||
yield resource if block_given?
|
yield resource if block_given?
|
||||||
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
||||||
end
|
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
|
end
|
||||||
@@ -2,4 +2,11 @@ class SessionsController < Devise::SessionsController
|
|||||||
# Needed to have Current.tenant available in Devise's controllers
|
# Needed to have Current.tenant available in Devise's controllers
|
||||||
prepend_before_action :load_tenant_data
|
prepend_before_action :load_tenant_data
|
||||||
before_action :load_oauths, only: [:new]
|
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
|
end
|
||||||
@@ -7,6 +7,8 @@ class SiteSettingsController < ApplicationController
|
|||||||
before_action :authenticate_moderator,
|
before_action :authenticate_moderator,
|
||||||
only: [:users]
|
only: [:users]
|
||||||
|
|
||||||
|
before_action :set_page_title
|
||||||
|
|
||||||
def general
|
def general
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -27,4 +29,10 @@ class SiteSettingsController < ApplicationController
|
|||||||
|
|
||||||
def users
|
def users
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_page_title
|
||||||
|
@page_title = t('header.menu.site_settings')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -5,14 +5,17 @@ class StaticPagesController < ApplicationController
|
|||||||
@board = Board.find_by(id: Current.tenant.tenant_setting.root_board_id)
|
@board = Board.find_by(id: Current.tenant.tenant_setting.root_board_id)
|
||||||
|
|
||||||
if @board
|
if @board
|
||||||
|
@page_title = @board.name
|
||||||
render 'boards/show'
|
render 'boards/show'
|
||||||
else
|
else
|
||||||
|
@page_title = t('roadmap.title')
|
||||||
get_roadmap_data
|
get_roadmap_data
|
||||||
render 'static_pages/roadmap'
|
render 'static_pages/roadmap'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def roadmap
|
def roadmap
|
||||||
|
@page_title = t('roadmap.title')
|
||||||
get_roadmap_data
|
get_roadmap_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
7
app/views/layouts/_page_title.html.erb
Normal file
7
app/views/layouts/_page_title.html.erb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<%= @page_title %>
|
||||||
|
<% if @tenant %>
|
||||||
|
<% if @page_title %>
|
||||||
|
<%= " | " %>
|
||||||
|
<% end %>
|
||||||
|
<%= @tenant.site_name %>
|
||||||
|
<% end %>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><%= @tenant ? @tenant.site_name : @page_title %></title>
|
<title><%= render 'layouts/page_title' %></title>
|
||||||
|
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= csp_meta_tag %>
|
<%= csp_meta_tag %>
|
||||||
|
|||||||
Reference in New Issue
Block a user