Skip to content

Commit

Permalink
Merge branch 'main' into 112-error-views
Browse files Browse the repository at this point in the history
  • Loading branch information
aliciapaz authored Sep 2, 2024
2 parents 977b2e3 + 7034161 commit a84d3d8
Show file tree
Hide file tree
Showing 30 changed files with 153 additions and 59 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
arm64-darwin-24
x86_64-linux

DEPENDENCIES
Expand Down
3 changes: 3 additions & 0 deletions app/assets/images/icons/no_wifi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/assets/images/intersection_lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/splashscreens/iPhone_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 11 additions & 18 deletions app/assets/images/telos_labs_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 13 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ class ApplicationController < ActionController::Base

helper_method :current_profile, :current_conference, :vapid_public_key

rescue_from ActionController::InvalidAuthenticityToken,
with: :after_invalid_authenticity_token

private

def current_profile = current_user&.profile

# TODO: Must change after implementing multi-conference support
def current_conference = Conference.last
def current_conference
@_current_conference ||= Conference.last
end

def vapid_public_key
Base64.urlsafe_decode64(ENV["VAPID_PUBLIC_KEY"]).bytes.to_json
@_vapid_public_key ||= Base64.urlsafe_decode64(ENV["VAPID_PUBLIC_KEY"]).bytes.to_json
end

def after_invalid_authenticity_token
path_to_redirect = request.referer
path_to_redirect ||= user_signed_in? ? sessions_path : new_user_session_path
redirect_to path_to_redirect, alert: t("authorization.invalid_auth_token")
end
end
2 changes: 1 addition & 1 deletion app/controllers/schedules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def show
@sessions = SessionQuery.new(
relation: current_user.sessions.where(conference: current_conference),
params: filter_params
).call.includes(:attendees, :location, :speakers, :tags).order(:starts_at)
).call.includes(:location, :tags, speakers: [profile: :image_attachment]).order(:starts_at)
end

private
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/service_worker_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ def service_worker

def manifest
end

def offline
end
end
4 changes: 2 additions & 2 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def index
@sessions = SessionQuery.new(
relation: sessions.joins(:location).distinct,
params: filter_params
).call.includes(:attendees, :tags).order(:starts_at)
).call.includes(:location, :tags, speakers: [profile: :image_attachment]).order(:starts_at)
end

def show
@session = sessions.friendly.find(params[:id])
@session = sessions.friendly.includes(:location, :tags, speakers: [profile: :image_attachment]).find(params[:id])
end

private
Expand Down
13 changes: 7 additions & 6 deletions app/views/abouts/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<%= title "About - Rails World 2024" %>

<div class="flex flex-col items-center w-full h-full font-karla">
<div class="flex flex-col items-center w-full h-full px-5 pt-6 pb-10 bg-blue-marine">
<div class="flex flex-col justify-center h-full max-w-screen-sm font-normal text-center">
<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>
<div class="flex flex-col items-center w-full h-full px-5 pt-6 pb-10 bg-gradient-to-r from-blue-marine from-[16.68%] to-[#001827] to-[99.85%] bg-no-repeat">
<div class="z-10 flex flex-col justify-center h-full max-w-screen-sm font-light text-center">
<p class="mb-6 text-base text-white">Brought to you by</p>
<a href="https://www.teloslabs.co/?utm_source=rails_world_app&utm_medium=affiliate&utm_campaign=rails_world_app">
<%= inline_svg_tag "telos_labs_logo.svg", class: "mb-10 w-full" %>
</a>
<p class="mb-6 text-lg text-white">
<p class="mb-6 text-lg leading-6 text-white">
We designed and developed this open-source app for the Rails community.
<br>
You can contribute to the repo <a href="https://github.com/TelosLabs/rails-world" target="_blank" class="text-blue-teal">here</a>.
You can contribute to the repo <a href="https://github.com/TelosLabs/rails-world" target="_blank" class="font-normal text-blue-teal">here</a>.
</p>
<p class="mb-10 text-lg text-white">Telos creates disruptive, purpose-driven software for visionary clients to enhance productivity and enrich lives.</p>
<p class="mb-10 text-lg leading-6 text-white">Telos creates disruptive, purpose-driven software for visionary clients to enhance productivity and enrich lives.</p>
<div class="flex flex-row items-center w-full gap-5">
<a href="https://www.teloslabs.co/?utm_source=rails_world_app&utm_medium=affiliate&utm_campaign=rails_world_app" target="_blank" class="grow bg-blue-teal rounded-[10px] p-4 flex flex-row items-center justify-center">
<%= inline_svg_tag "icon_web.svg", class: "w-6 h-6" %>
Expand Down
27 changes: 27 additions & 0 deletions app/views/layouts/_apple_splash_screen.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,30 @@

<!-- iPad Pro 11" (1668x2388) -->
<link rel="apple-touch-startup-image" href="<%= image_path "splashscreens/iPad_Pro_11.png" %>" media="(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2)">

<!-- iPhone 12 and iPhone 12 Pro -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_12_Pro.png" media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3)">

<!-- iPhone 12 Mini -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_12_Mini.png" media="(device-width: 360px) and (device-height: 780px) and (-webkit-device-pixel-ratio: 3)">

<!-- iPhone 12 Pro Max -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_12_Pro_Max.png" media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3)">

<!-- iPhone 13 and iPhone 13 Pro -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_13_Pro.png" media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3)">

<!-- iPhone 13 Mini -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_13_Mini.png" media="(device-width: 360px) and (device-height: 780px) and (-webkit-device-pixel-ratio: 3)">

<!-- iPhone 13 Pro Max -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_13_Pro_Max.png" media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3)">

<!-- iPhone 14 and iPhone 14 Pro -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_14_Pro.png" media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3)">

<!-- iPhone 14 Plus -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_14_Plus.png" media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3)">

<!-- iPhone 14 Pro Max -->
<link rel="apple-touch-startup-image" href="/assets/splashscreens/iPhone_14_Pro_Max.png" media="(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3)">
2 changes: 1 addition & 1 deletion app/views/layouts/_bottom_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<% if unread_notifications.present? %>
<div class="absolute -top-0.5 right-0 w-[18px] h-[18px] rounded-full bg-red flex justify-center items-center">
<span class="text-[11px] text-white font-bold px-1">
<%= unread_notifications.count < 10 ? unread_notifications.count : "+9" %>
<%= unread_notifications.length < 10 ? unread_notifications.length : "+9" %>
</span>
</div>
<% 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
Expand Up @@ -32,7 +32,7 @@
</a>
</div>
<div class="w-full mx-2 mb-1 border-b"></div>
<div class="mb-1 text-gray-400 text-nowrap"><%= pluralize(sessions.count, "Session") %></div>
<div class="mb-1 text-gray-400 text-nowrap"><%= pluralize(sessions.length, "Session") %></div>
<% end %>
<% sessions.each do |session| %>
<%= render(
Expand Down
11 changes: 11 additions & 0 deletions app/views/service_worker/offline.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="flex flex-col gap-6 justify-center items-center w-full h-full">
<div class="flex justify-center items-center w-32 h-32 bg-white rounded-full">
<%= inline_svg_tag "icons/no_wifi.svg", size: "56", class: "fill-gray-400" %>
</div>
<h1 class="text-4xl italic font-black text-gray-800">You're offline</h1>
<p class="text-base font-bold text-center">Check your connection <br> and try again.</p>
<%= link_to(
'Refresh the page', "",
class: "text-red font-bold text-center rounded-sm underline italic text-lg"
) %>
</div>
56 changes: 55 additions & 1 deletion app/views/service_worker/service_worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* global self, clients */
/* global self, clients, importScripts, workbox */

importScripts(
'https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js'
)

// ------------- Push Notifications -------------

self.addEventListener('push', async (event) => {
let data
Expand Down Expand Up @@ -41,3 +47,51 @@ self.addEventListener('notificationclick', function (event) {
})
)
})

// ------------- Request handling -------------

const { CacheFirst, NetworkFirst } = workbox.strategies
const { registerRoute } = workbox.routing

// For assets (scripts and images), cache first
registerRoute(
({ request }) => request.destination === 'script' ||
request.destination === 'style',
new CacheFirst({
cacheName: 'assets-styles-and-scripts'
})
)

registerRoute(
({ request }) => request.destination === 'image',
new CacheFirst({
cacheName: 'assets-images'
})
)

// For pages, network first
registerRoute(
({ request, url }) => request.destination === 'document' ||
request.destination === '',
new NetworkFirst()
)

// Offline fallback

const { warmStrategyCache } = workbox.recipes
const { setCatchHandler } = workbox.routing
const strategy = new NetworkFirst()
const urls = ['/offline.html']

// Warm the runtime cache with a list of asset URLs
warmStrategyCache({ urls, strategy })

// Trigger a 'catch' handler when any of the other routes fail to generate a response
setCatchHandler(async ({ event }) => {
switch (event.request.destination) {
case 'document':
return strategy.handle({ event, request: urls[0] })
default:
return Response.error()
}
})
4 changes: 2 additions & 2 deletions app/views/sessions/_card.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
:div,
class: [
"flex flex-col ml-2",
"max-w-[200px]": session.speakers.count > 1
"max-w-[200px]": session.speakers.length > 1
]
) do %>
<h2 class="text-sm italic font-black group-hover:text-red group-focus:text-red"><%= speaker.name %></h2>
Expand All @@ -71,7 +71,7 @@
<% end %>

<div class="flex flex-col">
<% if session.tags.exists? %>
<% if session.tags.present? %>
<div class="flex flex-wrap w-full gap-2 mb-3">
<% session.tags.each do |tag| %>
<div class="px-2 py-1 text-xs bg-transparent border rounded-lg border-bluegray-600 text-bluegray-600">
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</a>
</div>
<div class="w-full mx-2 mb-1 border-b"></div>
<div class="mb-1 text-gray-400 text-nowrap"><%= pluralize(sessions.count, "Session") %></div>
<div class="mb-1 text-gray-400 text-nowrap"><%= pluralize(sessions.length, "Session") %></div>
<% end %>
<% sessions.each do |session| %>
<%= render(
Expand Down
4 changes: 2 additions & 2 deletions app/views/sessions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<%= content_tag(:div, class: [
"flex flex-col ml-2",
"max-w-[200px]": @session.speakers.count > 1
"max-w-[200px]": @session.speakers.length > 1
] ) do %>
<h2 class="text-sm italic font-black group-hover:text-red group-focus:text-red"><%= speaker.name %></h2>
<p class="text-sm font-normal text-gray-400"><%= speaker.job_title %></p>
Expand Down Expand Up @@ -94,7 +94,7 @@
<div class="flex flex-col items-center w-full p-5 mt-6">
<div class="flex flex-col items-start w-full max-w-screen-sm">
<p class="mb-4 text-2xl italic font-bold text-black">
<%= "About the #{'speaker'.pluralize(@session.speakers.count)}" %>
<%= "About the #{'speaker'.pluralize(@session.speakers.length)}" %>
</p>
<div class="flex flex-col w-full gap-4">
<% @session.speakers.each do |speaker| %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ en:
submit: "Apply"
authorization:
unauthorized: "You are not authorized to access this page."
invalid_auth_token: "Your request has expired. Please try again."
session_mailer:
reminder:
subject: "This session is starting soon"
Expand All @@ -66,4 +67,3 @@ en:
one: "1month"
other: "%{count}months"
x_months: "%{count}months"

1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

get "up" => "rails/health#show", :as => :rails_health_check
get "/service-worker.js" => "service_worker#service_worker"
get "/offline.html" => "service_worker#offline"
get "/manifest.json" => "service_worker#manifest"

mount MissionControl::Jobs::Engine, at: "/jobs"
Expand Down
20 changes: 0 additions & 20 deletions lib/tasks/db.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace :db do
desc "Loading Rails World 2024 conference data."

task :rails_world_2024_seed, [:start_date] => :environment do |t, args|
start_date = args[:start_date].present? ? Date.parse(args[:start_date]) : Date.new(2024, 9, 26)
month = start_date.month
Expand All @@ -25,43 +24,24 @@ namespace :db do

# Create Tags
community = Tag.find_or_create_by!(name: "Community")

security = Tag.find_or_create_by!(name: "Security")

rails_8 = Tag.find_or_create_by!(name: "Rails 8")

productivity = Tag.find_or_create_by!(name: "Productivity")

tools = Tag.find_or_create_by!(name: "Tools")

developer_experience = Tag.find_or_create_by!(name: "Developer Experience")

deployment = Tag.find_or_create_by!(name: "Deployment")

performance = Tag.find_or_create_by!(name: "Performance")

storage_solutions = Tag.find_or_create_by!(name: "Storage Solutions")

refactoring = Tag.find_or_create_by!(name: "Refactoring")

database = Tag.find_or_create_by!(name: "Database")

hotwire = Tag.find_or_create_by!(name: "Hotwire")

ai = Tag.find_or_create_by!(name: "AI")

integrations = Tag.find_or_create_by!(name: "Integrations")

testing = Tag.find_or_create_by!(name: "Testing")

best_practices = Tag.find_or_create_by!(name: "Best Practices")

pwa = Tag.find_or_create_by!(name: "PWA")

insights = Tag.find_or_create_by!(name: "Insights")

background_jobs = Tag.find_or_create_by!(name: "Background Jobs")

rails_internals = Tag.find_or_create_by!(name: "Rails Internals")

# Create Speakers
Expand Down

0 comments on commit a84d3d8

Please sign in to comment.