Added ability to view and edit video scripts

This commit is contained in:
Gregory Ballantine 2023-03-04 11:37:53 -05:00
parent 51ee9f00fb
commit 2305a8a300
5 changed files with 69 additions and 3 deletions

View File

@ -88,7 +88,7 @@ hr{
}
#sidebar{
background: #ddd;
background: #eee;
border: 1px solid #666;
div:not(:last-child){
@ -105,7 +105,8 @@ hr{
}
}
.actions-bar{
.actions-bar,
.script-controls{
padding: 0;
span{
@ -138,3 +139,8 @@ hr{
}
}
}
#video_script{
max-width: 100%;
min-height: 250px;
}

View File

@ -42,13 +42,20 @@ namespace '/video' do
get '/:video_id' do
video = Video.where(id: params[:video_id]).first()
puts "#{video.name}"
erb :'video/view', :locals => {
:title => video.name,
:video => video
}
end
get '/:video_id/script' do
video = Video.where(id: params[:video_id]).first()
erb :'video/script', :locals => {
:title => "Script: #{video.name}",
:video => video
}
end
get '/:video_id/edit' do
video = Video.where(id: params[:video_id]).first()
channels = Channel.all()
@ -86,4 +93,24 @@ namespace '/video' do
redirect "/video/#{video.id}"
end
get '/:video_id/edit/script' do
video = Video.where(id: params[:video_id]).first()
erb :'video/edit-script', :locals => {
:title => "Editing script: #{video.name}",
:video => video
}
end
post '/:video_id/edit/script' do
# find video and temporarily save the old video path
video = Video.where(id: params[:video_id]).first()
# edit video attributes
video.update(
script: params[:video_script]
)
# redirect the user
redirect "/video/#{video.id}"
end
end

View File

@ -0,0 +1,20 @@
<div class="row">
<div class="twelve columns">
<h1>Editing script for: <%= video.name %></h1>
</div>
</div>
<div class="row">
<div class="twelve columns">
<form action="/video/<%= video.id %>/edit/script" method="POST" class="u-full-width">
<div class="row">
<div class="twelve columns">
<label for="video_script">Video script:</label>
<textarea class="u-full-width" type="text" placeholder="Description of the video" id="video_script" name="video_script" rows="30"><%= video.script %></textarea>
</div>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
</div>

9
views/video/script.erb Normal file
View File

@ -0,0 +1,9 @@
<div id="video-script" class="row">
<div class="twelve columns">
<h1>Script: <%= video.name %></h1>
<hr>
<%= video.parseScript() %>
</div>
</div>

View File

@ -23,6 +23,10 @@
<div class="video-path">
<p><span><%= video.directory_path %></span></p>
</div>
<div class="script-controls">
<span><a href="/video/<%= video.id %>/script">View script <i class="fa-solid fa-scroll"></i></a></span><span>
<a href="/video/<%= video.id %>/edit/script">Edit script <i class="fa-solid fa-pen-to-square"></i></a></span>
</div>
</div>
</div>