check file type
This commit is contained in:
parent
61c0c4b542
commit
f93d019ba0
2
Gemfile
2
Gemfile
|
@ -2,6 +2,7 @@ source 'http://rubygems.org'
|
|||
gem 'rails', '>=3.1.0', '<3.2.0'
|
||||
|
||||
gem "brakeman"
|
||||
gem 'mime-types'
|
||||
|
||||
gem 'bson_ext'
|
||||
gem 'carrierwave'
|
||||
|
@ -24,6 +25,7 @@ gem "mongo_session_store-rails3"
|
|||
gem 'mysql2'
|
||||
gem 'nokogiri'
|
||||
|
||||
|
||||
gem 'radius'
|
||||
gem 'rake'
|
||||
# gem 'remotipart'
|
||||
|
|
|
@ -956,13 +956,17 @@ var orbitDesktop = function(dom){
|
|||
var abstractview = function(){
|
||||
$("#journal_p div#paper_list div.overview").empty();
|
||||
var column = $('<div class="g_col list_t"><ul></ul></div>'),
|
||||
counter = 1,
|
||||
li;
|
||||
$.each(journalData,function(i,journal){
|
||||
$.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);
|
||||
$("#journal_p div#paper_list div.overview").append(column);
|
||||
column = $('<div class="g_col list_t"><ul></ul></div>');
|
||||
if(counter%5==0){
|
||||
$("#journal_p div#paper_list div.overview").append(column);
|
||||
column = $('<div class="g_col list_t"><ul></ul></div>');
|
||||
}
|
||||
counter++;
|
||||
})
|
||||
})
|
||||
$("#journal_p div#paper_list div.overview").append(column);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'mime/types'
|
||||
|
||||
class DesktopPublicationsController< ApplicationController
|
||||
def journal_p
|
||||
render "desktop/journal_p", :layout => false
|
||||
|
@ -42,12 +44,34 @@ class DesktopPublicationsController< ApplicationController
|
|||
render :json=>b.to_json
|
||||
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
|
||||
publications = WritingJournal.where(:create_user_id => current_user.id)
|
||||
|
||||
sort_publications= Hash.new
|
||||
data = Array.new
|
||||
icon_size = "128_32"
|
||||
|
||||
publications.each do |publication|
|
||||
if sort_publications[publication.journal_title].nil?
|
||||
sort_publications[publication.journal_title] = Array.new
|
||||
|
@ -60,7 +84,7 @@ class DesktopPublicationsController< ApplicationController
|
|||
coauthors: publication.authors,
|
||||
year: publication.year,
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue