mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-28 13:31:06 +00:00
Fix moveis and rmove flowplayer
This commit is contained in:
parent
30eaf37752
commit
84a1e13c95
9 changed files with 95 additions and 112 deletions
|
@ -2,7 +2,6 @@
|
||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require jquery.periodicalupdater
|
//= require jquery.periodicalupdater
|
||||||
//= require jquery.jplayer.min
|
//= require jquery.jplayer.min
|
||||||
//= require flowplayer
|
|
||||||
//= require yetii
|
//= require yetii
|
||||||
//= require local
|
//= require local
|
||||||
//= require shoutbox
|
//= require shoutbox
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -34,6 +34,8 @@ module ApplicationHelper
|
||||||
model
|
model
|
||||||
end
|
end
|
||||||
str = model.to_s
|
str = model.to_s
|
||||||
|
|
||||||
|
# Reduce length of too long model names
|
||||||
if length and str.length > length
|
if length and str.length > length
|
||||||
link_to str.to_s[0, length] + "...", model, class: model.class.to_s.downcase
|
link_to str.to_s[0, length] + "...", model, class: model.class.to_s.downcase
|
||||||
else
|
else
|
||||||
|
@ -96,7 +98,8 @@ module ApplicationHelper
|
||||||
next if str == "" or str.nil?
|
next if str == "" or str.nil?
|
||||||
|
|
||||||
if model[key].instance_of?(Time)
|
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)
|
elsif element.instance_of?(Symbol)
|
||||||
result << namelink(str)
|
result << namelink(str)
|
||||||
elsif key.to_s.match(/^(.*)_b$/)
|
elsif key.to_s.match(/^(.*)_b$/)
|
||||||
|
|
|
@ -21,15 +21,17 @@
|
||||||
# index_data_files_on_related_id (related_id)
|
# 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'
|
require 'digest/md5'
|
||||||
|
|
||||||
class DataFile < ActiveRecord::Base
|
class DataFile < ActiveRecord::Base
|
||||||
include Extra
|
include Extra
|
||||||
|
|
||||||
MEGABYTE = 1048576
|
MEGABYTE = 1_048_576
|
||||||
|
|
||||||
attr_accessor :related_id
|
attr_accessor :related_id
|
||||||
#attr_protected :id, :updated_at, :created_at, :path, :size, :md5
|
|
||||||
|
|
||||||
scope :recent, -> { order("created_at DESC").limit(8) }
|
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) }
|
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
|
mount_uploader :name, FileUploader
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
(description.nil? or description.empty?) ? File.basename(name.to_s) : description
|
description&.empty? ? File.basename(name.to_s) : description
|
||||||
end
|
end
|
||||||
|
|
||||||
def md5_s
|
def md5_s
|
||||||
|
@ -72,6 +74,7 @@ class DataFile < ActiveRecord::Base
|
||||||
(size.to_f/MEGABYTE).round(2).to_s + " MB"
|
(size.to_f/MEGABYTE).round(2).to_s + " MB"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Just an alias, use this to find the file's current path
|
||||||
def location
|
def location
|
||||||
name.current_path
|
name.current_path
|
||||||
end
|
end
|
||||||
|
@ -82,6 +85,7 @@ class DataFile < ActiveRecord::Base
|
||||||
|
|
||||||
def process_file
|
def process_file
|
||||||
self.md5 = "e948c22100d29623a1df48e1760494df"
|
self.md5 = "e948c22100d29623a1df48e1760494df"
|
||||||
|
|
||||||
if article
|
if article
|
||||||
self.directory_id = Directory::ARTICLES
|
self.directory_id = Directory::ARTICLES
|
||||||
end
|
end
|
||||||
|
@ -92,10 +96,12 @@ class DataFile < ActiveRecord::Base
|
||||||
self.created_at = File.mtime(location)
|
self.created_at = File.mtime(location)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Update the path on creation
|
||||||
if path.nil? or directory_id_changed?
|
if path.nil? or directory_id_changed?
|
||||||
self.path = File.join(directory.path, File.basename(name.to_s))
|
self.path = File.join(directory.path, File.basename(name.to_s))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Move the file if it has moved
|
||||||
if !new_record? and directory_id_changed? and File.exists?(name.current_path)
|
if !new_record? and directory_id_changed? and File.exists?(name.current_path)
|
||||||
FileUtils.mv(location, path)
|
FileUtils.mv(location, path)
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Directory < ActiveRecord::Base
|
||||||
has_many :files, -> { order("name") }, :class_name => "DataFile"
|
has_many :files, -> { order("name") }, :class_name => "DataFile"
|
||||||
|
|
||||||
scope :ordered, -> { order("name ASC") }
|
scope :ordered, -> { order("name ASC") }
|
||||||
scope :filtered, -> { where(hidden: true) }
|
scope :filtered, -> { where(hidden: false) }
|
||||||
scope :of_parent, -> (parent) { where(parent_id: parent.id) }
|
scope :of_parent, -> (parent) { where(parent_id: parent.id) }
|
||||||
|
|
||||||
validates_length_of [:name, :path], :in => 1..255
|
validates_length_of [:name, :path], :in => 1..255
|
||||||
|
|
|
@ -108,6 +108,16 @@ class Movie < ActiveRecord::Base
|
||||||
#end
|
#end
|
||||||
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
|
def make_preview x, y
|
||||||
result = file.full_path.gsub(/\.\w{3}$/, "") + "_preview.mp4"
|
result = file.full_path.gsub(/\.\w{3}$/, "") + "_preview.mp4"
|
||||||
params = "-vcodec libx264 -vpre hq -b 1200k -bt 1200k -acodec libmp3lame -ab 128k -ac 2"
|
params = "-vcodec libx264 -vpre hq -b 1200k -bt 1200k -acodec libmp3lame -ab 128k -ac 2"
|
||||||
|
|
|
@ -1,48 +1,50 @@
|
||||||
<div id="file">
|
<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">
|
<div class="actions">
|
||||||
<% if @file.can_update? cuser %>
|
<% if @file.can_update? cuser %>
|
||||||
<%= link_to 'Edit', edit_data_file_path(@file), class: 'button tiny' %>
|
<%= link_to 'Edit', edit_data_file_path(@file), class: 'button tiny' %>
|
||||||
<% end; if @file.can_destroy? cuser %>
|
<% end; if @file.can_destroy? cuser %>
|
||||||
<%= link_to 'Destroy', @file, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
|
<%= link_to 'Destroy', @file, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= link_to "Download", @file.url, class: 'button' %>
|
<%= link_to "Download", @file.url, class: 'button' %>
|
||||||
|
|
||||||
<div class="files-list">
|
<% if @file.related_files.count > 0 %>
|
||||||
<h4>Related Files</h4>
|
<div class="files-list">
|
||||||
|
<h4>Related Files</h4>
|
||||||
|
|
||||||
<table class="striped">
|
<table class="striped">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Size</th>
|
<th>Size</th>
|
||||||
<th>MD5</th>
|
<th>MD5</th>
|
||||||
<th>Modified</th>
|
<th>Modified</th>
|
||||||
</tr>
|
</tr>
|
||||||
<% @file.related_files.each do |related| %>
|
<% @file.related_files.each do |related| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to (h related.name.filename), related.name.url %>
|
<%= link_to (h related.name.filename), related.name.url %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= related.size_s %> MB
|
<%= related.size_s %> MB
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= related.md5_s %>
|
<%= related.md5_s %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= shorttime related.created_at %>
|
<%= shorttime related.created_at %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= add_comments @file %>
|
<%= add_comments @file %>
|
|
@ -1,28 +1,19 @@
|
||||||
<div class="movie-full">
|
<div class="movie-full">
|
||||||
<h1 class="fancy">
|
<h1 class="fancy">
|
||||||
<span><%= namelink @movie %></span>
|
<span><%= namelink @movie %></span>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<%= render partial: "movie", object: @movie %>
|
<%= render partial: "movie", object: @movie %>
|
||||||
|
|
||||||
<% if @movie.preview %>
|
<% if @movie.preview_url %>
|
||||||
<div class="player">
|
<div class="player">
|
||||||
<%= javascript_include_tag 'flowplayer' %>
|
<video src="<%= @movie.preview.url %>" controls></video>
|
||||||
|
|
||||||
<script>
|
<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>
|
||||||
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>
|
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<%= add_comments @movie.file %>
|
<%= add_comments @movie.file %>
|
|
@ -1,29 +1,25 @@
|
||||||
<div class="box center">
|
<div class="box center">
|
||||||
<%= javascript_include_tag 'flowplayer' %>
|
<%= javascript_include_tag 'flowplayer' %>
|
||||||
<a
|
<a style="display:block;width:520px;height:330px" id="player" class="centered">
|
||||||
style="display:block;width:520px;height:330px"
|
</a>
|
||||||
id="player" class="centered">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
flowplayer("player", "/flash/flowplayer-3.1.3.swf",
|
flowplayer("player", "/flash/flowplayer-3.1.3.swf", {
|
||||||
{
|
clip: {
|
||||||
clip:
|
url: 'ensl.sdp',
|
||||||
{
|
live: true,
|
||||||
url: 'ensl.sdp',
|
autoPlay: true,
|
||||||
live: true,
|
autoBuffering: true,
|
||||||
autoPlay: true,
|
provider: 'influxis'
|
||||||
autoBuffering: true,
|
},
|
||||||
provider: 'influxis'
|
plugins: {
|
||||||
},
|
influxis: {
|
||||||
plugins: {
|
url: '/flash/flowplayer.rtmp-3.1.3.swf',
|
||||||
influxis: {
|
netConnectionUrl: 'rtmp://ensl.org'
|
||||||
url: '/flash/flowplayer.rtmp-3.1.3.swf',
|
}
|
||||||
netConnectionUrl: 'rtmp://ensl.org'
|
}
|
||||||
}
|
});
|
||||||
}
|
</script>
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue