Skip to content

Commit

Permalink
Stub in episode media tab
Browse files Browse the repository at this point in the history
  • Loading branch information
cavis committed Jul 31, 2023
1 parent 4fb348e commit bfa43a7
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
42 changes: 42 additions & 0 deletions app/controllers/episode_media_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class EpisodeMediaController < ApplicationController
before_action :set_episode

# GET /episodes/1/media
def show
authorize @episode, :show?
@episode.assign_attributes(episode_params)
@episode.valid?
end

# PATCH/PUT /episodes/1/media
def update
authorize @episode, :update?
@episode.assign_attributes(episode_params)

respond_to do |format|
if @episode.save
format.html { redirect_to episode_media_path(@episode), notice: t(".notice") }
else
flash.now[:error] = t(".error")
format.html { render :show, status: :unprocessable_entity }
end
end
end

private

def set_episode
@episode = Episode.find_by_guid!(params[:episode_id])
@episode.strict_validations = true
@podcast = @episode.podcast
end

def episode_params
nilify params.fetch(:episode, {}).permit(
:medium,
:ad_breaks,
contents_attributes: %i[id position original_url file_size _destroy _retry],
uncut_attributes: %i[id original_url file_size _destroy _retry]
)
end
end
13 changes: 13 additions & 0 deletions app/views/episode_media/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% content_for :title, "#{@episode.title} - #{t(".title")}" %>
<%= render "episodes/tabs" %>

<div class="row my-4 mx-2">
<div class="col-lg-8">
<div class="row">
episode media todo
</div>
</div>
<div class="col-lg-4 d-grid align-content-start gap-3">
</div>
</div>
9 changes: 5 additions & 4 deletions app/views/episodes/_tabs.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<% content_for :tabs do %>
<div class="list-group d-flex col">
<% if @episode.persisted? %>
<%= tab_link_to "Metadata", edit_episode_path(@episode), active: episode_metadata_active? %>
<%= tab_link_to t(".edit"), edit_episode_path(@episode), active: episode_metadata_active? %>
<%= tab_link_to t(".media"), episode_media_path(@episode) %>
<% if @episode.medium_uncut? %>
<%= tab_link_to "Audio Segmenter", episode_segmenter_path(@episode) %>
<%= tab_link_to t(".segmenter"), episode_segmenter_path(@episode) %>
<% end %>
<%= tab_link_to "Embeddable Player", episode_player_path(@episode) %>
<%= tab_link_to t(".player"), episode_player_path(@episode) %>
<% else %>
<%= tab_link_to "Metadata", new_podcast_episode_path(@podcast), active: true %>
<%= tab_link_to t(".edit"), new_podcast_episode_path(@podcast), active: true %>
<% end %>
</div>
<% end %>
8 changes: 8 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,18 @@ en:
message: The more drafts you add, the better we can support your podcast. Please add <a href="%{href}">all of your known upcoming episodes</a> to the Production Calendar.
okay: Okay
title: Missing Episode Drafts
tabs:
edit: Metadata
media: Media Files
player: Embeddable Player
segmenter: Audio Segmenter
update:
error: Unable to save
media_not_ready: Audio not ready
notice: Episode updated
episode_media:
show:
title: Media Files
episode_player:
form:
enclosure_not_ready: No Media Files Uploaded
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
end

resources :episodes, except: [:create, :new] do
resource :media, only: [:show, :update], controller: :episode_media
resource :player, only: :show, controller: :episode_player
resource :segmenter, only: [:show, :update], controller: :episode_segmenter
end
Expand Down

0 comments on commit bfa43a7

Please sign in to comment.