Skip to content

Commit e8ff0e2

Browse files
authored
Merge pull request #2380 from gnclmorais/improve-open-graph-meta
Improves sharing previews
2 parents 49c20da + 8a67ec6 commit e8ff0e2

File tree

12 files changed

+50
-32
lines changed

12 files changed

+50
-32
lines changed
130 KB
Loading

app/mailers/virtual_workshop_invitation_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def attending(workshop, member, invitation, waiting_list = false)
1010
setup(workshop, invitation, member)
1111
@waiting_list = waiting_list
1212

13-
subject = "Attendance Confirmation: #{I18n.t('workshop.virtual.title',
13+
subject = "Attendance Confirmation: #{I18n.t('workshops.virtual.title_with_date',
1414
chapter: @workshop.chapter.name,
1515
date: humanize_date(@workshop.date_and_time))}"
1616

app/views/errors/error.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
!!!
22
%html
33
%head
4-
%link{ rel: 'image_src', href: '/assets/logo-square.png', :alt => "codebar logo" }
4+
= render partial: 'shared/meta_tags'
55
= favicon_link_tag 'favicon.ico'
66
%title codebar.io - Page not found
77
:css

app/views/errors/not_found.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
!!!
22
%html
33
%head
4-
%link{ rel: 'image_src', href: '/assets/logo-square.png', :alt => "codebar logo" }
4+
= render partial: 'shared/meta_tags'
55
= favicon_link_tag 'favicon.ico'
66
%title codebar.io - Page not found
77
:css

app/views/layouts/application.html.haml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,18 @@
55
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1.0' }
66
%meta{ name: 'robots', content: 'index, follow' }
77
%meta{ property: 'fb:admins', content: '622070503' }
8-
%meta{ property: 'og:type', content: 'website' }
9-
%meta{ property: 'og:locale', content: 'en_GB' }
10-
%meta{ property: 'og:site_name', content: 'codebar' }
118
%meta{ name: 'keywords', content: 'codebar, programming, diversity, html, css, javascript, ruby, python' }
12-
%meta{ property: 'og:image', content: image_url('logo-square.png') }
13-
%meta{ property: 'og:url', content: request.original_url }
14-
%meta{ property: 'og:title', content: 'codebar' }
15-
%meta{ property: 'og:description', content: 'Making tech more diverse and welcoming by bringing people together and helping teach programming skills.' }
169
%meta{ name: 'description', content: 'Making tech more diverse and welcoming by bringing people together and helping teach programming skills.' }
10+
11+
- if content_for? :meta_tags
12+
= yield :meta_tags
13+
- else
14+
= render partial: 'shared/meta_tags'
15+
1716
%link{ rel: 'icon', sizes: '196x196', href: '/Icon-196.png'}
1817
%link{ rel: 'icon', sizes: '128x128', href: '/Icon-128.png'}
1918
%link{ rel: 'apple-touch-icon', sizes: '128x128', href: '/Icon-128.png'}
2019

21-
= content_for :meta_tags
22-
23-
%link{ rel: 'image_src', href: '/assets/logo-square.png', alt: 'codebar logo' }
24-
2520
%title= retrieve_title
2621
= favicon_link_tag 'favicon.ico'
2722
= stylesheet_link_tag('application', media: 'all', data: { turbo_track: 'reload' })
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
%meta{ property: 'og:title', content: 'codebar' }
2+
%meta{ property: 'og:type', content: 'website' }
3+
%meta{ property: 'og:url', content: request.original_url }
4+
%meta{ property: 'og:image', content: image_url('logo-square.png') }
5+
%meta{ property: 'og:description', content: 'Making tech more diverse and welcoming by bringing people together and helping teach programming skills.' }
6+
%meta{ property: 'og:site_name', content: 'codebar' }
7+
%meta{ property: 'og:locale', content: 'en_GB' }
8+
-# Only Twitter-specific tag needed
9+
%meta{ name: 'twitter:card', content: 'summary_large_image' }

app/views/virtual_workshops/_meta_tags.html.haml

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/views/virtual_workshops/show.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
- title t('workshop.virtual.title', chapter: @workshop.chapter.name, date: humanize_date(@workshop.date_and_time))
1+
- title t('workshops.virtual.title_with_date', chapter: @workshop.chapter.name, date: humanize_date(@workshop.date_and_time))
22

3-
= render partial: 'virtual_workshops/meta_tags', locals: { workshop: @workshop }
3+
= render partial: 'workshops/meta_tags', locals: { workshop: @workshop }
44

55
.container.py-4.py-lg-5
66
.row
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
1-
- content_for :meta_tags do
2-
- title = "Workshop at #{workshop.host.name}"
3-
- slack_description = "codebar #{workshop.chapter.name}"
1+
:ruby
2+
title = if workshop.virtual?
3+
t('workshops.virtual.title_with_date', chapter: workshop.chapter.name, date: humanize_date(workshop.date_and_time))
4+
else
5+
t('workshop.title', host: workshop.host.name, date: humanize_date(workshop.date_and_time))
6+
end
7+
url = request.original_url
8+
image = workshop.host.try(:image_url).presence || image_url('codebar-social.jpg')
9+
description = (workshop.virtual? ? t('workshops.virtual.lead') : t('workshops.lead'))
10+
11+
= content_for :meta_tags do
412
%meta{ property: 'og:title', content: title }
5-
%meta{ property: 'og:description', content: slack_description }
6-
%meta{ property: 'og:image', content: image_url('social-summary-card-image.png') }
13+
%meta{ property: 'og:type', content: 'event' }
14+
%meta{ property: 'og:url', content: url }
15+
%meta{ property: 'og:image', content: image }
16+
%meta{ property: 'og:description', content: description }
17+
%meta{ property: 'og:site_name', content: 'codebar' }
18+
%meta{ property: 'og:locale', content: 'en_GB' }
19+
20+
-# Only Twitter-specific tag needed
21+
%meta{ name: 'twitter:card', content: 'summary_large_image' }
22+
23+
-# Event timing
24+
%meta{ property: 'event:start_time', content: workshop.date_and_time }
25+
%meta{ property: 'event:end_time', content: workshop.ends_at }

config/locales/en.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ en:
128128
subject: "Reminder: you're on the codebar waiting list (%{date_time})"
129129
workshop:
130130
title: Workshop at %{host} - %{date}
131+
lead: 'Join us in our in-person workshops to learn programming in a supportive and collaborative environment at your own pace, or share your knowledge and coach our students.'
131132
calendar:
132133
summary: codebar @ %{host_name}
133134
description: "Declining or removing this event from your calendar does not update your invitation. If you are unable to attend please follow the link found on this calendar entry and update your attendance status. Missing codebar events repeatedly will result in a suspension.\n
134135
135136
Invitation link: %{invitation_link}"
136137
virtual:
137-
title: Virtual workshop for %{chapter} - %{date}
138138
calendar:
139139
location: codebar Slack (https://slack.codebar.io)
140140
description: "How to join\n
@@ -263,7 +263,8 @@ en:
263263
on_waiting_list: You are on the waiting list.
264264
virtual:
265265
title: 'Virtual workshop for %{chapter}'
266-
lead: 'Participate in our workshops to learn programming in a supportive and collaborative online environment at your own pace, or share your knowledge and coach our students.'
266+
title_with_date: 'Virtual workshop for %{chapter} 🌐 %{date}'
267+
lead: 'Participate in our online workshops to learn programming in a supportive and collaborative environment at your own pace, or share your knowledge and coach our students.'
267268
intro: 'Our virtual workshops take place online. Our aim is to help you get started with programming by pairing you with a coach that will be able to remotely assist and guide you through what you want to learn. Once you sign up we will email you more details about how to join the workshop and tools that we recommend to make the process easier for you. In the meantime if you have any questions, do not hesitate to send an email to %{chapter_email}.'
268269
events:
269270
title: "Events"

0 commit comments

Comments
 (0)