check file type
This commit is contained in:
parent
c627376fbe
commit
3144b84d10
2
Gemfile
2
Gemfile
|
@ -2,6 +2,7 @@ source 'http://rubygems.org'
|
||||||
gem 'rails', '>=3.1.0', '<3.2.0'
|
gem 'rails', '>=3.1.0', '<3.2.0'
|
||||||
|
|
||||||
gem "brakeman"
|
gem "brakeman"
|
||||||
|
gem 'mime-types'
|
||||||
|
|
||||||
gem 'bson_ext'
|
gem 'bson_ext'
|
||||||
gem 'carrierwave'
|
gem 'carrierwave'
|
||||||
|
@ -24,6 +25,7 @@ gem "mongo_session_store-rails3"
|
||||||
gem 'mysql2'
|
gem 'mysql2'
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
|
|
||||||
|
|
||||||
gem 'radius'
|
gem 'radius'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
# gem 'remotipart'
|
# gem 'remotipart'
|
||||||
|
|
|
@ -956,13 +956,17 @@ var orbitDesktop = function(dom){
|
||||||
var abstractview = function(){
|
var abstractview = function(){
|
||||||
$("#journal_p div#paper_list div.overview").empty();
|
$("#journal_p div#paper_list div.overview").empty();
|
||||||
var column = $('<div class="g_col list_t"><ul></ul></div>'),
|
var column = $('<div class="g_col list_t"><ul></ul></div>'),
|
||||||
|
counter = 1,
|
||||||
li;
|
li;
|
||||||
$.each(journalData,function(i,journal){
|
$.each(journalData,function(i,journal){
|
||||||
$.each(journal.papers,function(j,paper){
|
$.each(journal.papers,function(j,paper){
|
||||||
li = $('<li class="list_t_item" style="height:auto;"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.abstract+paper.abstract+'</div></li>');
|
li = $('<li class="list_t_item" style="height:auto;"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.abstract+'</div></li>');
|
||||||
column.find("ul").append(li);
|
column.find("ul").append(li);
|
||||||
|
if(counter%5==0){
|
||||||
$("#journal_p div#paper_list div.overview").append(column);
|
$("#journal_p div#paper_list div.overview").append(column);
|
||||||
column = $('<div class="g_col list_t"><ul></ul></div>');
|
column = $('<div class="g_col list_t"><ul></ul></div>');
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
$("#journal_p div#paper_list div.overview").append(column);
|
$("#journal_p div#paper_list div.overview").append(column);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'mime/types'
|
||||||
|
|
||||||
class DesktopPublicationsController< ApplicationController
|
class DesktopPublicationsController< ApplicationController
|
||||||
def journal_p
|
def journal_p
|
||||||
render "desktop/journal_p", :layout => false
|
render "desktop/journal_p", :layout => false
|
||||||
|
@ -42,12 +44,34 @@ class DesktopPublicationsController< ApplicationController
|
||||||
render :json=>b.to_json
|
render :json=>b.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_file_type file
|
||||||
|
if not file.nil?
|
||||||
|
file_type = MIME::Types.type_for(file).first.to_s.split("/")[1]
|
||||||
|
|
||||||
|
case file_type
|
||||||
|
when "jpg", "jpeg"
|
||||||
|
type = "jpg"
|
||||||
|
when "text", "txt"
|
||||||
|
type = "txt"
|
||||||
|
when "pdf"
|
||||||
|
type = "pdf"
|
||||||
|
when "png"
|
||||||
|
type = "png"
|
||||||
|
else "readme"
|
||||||
|
end
|
||||||
|
|
||||||
|
file_type = "/assets/ft-icons/#{type}/#{type}-48_32.png"
|
||||||
|
else
|
||||||
|
file_type = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def getjournals
|
def getjournals
|
||||||
publications = WritingJournal.where(:create_user_id => current_user.id)
|
publications = WritingJournal.where(:create_user_id => current_user.id)
|
||||||
|
|
||||||
sort_publications= Hash.new
|
sort_publications= Hash.new
|
||||||
data = Array.new
|
data = Array.new
|
||||||
icon_size = "128_32"
|
|
||||||
publications.each do |publication|
|
publications.each do |publication|
|
||||||
if sort_publications[publication.journal_title].nil?
|
if sort_publications[publication.journal_title].nil?
|
||||||
sort_publications[publication.journal_title] = Array.new
|
sort_publications[publication.journal_title] = Array.new
|
||||||
|
@ -60,7 +84,7 @@ class DesktopPublicationsController< ApplicationController
|
||||||
coauthors: publication.authors,
|
coauthors: publication.authors,
|
||||||
year: publication.year,
|
year: publication.year,
|
||||||
files: publication.writing_journal_files.collect{|file|
|
files: publication.writing_journal_files.collect{|file|
|
||||||
{title: file.title, url: file.file.url, icon: "/assets/ft-icons/jpg/jpg-48_32.png"}
|
{title: file.title, url: file.file.url, icon: check_file_type(file.file.url)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue