Added directories to channels and videos
This commit is contained in:
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user