Skip to content

Commit

Permalink
podcaster info site
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Aug 6, 2024
1 parent da62998 commit 4c722f8
Show file tree
Hide file tree
Showing 38 changed files with 623 additions and 712 deletions.
Binary file modified .DS_Store
Binary file not shown.
13 changes: 7 additions & 6 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,35 +208,36 @@
}

textarea {
@apply block w-full rounded-md border-0 py-1.5 dark:bg-gray-900 dark:text-gray-100 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-brand-600 sm:text-sm sm:leading-6;
@apply block w-full rounded-md border-0 py-1.5 bg-muted text-default shadow-sm ring-1 ring-inset ring-subtle placeholder:text-subtle focus:ring-2 focus:ring-inset focus:ring-brand-600 sm:text-sm sm:leading-6;
}

.select,
select {
@apply block w-full rounded-md border-0 px-3 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-brand-600 sm:text-sm sm:leading-6;
@apply block w-full rounded-md border-0 px-3 pl-3 pr-10 text-default ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-brand-600 sm:text-sm sm:leading-6;
}

label {
@apply block text-sm font-medium text-gray-700 dark:text-gray-300 sm:mt-px sm:pt-2;
}

input[type="number"] {
@apply block w-full rounded-md border-0 px-3 pl-3 dark:bg-gray-900 dark:text-gray-100 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-brand-600 sm:text-sm sm:leading-6;
@apply block w-full rounded-md border-0 py-1.5 bg-muted text-default shadow-sm ring-1 ring-inset ring-subtle placeholder:text-subtle focus:ring-2 focus:ring-inset focus:ring-brand-600 sm:text-sm sm:leading-6;
}

input[type="date"],
input[type="datetime-local"] {
@apply block w-full rounded-md border-0 px-3 pl-3 pr-10 dark:bg-gray-900 dark:text-gray-100 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-brand-600 sm:text-sm sm:leading-6;
@apply block w-full rounded-md border-0 py-1.5 bg-muted text-default shadow-sm ring-1 ring-inset ring-subtle placeholder:text-subtle focus:ring-2 focus:ring-inset focus:ring-brand-600 sm:text-sm sm:leading-6;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"] {
@apply block w-full rounded-md border-0 px-3 pl-3 pr-10 dark:bg-gray-900 dark:text-gray-100 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-brand-600 sm:text-sm sm:leading-6;
@apply block w-full rounded-md border-0 py-1.5 bg-muted text-default shadow-sm ring-1 ring-inset ring-subtle placeholder:text-subtle focus:ring-2 focus:ring-inset focus:ring-brand-600 sm:text-sm sm:leading-6;
}

select {
@apply shadow-sm focus:ring-brand-500 focus:border-brand-500 block w-full sm:text-sm border-gray-300 dark:border-gray-600 rounded-md dark:bg-gray-900 dark:text-gray-100;
@apply shadow-sm focus:ring-brand-500 focus:border-brand-500 block w-full sm:text-sm border-muted rounded-md dark:bg-default;
}

label {
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ def become
redirect_to root_url, error: "not allowed"
end
end

def disable_footer
@disable_footer = true
end
end
31 changes: 14 additions & 17 deletions app/controllers/podcasts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
class PodcastsController < ApplicationController

before_action :find_user
before_action :unset_user_menu
before_action :disable_footer

def show
@user = User.find_by(username: params[:user_id])
def index
@collection = @user.tracks.published.podcasts.page(params[:page]).per(10)
end

def edit
@user = User.find_by(username: params[:user_id])
@info = @user.podcaster_info || @user.build_podcaster_info
def show
@podcast = @user.tracks.published.podcasts.friendly.find(params[:id])
end

def update
@user = User.find_by(username: params[:user_id])
@info = @user.podcaster_info || @user.build_podcaster_info
@info.update(podcaster_params)
redirect_to user_podcast_path(@user.username)
def about
end

private

def create
@user = User.find_by(username: params[:user_id])
@info = @user.podcaster_info || @user.build_podcaster_info
@info.update(podcaster_params)
redirect_to user_podcast_path(@user.username)
def unset_user_menu
@disable_user_menu = true
end


private
def find_user
@user = User.find_by(username: params[:user_id])
end

def podcaster_params
params.require(:podcaster_info).permit(:about, :title, :description)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def track_params
:display_comments, :display_stats, :include_in_rss,
:offline_listening, :enable_app_playblack,
:cover,
:podcast,
:copyright, :attribution, :noncommercial, :copies,
tags: []
)
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/user_settings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class UserSettingsController < ApplicationController
before_action :authenticate_user!
before_action :disable_footer

def show
@section = params[:section] || "profile"
Expand Down Expand Up @@ -47,7 +48,11 @@ def user_attributes
:new_message_app,
:profile_header,
:like_and_plays_on_your_post_email,
:tbk_commerce_code, :pst_enabled, :tbk_test_mode
:tbk_commerce_code, :pst_enabled, :tbk_test_mode,
podcaster_info_attributes: [
:title, :about, :description, :avatar, :id,
:spotify_url, :apple_podcasts_url, :google_podcasts_url, :stitcher_url, :overcast_url, :pocket_casts_url
]
)
end
end
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ def icon_for(kind)
<path d="M69.164 8.47l-.302-1.434h-4.196V24.04h4.848V12.5c1.147-1.5 3.082-1.208 3.698-1.017V7.038c-.646-.232-2.913-.658-4.048 1.43zm-9.73-5.646L54.698 3.83l-.02 15.562c0 2.87 2.158 4.993 5.038 4.993 1.585 0 2.756-.302 3.405-.643v-3.95c-.622.248-3.683 1.138-3.683-1.72v-6.9h3.683V7.035h-3.683zM46.3 11.97c0-.758.63-1.05 1.648-1.05a10.868 10.868 0 0 1 4.83 1.25V7.6a12.815 12.815 0 0 0-4.83-.888c-3.924 0-6.557 2.056-6.557 5.488 0 5.37 7.375 4.498 7.375 6.813 0 .906-.78 1.186-1.863 1.186-1.606 0-3.68-.664-5.307-1.55v4.63a13.461 13.461 0 0 0 5.307 1.117c4.033 0 6.813-1.992 6.813-5.485 0-5.796-7.417-4.76-7.417-6.943zM13.88 9.515c0-1.37 1.14-1.9 2.982-1.9A19.661 19.661 0 0 1 25.6 9.876v-8.27A23.184 23.184 0 0 0 16.862.001C9.762.001 5 3.72 5 9.93c0 9.716 13.342 8.138 13.342 12.326 0 1.638-1.4 2.146-3.37 2.146-2.905 0-6.657-1.202-9.6-2.802v8.378A24.353 24.353 0 0 0 14.973 32C22.27 32 27.3 28.395 27.3 22.077c0-10.486-13.42-8.613-13.42-12.56z" fill-rule="evenodd"/>
</svg>
HTML
when :podcast
heroicon("microphone")
else
""
end
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/tailwind_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ def text_field(attribute, options = {})
end
end

def url_field(attribute, options = {})
@template.content_tag :div, class: "w-full sm:w-full" do
[
options[:label].is_a?(FalseClass) ? @template.content_tag(:div) : @template.label_tag(tr(options[:label] || attribute), nil),
super(attribute, options.reverse_merge(class: "input")),
field_details(attribute, object, options)
].join.html_safe
end
end

def email_field(attribute, options = {})
@template.content_tag :div, class: "w-full sm:w-full" do
[
Expand Down
34 changes: 34 additions & 0 deletions app/models/podcaster_info.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
class PodcasterInfo < ApplicationRecord
belongs_to :user
has_one_attached :avatar


store_accessor :data, :spotify_url
store_accessor :data, :apple_podcasts_url
store_accessor :data, :google_podcasts_url
store_accessor :data, :stitcher_url
store_accessor :data, :overcast_url
store_accessor :data, :pocket_casts_url

# You can add validations for these fields if needed
validates :spotify_url, url: true, allow_blank: true
validates :apple_podcasts_url, url: true, allow_blank: true
validates :google_podcasts_url, url: true, allow_blank: true
validates :stitcher_url, url: true, allow_blank: true
validates :overcast_url, url: true, allow_blank: true
validates :pocket_casts_url, url: true, allow_blank: true

# You can add custom methods to work with these fields
def has_podcast_links?
spotify_url.present? || apple_podcasts_url.present? || google_podcasts_url.present? ||
stitcher_url.present? || overcast_url.present? || pocket_casts_url.present?
end

def podcast_links
{
spotify: spotify_url,
apple_podcasts: apple_podcasts_url,
google_podcasts: google_podcasts_url,
stitcher: stitcher_url,
overcast: overcast_url,
pocket_casts: pocket_casts_url
}.compact
end
end
2 changes: 2 additions & 0 deletions app/models/track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def check_label
# scope :private, -> { where.not(:private => true)}
scope :latests, -> { order("id desc") }

scope :podcasts, -> {where(podcast: true)}

# store_attribute :metadata, :ratio, :integer, limit: 1
# store_attribute :metadata, :login_at, :datetime
# #store_attribute :metadata, :active, :boolean
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class User < ApplicationRecord
store_attribute :settings, :tbk_test_mode, :boolean

accepts_nested_attributes_for :photos, allow_destroy: true
accepts_nested_attributes_for :podcaster_info, allow_destroy: true

scope :artists, -> { where(role: "artist").where.not(username: nil) }

Expand Down
19 changes: 19 additions & 0 deletions app/validators/url_validator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, (options[:message] || "must be a valid URL")) unless url_valid?(value)
end

# a URL may be technically well-formed but may
# not actually be valid, so this checks for both.
def url_valid?(url)
encoded_url = URI::DEFAULT_PARSER.escape(url)
url = begin
URI.parse(encoded_url)
rescue StandardError
false
end
url.is_a?(URI::HTTP) || url.is_a?(URI::HTTPS)
end
end
2 changes: 1 addition & 1 deletion app/views/articles/_article_highlights.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="py-8 sm:py-24- lg:max-w-7xl lg:mx-auto lg:py-32- lg:px-8">
<% if posts.any? %>
<div class="relative max-w-lg mx-auto divide-y-2 divide-gray-200 dark:divide-gray-100 lg:max-w-7xl">
<div class="relative max-w-lg mx-auto divide-y-2 divide-gray-200 dark:divide-muted lg:max-w-7xl">
<div class="mx-2 sm:mx-0">
<h2 class="text-xl sm:text-3xl tracking-tight font-extrabold text-gray-900 dark:text-gray-100 sm:text-4xl">
<%= t("articles.recent_publications") %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/articles/_categories_section.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
<div class="border-white border-t border-b flex items-center">
<div class="border-muted border-t border-b flex items-center">
<h2 class="text-3xl tracking-tight font-extrabold text-gray-900 dark:text-gray-100 sm:text-4xl py-4">
Reviews
</h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/articles/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="pt-16 pb-20 px-4 sm:px-6 lg:pt-24 lg:pb-28 lg:px-8">
<div class="relative max-w-lg mx-auto divide-y-2 divide-gray-200 dark:divide-gray-100 lg:max-w-7xl">
<div class="relative max-w-lg mx-auto divide-y-2 divide-gray-200 dark:divide-muted lg:max-w-7xl">
<div>
<h2 class="text-3xl tracking-tight font-extrabold text-gray-900 dark:text-gray-100 sm:text-4xl">
<%= t("articles.recent_publications") %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/events/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="pt-16 pb-20 px-4 sm:px-6 lg:pt-24 lg:pb-28 lg:px-8">
<div class="relative max-w-lg mx-auto divide-y-2 divide-gray-200 dark:divide-gray-100 lg:max-w-7xl">
<div class="relative max-w-lg mx-auto divide-y-2 divide-muted lg:max-w-7xl">
<% if @upcoming_events.any? %>
<div>
<h2 class="text-3xl tracking-tight font-extrabold text-gray-900 dark:text-gray-100 sm:text-4xl">
Expand Down Expand Up @@ -40,7 +40,7 @@
<% end %>
</div>

<div class="relative max-w-lg mx-auto divide-y-2 divide-gray-200 dark:divide-gray-100 lg:max-w-7xl">
<div class="relative max-w-lg mx-auto divide-y-2 divide-gray-200 dark:divide-muted lg:max-w-7xl">
<div>
<h2 class="text-3xl tracking-tight font-extrabold text-gray-900 dark:text-gray-100 sm:text-4xl">
<%= t("events.past") %>
Expand Down
7 changes: 6 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

<body class="bg-default font-sans antialiased text-default dark"
data-controller="track-detector dark-mode">
<%= render "shared/user_menu" %>

<% if !@disable_user_menu %>
<%= render "shared/user_menu" %>
<% end %>
<%= yield %>

Expand Down Expand Up @@ -68,7 +71,9 @@
</script>
<% end %>
<% unless @disable_footer %>
<%= render("shared/footer", assigns) %>
<% end %>
<% if ENV["GA_ID"] %>
<!-- Google tag (gtag.js) -->
Expand Down
6 changes: 4 additions & 2 deletions app/views/podcasts/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
<svg aria-hidden="true" viewBox="0 0 11 12" class="h-3 w-auto fill-slate-300">
<path d="M5.019 5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm3.29 7c1.175 0 2.12-1.046 1.567-2.083A5.5 5.5 0 0 0 5.019 7 5.5 5.5 0 0 0 .162 9.917C-.39 10.954.554 12 1.73 12h6.578Z"></path>
</svg>
<span class="ml-2.5">Hosted by</span>
<span class="ml-2.5"><%= t("podcasts.hosted_by") %></span>
</h2>
<div class="mt-2 flex gap-6 text-sm font-bold leading-7 text-default">Eric Gordon <span aria-hidden="true" class="text-slate-400">/</span>Wes Mantooth </div>
<div class="mt-2 flex gap-6 text-sm font-bold leading-7 text-default">
<span aria-hidden="true" class="text-slate-400">/</span>
</div>
</div>
</footer>>
Loading

0 comments on commit 4c722f8

Please sign in to comment.