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 @@Name | -Size | -MD5 | -Modified | -
---|---|---|---|
- <%= link_to (h related.name.filename), related.name.url %> - | -- <%= related.size_s %> MB - | -- <%= related.md5_s %> - | -- <%= shorttime related.created_at %> - | -
Name | +Size | +MD5 | +Modified | +
---|---|---|---|
+ <%= link_to (h related.name.filename), related.name.url %> + | ++ <%= related.size_s %> MB + | ++ <%= related.md5_s %> + | ++ <%= shorttime related.created_at %> + | +
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
There is no preview available. Please download the movie and use eg. VLC
+ <% end %>