Skip to content

Commit

Permalink
[FS-25] Make sure titles are correct in every view (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
beetlegius-jt authored Jan 29, 2025
1 parent 73171ff commit ed8eae3
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/admin/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def new
end

def edit
set_metadata title: @activity.name

render :form
end

Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/attendances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def index
end

def show
set_metadata title: @attendance.customer.name
end

def new
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/admin/companies_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Admin
class CompaniesController < BaseController
before_action :set_company
before_action :set_company_metadata

def show
end
Expand Down Expand Up @@ -29,5 +30,9 @@ def set_company
def company_params
params.require(:company).permit(:name, :subdomain, :utc_offset, :logo)
end

def set_company_metadata
set_metadata title: @company.name
end
end
end
2 changes: 2 additions & 0 deletions app/controllers/app/customers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module App
class CustomersController < BaseController
def show
@customer = authorize Current.customer

set_metadata title: @customer.name
end
end
end
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class ApplicationController < ActionController::Base
include Pundit::Authorization
include HasMetadata

# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
Expand Down
19 changes: 19 additions & 0 deletions app/controllers/concerns/has_metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module HasMetadata
extend ActiveSupport::Concern

Metadata = Data.define(:title)

included do
helper_method :metadata
end

private

def metadata
@metadata ||= set_metadata
end

def set_metadata(title: t(".title"))
@metadata = Metadata.new(title:)
end
end
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title><%= content_for(:title) %> :: Fit Shift</title>
<title><%= metadata.title %> :: Fit Shift</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
Expand Down
11 changes: 11 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,17 @@ en:
event: Event
admin:
activities:
index:
title: List of activities
new:
title: Add activity
form:
title: Activity form
attendances:
index:
title: List of attendances
new:
title: Scan QR code
form:
title: Scan QR code
description: Open your application and show your QR code to the camera
Expand Down Expand Up @@ -109,6 +117,9 @@ en:
application:
navigation_links:
admin: Admin panel
devise:
sessions:
title: Sign in
helpers:
submit:
reservation:
Expand Down

0 comments on commit ed8eae3

Please sign in to comment.