Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page Titles based on current conference #181

Merged
merged 6 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base

default_form_builder ApplicationFormBuilder

helper_method :current_profile, :current_conference, :vapid_public_key
helper_method :current_profile, :vapid_public_key

rescue_from ActionController::InvalidAuthenticityToken,
with: :after_invalid_authenticity_token
Expand All @@ -14,10 +14,6 @@ class ApplicationController < ActionController::Base

def current_profile = current_user&.profile

def current_conference
@_current_conference ||= Conference.last
end

def vapid_public_key
@_vapid_public_key ||= Base64.urlsafe_decode64(ENV["VAPID_PUBLIC_KEY"]).bytes.to_json
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/attendees_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def destroy
private

def set_session
@session = current_conference.sessions.find(params[:session_id])
@session = Current.conference.sessions.find(params[:session_id])
end
end
2 changes: 1 addition & 1 deletion app/controllers/schedules_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class SchedulesController < ApplicationController
def show
@sessions = SessionQuery.new(
relation: current_user.sessions.where(conference: current_conference),
relation: current_user.sessions.where(conference: Current.conference),
params: filter_params
).call.includes(:location, :tags, speakers: [profile: :image_attachment]).order(:starts_at)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def show
private

def sessions
Session.where(conference: current_conference)
Session.where(conference: Current.conference)
end

def filter_params
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/speakers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class SpeakersController < ApplicationController
allow_unauthenticated_access only: [:show]

def show
@speaker = current_conference.speakers.friendly.find(params[:id])
@speaker = Current.conference.speakers.friendly.find(params[:id])
@profile = @speaker.profile.presence || Profile.new
@sessions = @speaker.sessions
end
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/session_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def current_day_anchor(session_date)
end

def current_starts_at_filter
return unless current_conference
return unless Current.conference

current_conference.sessions.starts_at(Date.current).first&.starts_at&.to_date
Current.conference.sessions.starts_at(Date.current).first&.starts_at&.to_date
end

def current_agenda_session
@current_agenda_session ||= current_conference&.sessions&.live_or_upcoming_today&.first
@current_agenda_session ||= Current.conference&.sessions&.live_or_upcoming_today&.first
end

def current_schedule_session
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/password_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class PasswordMailer < ApplicationMailer
def password_reset
mail(to: params[:user].email, subject: I18n.t("mailers.password_mailer.password_reset.subject"))
mail(to: params[:user].email, subject: I18n.t("mailers.password_mailer.password_reset.subject", conference_name: Current.conference&.name))
end
end
1 change: 1 addition & 0 deletions app/models/current.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class Current < ActiveSupport::CurrentAttributes
attribute :user
attribute :conference, default: -> { Conference.last }
end
2 changes: 1 addition & 1 deletion app/views/abouts/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "About - Rails World 2024" %>
<%= title "About - #{Current.conference&.name}" %>

<div class="relative flex flex-col items-center w-full h-full font-karla">
<div class="absolute left-0 bottom-0 z-0 w-full max-w-[430px] h-[228px] bg-no-repeat bg-cover" style="background-image: url(<%= asset_path 'intersection_lines.svg' %>)"></div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/coming_soons/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "Coming soon - Rails World 2024" %>
<%= title "Coming soon - #{Current.conference&.name}" %>

<div class="flex flex-col items-center flex-1 px-5 py-10 bg-purple-dark">
<%= inline_svg_tag("main_logo_with_date.svg", class: "w-full mt-14") %>
Expand Down
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 class="h-screen">
<head>
<title><%= content_for(:title).presence || "Rails World 2024" %></title>
<title><%= content_for(:title).presence || "#{Current.conference&.name}" %></title>

<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,viewport-fit=cover">
<meta name="turbo-refresh-scroll" content="preserve">
Expand Down
2 changes: 1 addition & 1 deletion app/views/notification_settings/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "Notifications settings - Rails World 2024" %>
<%= title "Notifications settings - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/secondary_top_nav" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/notifications/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "Notifications - Rails World 2024" %>
<%= title "Notifications - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/primary_top_nav" %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/password_resets/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= title "Reset password - #{Current.conference&.name}" %>

<div class="flex flex-col items-center flex-1 h-screen px-5 pb-10 bg-purple-dark pt-safe-area-header">
<%= form_with model: @user, url: password_reset_path(token: params[:token]), class: "flex flex-col h-full justify-between w-full max-w-screen-sm pt-10" do |form| %>
<div class="flex flex-col">
Expand Down
2 changes: 2 additions & 0 deletions app/views/password_resets/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= title "Forgot password" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/primary_top_nav" %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "Edit profile - Rails World 2024" %>
<%= title "Edit profile - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/primary_top_nav" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% profile_name = @profile.name.presence || "Anonymous" %>
<%= title "#{profile_name}'s Profile - Rails World 2024" %>
<%= title "#{profile_name}'s Profile - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/primary_top_nav" %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= title "Sign up - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/primary_top_nav" %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/schedules/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "My Schedule - Rails World 2024" %>
<%= title "My Schedule - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/primary_top_nav" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/_filters.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="flex justify-between w-full mb-4" data-controller="preserve-scroll">
<div id="<%= resource %>_filters" class="flex items-center gap-2 overflow-x-scroll no-scrollbar" data-preserve-scroll>
<% current_conference&.dates&.each do |session_date| %>
<% Current.conference&.dates&.each do |session_date| %>
<%= link_to(
session_date.strftime("%a, %d"),
url_for([resource, session_filter_params.to_h.merge(starts_at: session_date)]) + current_day_anchor(session_date),
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "Agenda - Rails World 2024" %>
<%= title "Agenda - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/primary_top_nav" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "#{@session.title} - Rails World 2024" %>
<%= title "#{@session.title} - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/secondary_top_nav" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/speakers/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= title "#{@profile.name} - Rails World 2024" %>
<%= title "#{@profile.name} - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/secondary_top_nav" %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/user_sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= title "Login - #{Current.conference&.name}" %>

<div class="flex flex-col items-center flex-1 px-5 pb-10 pt-safe-area-2 bg-purple-dark">
<%= form_with model: @user, url: user_session_path, class: "flex flex-col h-full justify-between w-full max-w-screen-sm" do |form| %>
<div class="flex flex-col items-center">
Expand Down
2 changes: 2 additions & 0 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= title "Edit user - #{Current.conference&.name}" %>

<% content_for :top_nav do %>
<%= render partial: "layouts/primary_top_nav" %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ en:
without_time: "Your bookmarked session is starting soon."
password_mailer:
password_reset:
subject: "Password Reset - Rails World 2024"
subject: "Password Reset - %{conference_name}"
views:
status_filters:
past: "Past"
Expand Down