Added directories to channels and videos

This commit is contained in:
2023-03-03 23:22:17 -05:00
parent db74e26124
commit ef1813f16e
8 changed files with 48 additions and 5 deletions

View File

@ -13,15 +13,19 @@ namespace '/channel' do
get '/create' do
erb :'channel/create', :locals => {
:title => 'Create new channel'
:title => 'Create new channel',
:base_directory => $conf.get('stgm.base_directory')
}
end
post '/create' do
channel = Channel.create(
name: params[:channel_name],
directory_path: params[:channel_dir],
description: params[:channel_description]
)
Dir.mkdir(channel.directory_path)
redirect "/channel/#{channel.id}"
end

View File

@ -19,13 +19,23 @@ namespace '/video' do
}
end
post '/create' do
channel = Channel.where(id: params[:video_channel]).first()
video_serial = params[:video_serial].to_s.rjust(4, '0')
video_path = File.join(
channel.directory_path,
"##{video_serial} - #{params[:video_name]}"
)
video = Video.create(
serial: params[:video_serial],
name: params[:video_name],
channel_id: params[:video_channel],
directory_path: video_path,
description: params[:video_description]
)
Dir.mkdir(video_path)
redirect "/video/#{video.id}"
end