diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 23550bd..343ab1a 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -2,7 +2,6 @@ //= require jquery_ujs //= require jquery.periodicalupdater //= require jquery.jplayer.min -//= require flowplayer //= require yetii //= require local //= require shoutbox diff --git a/app/assets/javascripts/flowplayer.js b/app/assets/javascripts/flowplayer.js deleted file mode 100644 index 9d8b28a..0000000 --- a/app/assets/javascripts/flowplayer.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * flowplayer.js 3.1.3. The Flowplayer API - * - * Copyright 2009 Flowplayer Oy - * - * This file is part of Flowplayer. - * - * Flowplayer is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Flowplayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Flowplayer. If not, see . - * - * Date: 2009-02-25 16:24:29 -0500 (Wed, 25 Feb 2009) - * Revision: 166 - */ -(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p1){var r=arguments[1];var q=(arguments.length==3)?arguments[2]:{};if(typeof o=="string"){if(o.indexOf(".")!=-1){var t=[];m(n(o),function(){t.push(new b(this,k(r),k(q)))});return new d(t)}else{var s=c(o);return new b(s!==null?s:o,r,q)}}else{if(o){return new b(o,r,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.prototype.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var e=typeof jQuery=="function";var i={width:"100%",height:"100%",allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:null,onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(e){jQuery.tools=jQuery.tools||{};jQuery.tools.flashembed={version:"1.0.4",conf:i}}function j(){if(c.done){return false}var l=document;if(l&&l.getElementsByTagName&&l.getElementById&&l.body){clearInterval(c.timer);c.timer=null;for(var k=0;k'}q.width=q.height=q.id=q.w3c=q.src=null;for(var l in q){if(q[l]!==null){n+=''}}var o="";if(t){for(var m in t){if(t[m]!==null){o+=m+"="+(typeof t[m]=="object"?g(t[m]):t[m])+"&"}}o=o.substring(0,o.length-1);n+='"}n+="";return n}function d(m,p,l){var k=flashembed.getVersion();f(this,{getContainer:function(){return m},getConf:function(){return p},getVersion:function(){return k},getFlashvars:function(){return l},getApi:function(){return m.firstChild},getHTML:function(){return a(p,l)}});var q=p.version;var r=p.expressInstall;var o=!q||flashembed.isSupported(q);if(o){p.onFail=p.version=p.expressInstall=null;m.innerHTML=a(p,l)}else{if(q&&r&&flashembed.isSupported([6,65])){f(p,{src:r});l={MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title};m.innerHTML=a(p,l)}else{if(m.innerHTML.replace(/\s/g,"")!==""){}else{m.innerHTML="

Flash version "+q+" or greater is required

"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"

"+(m.tagName=="A"?"

Click here to download latest version

":"

Download latest version from here

");if(m.tagName=="A"){m.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer"}}}}}if(!o&&p.onFail){var n=p.onFail.call(this);if(typeof n=="string"){m.innerHTML=n}}if(document.all){window[p.id]=document.getElementById(p.id)}}window.flashembed=function(l,m,k){if(typeof l=="string"){var n=document.getElementById(l);if(n){l=n}else{c(function(){flashembed(l,m,k)});return}}if(!l){return}if(typeof m=="string"){m={src:m}}var o=f({},i);f(o,m);return new d(l,o,k)};f(window.flashembed,{getVersion:function(){var m=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var l=navigator.plugins["Shockwave Flash"].description;if(typeof l!="undefined"){l=l.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var n=parseInt(l.replace(/^(.*)\..*$/,"$1"),10);var r=/r/.test(l)?parseInt(l.replace(/^.*r(.*)$/,"$1"),10):0;m=[n,r]}}else{if(window.ActiveXObject){try{var p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(q){try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");m=[6,0];p.AllowScriptAccess="always"}catch(k){if(m[0]==6){return m}}try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(o){}}if(typeof p=="object"){l=p.GetVariable("$version");if(typeof l!="undefined"){l=l.replace(/^\S+\s+(.*)$/,"$1").split(",");m=[parseInt(l[0],10),parseInt(l[2],10)]}}}}return m},isSupported:function(k){var m=flashembed.getVersion();var l=(m[0]>k[0])||(m[0]==k[0]&&m[1]>=k[1]);return l},domReady:c,asString:g,getHTML:a});if(e){jQuery.fn.flashembed=function(l,k){var m=null;this.each(function(){m=flashembed(this,l,k)});return l.api===false?this:m}}})(); \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 84737f5..dc5bb0f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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$/) diff --git a/app/models/data_file.rb b/app/models/data_file.rb index 2a70721..8f71a83 100644 --- a/app/models/data_file.rb +++ b/app/models/data_file.rb @@ -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? diff --git a/app/models/directory.rb b/app/models/directory.rb index 3e2057a..36e562d 100644 --- a/app/models/directory.rb +++ b/app/models/directory.rb @@ -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 diff --git a/app/models/movie.rb b/app/models/movie.rb index 2376b15..d0aa8f1 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -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" diff --git a/app/views/data_files/show.html.erb b/app/views/data_files/show.html.erb index 15c06f8..3e227d8 100644 --- a/app/views/data_files/show.html.erb +++ b/app/views/data_files/show.html.erb @@ -1,48 +1,50 @@
-

<%=h @file %>

+

<%=h @file %>

- <%= 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? %>
- <% 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 %>
- <% end %> + <% end %> - <%= link_to "Download", @file.url, class: 'button' %> + <%= link_to "Download", @file.url, class: 'button' %> -
-

Related Files

+ <% if @file.related_files.count > 0 %> +
+

Related Files

- - - - - - - - <% @file.related_files.each do |related| %> - - - - - - - <% end %> -
NameSizeMD5Modified
- <%= link_to (h related.name.filename), related.name.url %> - - <%= related.size_s %> MB - - <%= related.md5_s %> - - <%= shorttime related.created_at %> -
-
+ + + + + + + + <% @file.related_files.each do |related| %> + + + + + + + <% end %> +
NameSizeMD5Modified
+ <%= link_to (h related.name.filename), related.name.url %> + + <%= related.size_s %> MB + + <%= related.md5_s %> + + <%= shorttime related.created_at %> +
+
+ <% end %>
-<%= add_comments @file %> +<%= add_comments @file %> \ No newline at end of file diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index 11927cf..93acd3c 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -1,28 +1,19 @@
-

- <%= namelink @movie %> -

+

+ <%= namelink @movie %> +

- <%= render partial: "movie", object: @movie %> + <%= render partial: "movie", object: @movie %> - <% if @movie.preview %> + <% if @movie.preview_url %>
- <%= javascript_include_tag 'flowplayer' %> + - - - - -

This is a low quality version. Please download better version from above. For broken links: try changing /ns1videos/ to /videos/ in the link.

+

This is a preview version and video quality may not be full. For best experince please download the movie and use eg. VLC

- <% end %> + <% else %> +

There is no preview available. Please download the movie and use eg. VLC

+ <% end %>
-<%= add_comments @movie.file %> +<%= add_comments @movie.file %> \ No newline at end of file diff --git a/app/views/movies/stream.html.erb b/app/views/movies/stream.html.erb index 0606889..ce61402 100644 --- a/app/views/movies/stream.html.erb +++ b/app/views/movies/stream.html.erb @@ -1,30 +1,26 @@
- <%= javascript_include_tag 'flowplayer' %> - - + <%= javascript_include_tag 'flowplayer' %> + + - +
-<%= render :partial => "shoutmsgs/index", :locals => {:object => @movie} %> +<%= render :partial => "shoutmsgs/index", :locals => {:object => @movie} %> \ No newline at end of file