2012-11-15 14:39:01 +00:00
|
|
|
require 'mime/types'
|
|
|
|
|
2012-05-03 13:30:12 +00:00
|
|
|
class DesktopPublicationsController< ApplicationController
|
2012-11-13 09:21:23 +00:00
|
|
|
def journal_p
|
|
|
|
render "desktop/journal_p", :layout => false
|
|
|
|
end
|
2012-07-04 10:49:10 +00:00
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
def journal_p_list
|
|
|
|
render "desktop/journal_pages/list", :layout => false
|
|
|
|
end
|
2012-07-04 10:49:10 +00:00
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
def journal_p_add
|
2012-11-15 17:53:45 +00:00
|
|
|
@writing_journal = WritingJournal.new
|
|
|
|
|
|
|
|
# respond_to do |format|
|
|
|
|
# format.html # new.html.erb
|
|
|
|
# format.xml { render :xml => @writing_journal }
|
|
|
|
# end
|
2012-11-13 09:21:23 +00:00
|
|
|
render "desktop/journal_pages/add", :layout => false
|
|
|
|
end
|
2012-07-04 10:49:10 +00:00
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
def books
|
|
|
|
render "desktop/books", :layout => false
|
|
|
|
end
|
2012-07-04 11:12:02 +00:00
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
def books_list
|
|
|
|
render "desktop/books/list", :layout => false
|
|
|
|
end
|
|
|
|
|
|
|
|
def books_add
|
|
|
|
render "desktop/books/add", :layout => false
|
|
|
|
end
|
|
|
|
|
|
|
|
def seminar_p
|
|
|
|
render "desktop/seminar_p", :layout => false
|
|
|
|
end
|
|
|
|
|
|
|
|
def seminar_p_list
|
|
|
|
render "desktop/seminar_pages/list", :layout => false
|
|
|
|
end
|
2012-07-04 11:12:02 +00:00
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
def seminar_p_add
|
|
|
|
render "desktop/seminar_pages/add", :layout => false
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_journal
|
|
|
|
Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich")
|
|
|
|
b = Array.new
|
|
|
|
b << {"success"=>"true"}
|
|
|
|
render :json=>b.to_json
|
|
|
|
end
|
|
|
|
|
2012-11-15 14:39:01 +00:00
|
|
|
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
|
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
def getjournals
|
2012-11-15 17:53:45 +00:00
|
|
|
publications = WritingJournal.where(create_user_id: current_user.id)
|
|
|
|
p current_user.id
|
|
|
|
p "======="
|
2012-11-13 09:21:23 +00:00
|
|
|
|
|
|
|
sort_publications= Hash.new
|
|
|
|
data = Array.new
|
2012-11-15 14:39:01 +00:00
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
publications.each do |publication|
|
|
|
|
if sort_publications[publication.journal_title].nil?
|
|
|
|
sort_publications[publication.journal_title] = Array.new
|
|
|
|
end
|
|
|
|
sort_publications[publication.journal_title] <<
|
|
|
|
{ title: publication.paper_title,
|
|
|
|
keywords: publication.keywords,
|
|
|
|
abstract: publication.abstract,
|
|
|
|
level: publication.journal_paper_type_id,
|
|
|
|
coauthors: publication.authors,
|
2012-11-14 09:27:36 +00:00
|
|
|
year: publication.year,
|
|
|
|
files: publication.writing_journal_files.collect{|file|
|
2012-11-15 14:39:01 +00:00
|
|
|
{title: file.title, url: file.file.url, icon: check_file_type(file.file.url)}
|
2012-11-14 09:27:36 +00:00
|
|
|
}
|
2012-11-13 09:21:23 +00:00
|
|
|
}
|
2012-07-04 11:12:02 +00:00
|
|
|
end
|
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
sort_publications.each do |journal, papers|
|
|
|
|
data << {title: journal, papers: papers}
|
2012-06-28 09:31:48 +00:00
|
|
|
end
|
2012-07-03 11:45:47 +00:00
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
render json: JSON.pretty_generate(data)
|
|
|
|
end
|
2012-08-21 11:36:49 +00:00
|
|
|
|
2012-11-13 09:21:23 +00:00
|
|
|
def delete_journal
|
|
|
|
@journals = Journal.find("")
|
|
|
|
@journals.delete
|
|
|
|
b = Array.new
|
|
|
|
b << {"success"=>"true"}
|
|
|
|
render :json=>b.to_json
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_journal
|
|
|
|
@journal = Journal.find("4ff2d6ebbd98eb02b9000017")
|
|
|
|
@papers = @journal.papers
|
|
|
|
@papers.each do |paper|
|
|
|
|
paper.update_attributes(:user_id => current_user.id)
|
2012-07-03 11:45:47 +00:00
|
|
|
end
|
2012-11-13 09:21:23 +00:00
|
|
|
b = Array.new
|
|
|
|
|
|
|
|
b << {"success"=>"true"}
|
|
|
|
render :json=>b.to_json
|
|
|
|
end
|
2012-05-03 13:30:12 +00:00
|
|
|
end
|