From b262d98873d4b4d10dca80fef0c3554e6214f716 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 11:25:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=BApdf=E7=9A=84?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD=EF=BC=8C=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_attachment_history.json.jbuilder | 3 ++- app/views/attachments/_attachment.json.jbuilder | 3 ++- app/views/attachments/_attachment_simple.json.jbuilder | 4 +++- app/views/attachments/_attachment_small.json.jbuilder | 4 ++-- app/views/files/histories.json.jbuilder | 8 +------- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 285aced42..6a02b569b 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -6,6 +6,7 @@ json.publish_time attachment.publish_time json.quotes attachment.quotes_count json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url attachment_path(attachment, type: 'history').gsub("/api","") +# json.url attachment_path(attachment, type: 'history').gsub("/api","") json.is_pdf attachment.is_history_pdf? +json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history').gsub("/api","") : attachment_path(attachment, type: 'history') json.attachment_id attachment.attachment_id diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index b87154157..76b9f2df0 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -11,6 +11,7 @@ json.quotes attachment.quotes_count json.description attachment.description json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) # json.url download_url(attachment) unless attachment.locked?(@is_member) diff --git a/app/views/attachments/_attachment_simple.json.jbuilder b/app/views/attachments/_attachment_simple.json.jbuilder index ad98fadb5..4bf6bd3e9 100644 --- a/app/views/attachments/_attachment_simple.json.jbuilder +++ b/app/views/attachments/_attachment_simple.json.jbuilder @@ -2,5 +2,7 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size attachment.filesize json.description attachment.description -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +# json.url download_url(attachment) json.set! :delete, delete.nil? ? true : delete if defined? delete \ No newline at end of file diff --git a/app/views/attachments/_attachment_small.json.jbuilder b/app/views/attachments/_attachment_small.json.jbuilder index 97cbee120..5a1faae3a 100644 --- a/app/views/attachments/_attachment_small.json.jbuilder +++ b/app/views/attachments/_attachment_small.json.jbuilder @@ -1,6 +1,6 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size(attachment.filesize) -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) json.created_on attachment.created_on -json.is_pdf attachment.is_pdf? \ No newline at end of file diff --git a/app/views/files/histories.json.jbuilder b/app/views/files/histories.json.jbuilder index ed322bb17..7039752e7 100644 --- a/app/views/files/histories.json.jbuilder +++ b/app/views/files/histories.json.jbuilder @@ -1,9 +1,3 @@ -# json.partial! 'attachments/attachment_small', attachment: @file -json.id @file.id -json.title @file.title -json.filesize number_to_human_size(@file.filesize) -json.url download_url(@file).gsub("/api","") -json.created_on @file.created_on -json.is_pdf @file.is_pdf? +json.partial! 'attachments/attachment_small', attachment: @file json.partial! "attachment_histories/list", attachment_histories: @attachment_histories