Skip to content

Commit

Permalink
Improve social handle setups
Browse files Browse the repository at this point in the history
- Add Bluesky
- Change "Twitter" to "X" (ugh)
  • Loading branch information
jerodsanto committed Dec 19, 2024
1 parent 94ef279 commit 4a30b61
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 79 deletions.
7 changes: 5 additions & 2 deletions assets/app/layout/show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,11 @@
&--mastodon {
background-image: url("../images/icons/podcast_icon-mastodon.png");
}
&--twitter {
background-image: url("../images/icons/podcast_icon-twitter.png");
&--bsky {
background-image: url("../images/icons/podcast_icon-bsky.png");
}
&--x {
background-image: url("../images/icons/podcast_icon-x.png");
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions assets/static/images/icons/icon-bsky-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions assets/static/images/icons/icon-bsky.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/static/images/icons/icon-x-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/static/images/icons/icon-x.svg
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 assets/static/images/icons/podcast_icon-bsky.png
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 assets/static/images/icons/podcast_icon-x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions lib/changelog/schema/person.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ defmodule Changelog.Person do
field :linkedin_handle, :string
field :mastodon_handle, :string
field :twitter_handle, :string
field :bsky_handle, :string
field :slack_id, :string
field :zulip_id, :string
field :website, :string
Expand Down Expand Up @@ -215,7 +216,7 @@ defmodule Changelog.Person do

def admin_insert_changeset(person, attrs \\ %{}) do
allowed = ~w(name email handle github_handle linkedin_handle mastodon_handle
twitter_handle bio website location admin host editor
twitter_handle bsky_handle bio website location admin host editor
public_profile approved)a

changeset_with_allowed_attrs(person, attrs, allowed)
Expand All @@ -232,7 +233,7 @@ defmodule Changelog.Person do

def insert_changeset(person, attrs \\ %{}) do
allowed = ~w(name email handle github_handle linkedin_handle mastodon_handle
twitter_handle bio website location public_profile)a
twitter_handle bsky_handle bio website location public_profile)a

changeset_with_allowed_attrs(person, attrs, allowed)
end
Expand Down Expand Up @@ -271,6 +272,7 @@ defmodule Changelog.Person do
|> unique_constraint(:linkedin_handle)
|> unique_constraint(:mastodon_handle)
|> unique_constraint(:twitter_handle)
|> unique_constraint(:bsky_handle)
end

defp validate_handle_allowed(changeset) do
Expand Down
5 changes: 4 additions & 1 deletion lib/changelog/schema/podcast/podcast.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ defmodule Changelog.Podcast do
field :mastodon_handle, :string
field :mastodon_token, :string
field :twitter_handle, :string
field :bsky_handle, :string
field :apple_url, :string
field :spotify_url, :string
field :riverside_url, :string
Expand Down Expand Up @@ -79,6 +80,7 @@ defmodule Changelog.Podcast do
status: :publishing,
is_meta: true,
twitter_handle: "changelog",
bsky_handle: "changelog.com",
mastodon_handle: "[email protected]",
mastodon_token: nil,
welcome: "Your one-stop shop for all Changelog podcasts",
Expand All @@ -105,6 +107,7 @@ defmodule Changelog.Podcast do
is_meta: true,
vanity_domain: "https://changelog.fm",
twitter_handle: "changelog",
bsky_handle: "changelog.com",
mastodon_handle: "[email protected]",
mastodon_token: nil,
welcome: "Software's best weekly news brief, deep technical interviews & talk show",
Expand Down Expand Up @@ -147,7 +150,7 @@ defmodule Changelog.Podcast do
podcast
|> cast(
attrs,
~w(name slug status vanity_domain schedule_note welcome description extended_description keywords mastodon_handle mastodon_token twitter_handle apple_url spotify_url riverside_url youtube_url clips_url zulip_url recorded_live partner position)a
~w(name slug status vanity_domain schedule_note welcome description extended_description keywords mastodon_handle mastodon_token twitter_handle bsky_handle apple_url spotify_url riverside_url youtube_url clips_url zulip_url recorded_live partner position)a
)
|> validate_required([:name, :slug, :status])
|> validate_format(:vanity_domain, Regexp.http(), message: Regexp.http_message())
Expand Down
10 changes: 10 additions & 0 deletions lib/changelog_web/helpers/shared_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ defmodule ChangelogWeb.Helpers.SharedHelpers do

def action_name(conn), do: Controller.action_name(conn)

def bsky_url(nil), do: ""
def bsky_url(%{bsky_handle: nil}), do: ""
def bsky_url(%{bsky_handle: handle}), do: bsky_url(handle)
def bsky_url(handle), do: "https://bsky.app/profile/#{handle}"

def comma_separated(number) do
number
|> Integer.to_charlist()
Expand Down Expand Up @@ -201,6 +206,11 @@ defmodule ChangelogWeb.Helpers.SharedHelpers do
end
end

def x_url(nil), do: ""
def x_url(%{twitter_handle: nil}), do: ""
def x_url(%{twitter_handle: handle}), do: x_url(handle)
def x_url(handle) when is_binary(handle), do: "https://x.com/#{handle}"

def word_count(nil), do: 0

def word_count(text) when is_binary(text) do
Expand Down
8 changes: 7 additions & 1 deletion lib/changelog_web/templates/admin/person/_form.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
</div>

<div class="three fields">
<div class="four fields">
<div class="field <%= AdminHelpers.error_class(f, :github_handle) %>">
<%= label(f, :github_handle, "GitHub Handle") %>
<%= text_input(f, :github_handle, placeholder: "gracehopper", autocapitalize: "none", mask: "slug") %>
Expand All @@ -45,6 +45,12 @@
<%= text_input(f, :mastodon_handle, placeholder: "[email protected]", autocapitalize: "none", mask: "slug") %>
<%= AdminHelpers.error_message(f, :mastodon_handle) %>
</div>

<div class="field <%= AdminHelpers.error_class(f, :bsky_handle) %>">
<%= label(f, :bsky_handle, "Bluesky Handle") %>
<%= text_input(f, :bsky_handle, placeholder: "gracehopper", autocapitalize: "none", mask: "slug") %>
<%= AdminHelpers.error_message(f, :bsky_handle) %>
</div>
</div>

<div class="three fields">
Expand Down
15 changes: 11 additions & 4 deletions lib/changelog_web/templates/admin/podcast/_form.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@
<%= AdminHelpers.error_message(f, :twitter_handle) %>
</div>

<div class={"field #{AdminHelpers.error_class(f, :bsky_handle)}"}>
<%= label(f, :bsky_handle, "On Bluesky") %>
<%= text_input(f, :bsky_handle, placeholder: "changelog.com") %>
</div>
</div>

<div class="two fields">
<div class={"field #{AdminHelpers.error_class(f, :mastodon_handle)}"}>
<%= label(f, :mastodon_handle, "On Mastodon") %>
<%= text_input(f, :mastodon_handle, placeholder: "[email protected]") %>
</div>
</div>

<div class={"field #{AdminHelpers.error_class(f, :mastodon_token)}"}>
<%= label(f, :mastodon_token, "Mastodon API Token") %>
<%= text_input(f, :mastodon_token) %>
<div class={"field #{AdminHelpers.error_class(f, :mastodon_token)}"}>
<%= label(f, :mastodon_token, "Mastodon API Token") %>
<%= text_input(f, :mastodon_token) %>
</div>
</div>

<div class="two fields">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
<input type="hidden" name="from" value="profile">

<div class="form-element_wrap form-element_wrap--2">
<div class="form-element <%= PublicHelpers.error_class(f, :name) %>">
<div class={"form-element #{PublicHelpers.error_class(f, :name)}"}>
<label>Name<span>*</span></label>
<%= text_input(f, :name, placeholder: "Grace Hopper") %>
<%= PublicHelpers.error_message(f, :name) %>
</div>

<div class="form-element <%= PublicHelpers.error_class(f, :handle) %>">
<div class={"form-element #{PublicHelpers.error_class(f, :handle)}"}>
<label>Username / Handle<span>*</span></label>
<%= text_input(f, :handle, placeholder: "gracehopper", autocapitalize: "none") %>
<%= PublicHelpers.error_message(f, :handle) %>
</div>
</div>

<div class="form-element_wrap form-element_wrap--2">
<div class="form-element <%= PublicHelpers.error_class(f, :avatar) %>">
<div class={"form-element #{PublicHelpers.error_class(f, :avatar)}"}>
<label>Avatar</label>
<%= file_input(f, :avatar) %>
<%= PublicHelpers.error_message(f, :avatar) %>
Expand All @@ -38,12 +38,12 @@

<div class="form-element">
<%= SharedHelpers.maybe_lazy_image(@conn, PersonView.avatar_url(@changeset.data), @changeset.data.name, width: 67, height: 67) %>
<p class="form-element-note"><%= if @changeset.data.avatar, do: "This image was uploaded to changelog.com", else: "This image is loaded from Gravatar" %>
<p class="form-element-note"><%= if @changeset.data.avatar, do: "This image was uploaded to changelog.com", else: "This image is loaded from Gravatar" %></p>
</div>
</div>

<div class="form-element_wrap form-element_wrap--3">
<div class="form-element <%= PublicHelpers.error_class(f, :github_handle) %>">
<div class="form-element_wrap form-element_wrap--2">
<div class={"form-element #{PublicHelpers.error_class(f, :github_handle)}"}>
<label>GitHub Handle</label>
<div class="form-element-preppended_field">
<span>github.com/</span>
Expand All @@ -52,27 +52,38 @@
<%= PublicHelpers.error_message(f, :github_handle) %>
</div>

<div class="form-element <%= PublicHelpers.error_class(f, :twitter_handle) %>">
<label>Twitter Handle</label>
<div class={"form-element #{PublicHelpers.error_class(f, :linkedin_handle)}"}>
<label>LinkedIn Handle</label>
<div class="form-element-preppended_field">
<span>linked.com/in/</span>
<%= text_input(f, :linkedin_handle, placeholder: "gracehopper", autocapitalize: "none") %>
</div>
<%= PublicHelpers.error_message(f, :linkedin_handle) %>
</div>
</div>

<div class="form-element_wrap form-element_wrap--2">
<div class={"form-element {PublicHelpers.error_class(f, :twitter_handle)}"}>
<label>X Handle</label>
<div class="form-element-preppended_field">
<span>twitter.com/</span>
<span>x.com/</span>
<%= text_input(f, :twitter_handle, placeholder: "gracehopper", autocapitalize: "none") %>
</div>
<%= PublicHelpers.error_message(f, :twitter_handle) %>
</div>

<div class="form-element <%= PublicHelpers.error_class(f, :linkedin_handle) %>">
<label>LinkedIn Handle</label>
<div class={"form-element {PublicHelpers.error_class(f, :bsky_handle)}"}>
<label>Bluesky Handle</label>
<div class="form-element-preppended_field">
<span>linked.com/in/</span>
<%= text_input(f, :linkedin_handle, placeholder: "gracehopper", autocapitalize: "none") %>
<span>bsky.app/profile/</span>
<%= text_input(f, :bsky_handle, placeholder: "gracehopper", autocapitalize: "none") %>
</div>
<%= PublicHelpers.error_message(f, :linkedin_handle) %>
<%= PublicHelpers.error_message(f, :bsky_handle) %>
</div>
</div>

<div class="form-element_wrap form-element_wrap--3">
<div class="form-element <%= PublicHelpers.error_class(f, :mastodon_handle) %>">
<div class={"form-element #{PublicHelpers.error_class(f, :mastodon_handle)}"}>
<label>Mastodon Handle</label>
<div class="form-element-preppended_field">
<span>@</span>
Expand All @@ -81,21 +92,21 @@
<%= PublicHelpers.error_message(f, :mastodon_handle) %>
</div>

<div class="form-element <%= PublicHelpers.error_class(f, :location) %>">
<div class={"form-element #{PublicHelpers.error_class(f, :location)}"}>
<label>Location</label>
<%= text_input(f, :location, placeholder: "New York, New York") %>
<%= PublicHelpers.error_message(f, :location) %>
</div>

<div class="form-element <%= PublicHelpers.error_class(f, :website) %>">
<div class={"form-element #{PublicHelpers.error_class(f, :website)}"}>
<label>Website URL</label>
<%= text_input(f, :website, placeholder: "https://gracehopper.com", autocapitalize: "none") %>
<%= PublicHelpers.error_message(f, :website) %>
</div>
</div>

<div class="form-element_wrap">
<div class="form-element <%= PublicHelpers.error_class(f, :bio) %>">
<div class={"form-element #{PublicHelpers.error_class(f, :bio)}"}>
<label>Bio</label>
<%= textarea(f, :bio) %>
<%= PublicHelpers.error_message(f, :bio) %>
Expand All @@ -104,7 +115,7 @@
</div>

<div class="form-checklist">
<div class="form-checklist-item <%= PublicHelpers.error_class(f, :public_profile) %>">
<div class={"form-checklist-item #{PublicHelpers.error_class(f, :public_profile)}"}>
<%= if Changelog.Policies.Person.profile(@current_user, @current_user) do %>
<label>
<%= checkbox(f, :public_profile) %>
Expand Down
Loading

0 comments on commit 4a30b61

Please sign in to comment.