Fix moveis and rmove flowplayer

This commit is contained in:
Ari Timonen 2020-03-22 19:47:24 +02:00
parent 30eaf37752
commit 84a1e13c95
9 changed files with 95 additions and 112 deletions

View file

@ -2,7 +2,6 @@
//= require jquery_ujs
//= require jquery.periodicalupdater
//= require jquery.jplayer.min
//= require flowplayer
//= require yetii
//= require local
//= require shoutbox

File diff suppressed because one or more lines are too long

View file

@ -29,11 +29,13 @@ module ApplicationHelper
when "Comment"
model.commentable
when "Post"
model.topic
model.topic
else
model
end
str = model.to_s
# Reduce length of too long model names
if length and str.length > length
link_to str.to_s[0, length] + "...", model, class: model.class.to_s.downcase
else
@ -96,7 +98,8 @@ module ApplicationHelper
next if str == "" or str.nil?
if model[key].instance_of?(Time)
result << shorttime(str)
# result << shorttime(str)
result << model[key].to_formatted_s(:long_ordinal)
elsif element.instance_of?(Symbol)
result << namelink(str)
elsif key.to_s.match(/^(.*)_b$/)

View file

@ -21,15 +21,17 @@
# index_data_files_on_related_id (related_id)
#
# DataFile uses CarrierWave to manage files. The attrribute 'name' is the most crucial attribute.
# Avoid using .path for anything, rather use .location which is alias.
require 'digest/md5'
class DataFile < ActiveRecord::Base
include Extra
MEGABYTE = 1048576
MEGABYTE = 1_048_576
attr_accessor :related_id
#attr_protected :id, :updated_at, :created_at, :path, :size, :md5
scope :recent, -> { order("created_at DESC").limit(8) }
scope :demos, -> { order("created_at DESC").where("directory_id IN (SELECT id FROM directories WHERE parent_id = ?)", Directory::DEMOS) }
@ -57,7 +59,7 @@ class DataFile < ActiveRecord::Base
mount_uploader :name, FileUploader
def to_s
(description.nil? or description.empty?) ? File.basename(name.to_s) : description
description&.empty? ? File.basename(name.to_s) : description
end
def md5_s
@ -72,6 +74,7 @@ class DataFile < ActiveRecord::Base
(size.to_f/MEGABYTE).round(2).to_s + " MB"
end
# Just an alias, use this to find the file's current path
def location
name.current_path
end
@ -82,6 +85,7 @@ class DataFile < ActiveRecord::Base
def process_file
self.md5 = "e948c22100d29623a1df48e1760494df"
if article
self.directory_id = Directory::ARTICLES
end
@ -92,12 +96,14 @@ class DataFile < ActiveRecord::Base
self.created_at = File.mtime(location)
end
# Update the path on creation
if path.nil? or directory_id_changed?
self.path = File.join(directory.path, File.basename(name.to_s))
end
# Move the file if it has moved
if !new_record? and directory_id_changed? and File.exists?(name.current_path)
FileUtils.mv(location, path)
FileUtils.mv(location, path)
end
if description.nil? or description.empty?

View file

@ -34,7 +34,7 @@ class Directory < ActiveRecord::Base
has_many :files, -> { order("name") }, :class_name => "DataFile"
scope :ordered, -> { order("name ASC") }
scope :filtered, -> { where(hidden: true) }
scope :filtered, -> { where(hidden: false) }
scope :of_parent, -> (parent) { where(parent_id: parent.id) }
validates_length_of [:name, :path], :in => 1..255

View file

@ -108,6 +108,16 @@ class Movie < ActiveRecord::Base
#end
end
def preview_url
if preview
preview.url
elsif movie.url.ends_with?(".mp4")
file.url
else
False
end
end
def make_preview x, y
result = file.full_path.gsub(/\.\w{3}$/, "") + "_preview.mp4"
params = "-vcodec libx264 -vpre hq -b 1200k -bt 1200k -acodec libmp3lame -ab 128k -ac 2"

View file

@ -1,48 +1,50 @@
<div id="file">
<h1><%=h @file %></h1>
<h1><%=h @file %></h1>
<%= cascade @file, [["Filename", "name.filename".to_sym], "size_s", "directory", "md5_s", ["Modified", "created_at"]] %>
<%= cascade @file, [["Filename", "name.identifier".to_sym], "size_s", "directory", ["Directory path", "directory.path".to_sym], "md5_s", ["Modified", "created_at"]] %>
<% if cuser and cuser.admin? %>
<% if cuser and cuser.admin? %>
<div class="actions">
<% if @file.can_update? cuser %>
<% if @file.can_update? cuser %>
<%= link_to 'Edit', edit_data_file_path(@file), class: 'button tiny' %>
<% end; if @file.can_destroy? cuser %>
<%= link_to 'Destroy', @file, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
<% end %>
<% end %>
</div>
<% end %>
<% end %>
<%= link_to "Download", @file.url, class: 'button' %>
<%= link_to "Download", @file.url, class: 'button' %>
<div class="files-list">
<h4>Related Files</h4>
<% if @file.related_files.count > 0 %>
<div class="files-list">
<h4>Related Files</h4>
<table class="striped">
<tr>
<th>Name</th>
<th>Size</th>
<th>MD5</th>
<th>Modified</th>
</tr>
<% @file.related_files.each do |related| %>
<tr>
<td>
<%= link_to (h related.name.filename), related.name.url %>
</td>
<td>
<%= related.size_s %> MB
</td>
<td>
<%= related.md5_s %>
</td>
<td>
<%= shorttime related.created_at %>
</td>
</tr>
<% end %>
</table>
</div>
<table class="striped">
<tr>
<th>Name</th>
<th>Size</th>
<th>MD5</th>
<th>Modified</th>
</tr>
<% @file.related_files.each do |related| %>
<tr>
<td>
<%= link_to (h related.name.filename), related.name.url %>
</td>
<td>
<%= related.size_s %> MB
</td>
<td>
<%= related.md5_s %>
</td>
<td>
<%= shorttime related.created_at %>
</td>
</tr>
<% end %>
</table>
</div>
<% end %>
</div>
<%= add_comments @file %>
<%= add_comments @file %>

View file

@ -1,28 +1,19 @@
<div class="movie-full">
<h1 class="fancy">
<span><%= namelink @movie %></span>
</h1>
<h1 class="fancy">
<span><%= namelink @movie %></span>
</h1>
<%= render partial: "movie", object: @movie %>
<%= render partial: "movie", object: @movie %>
<% if @movie.preview %>
<% if @movie.preview_url %>
<div class="player">
<%= javascript_include_tag 'flowplayer' %>
<video src="<%= @movie.preview.url %>" controls></video>
<script>
flowplayer("player", "/flash/flowplayer-3.1.3.swf", {
clip: {
autoPlay: false,
autoBuffering: false
}
});
</script>
<a id="player" href="<%= @movie.preview.url %>"></a>
<p>This is a low quality version. Please download better version from above. For broken links: try changing /ns1videos/ to /videos/ in the link.</p>
<p>This is a preview version and video quality may not be full. For best experince please download the movie and use eg. <a href="https://www.videolan.org/vlc/">VLC</a></p>
</div>
<% end %>
<% else %>
<p>There is no preview available. Please download the movie and use eg. <a href="https://www.videolan.org/vlc/">VLC</a></p>
<% end %>
</div>
<%= add_comments @movie.file %>
<%= add_comments @movie.file %>

View file

@ -1,30 +1,26 @@
<div class="box center">
<%= javascript_include_tag 'flowplayer' %>
<a
style="display:block;width:520px;height:330px"
id="player" class="centered">
</a>
<%= javascript_include_tag 'flowplayer' %>
<a style="display:block;width:520px;height:330px" id="player" class="centered">
</a>
<script>
flowplayer("player", "/flash/flowplayer-3.1.3.swf",
{
clip:
{
url: 'ensl.sdp',
live: true,
autoPlay: true,
autoBuffering: true,
provider: 'influxis'
},
plugins: {
influxis: {
url: '/flash/flowplayer.rtmp-3.1.3.swf',
netConnectionUrl: 'rtmp://ensl.org'
}
}
});
</script>
<script>
flowplayer("player", "/flash/flowplayer-3.1.3.swf", {
clip: {
url: 'ensl.sdp',
live: true,
autoPlay: true,
autoBuffering: true,
provider: 'influxis'
},
plugins: {
influxis: {
url: '/flash/flowplayer.rtmp-3.1.3.swf',
netConnectionUrl: 'rtmp://ensl.org'
}
}
});
</script>
</div>
<%= render :partial => "shoutmsgs/index", :locals => {:object => @movie} %>
<%= render :partial => "shoutmsgs/index", :locals => {:object => @movie} %>