Added functionality to create directory structure for channels and videos

This commit is contained in:
Gregory Ballantine 2023-03-06 15:59:09 -05:00
parent a2f2224b96
commit f243452783
6 changed files with 34 additions and 2 deletions

View File

@ -2,6 +2,19 @@ class Channel < Sequel::Model
one_to_many :videos
def ensureDirectoryStructure()
sub_dirs = ['Archive', 'Channel Documents', 'Main', 'Shorts']
sub_dirs.each do |d|
sub_path = File.join(
@values[:directory_path],
d
)
unless Dir.exist?(sub_path)
Dir.mkdir(sub_path)
end
end
end
def openProjects()
return 0
end

View File

@ -4,6 +4,19 @@ class Video < Sequel::Model
many_to_one :channel
def ensureDirectoryStructure()
sub_dirs = ['Audio', 'B-Roll', 'Clips', 'Images', 'Export']
sub_dirs.each do |d|
sub_path = File.join(
@values[:directory_path],
d
)
unless Dir.exist?(sub_path)
Dir.mkdir(sub_path)
end
end
end
def parseScript()
return Kramdown::Document.new(@values[:script]).to_html
end

View File

@ -24,7 +24,9 @@ namespace '/channel' do
description: params[:channel_description]
)
# create supporting directory structure
Dir.mkdir(channel.directory_path)
channel.ensureDirectoryStructure()
redirect "/channel/#{channel.id}"
end

View File

@ -25,6 +25,7 @@ namespace '/video' do
video_serial = params[:video_serial].to_s.rjust(4, '0')
video_path = File.join(
channel.directory_path,
'Main',
"##{video_serial} - #{params[:video_name]}"
)
@ -37,7 +38,9 @@ namespace '/video' do
script: "# Introduction\n\n# Body\n\n# Conclusions"
)
# create supporting directory structure
Dir.mkdir(video_path)
video.ensureDirectoryStructure()
redirect "/video/#{video.id}"
end
@ -72,6 +75,7 @@ namespace '/video' do
video_serial = params[:video_serial].to_s.rjust(4, '0')
video_path = File.join(
channel.directory_path,
'Main',
"##{video_serial} - #{params[:video_name]}"
)

View File

@ -1,6 +1,6 @@
<div class="row">
<div class="twelve columns">
<h1>Hardware Inventory List</h1>
<h1>Channel List</h1>
</div>
</div>

View File

@ -1,6 +1,6 @@
<div class="row">
<div class="twelve columns">
<h1>Hardware Inventory List</h1>
<h1>Video List</h1>
</div>
</div>