Skip to content

Conversation

@kisiohlova
Copy link
Owner

@kisiohlova kisiohlova commented Nov 19, 2023

Added PDF viewer to the Show page with Adobe PDF Embed API.
Add view test.

telegram-cloud-photo-size-2-5395745316814313320-y

PDF Viewer on show book page.
telegram-cloud-photo-size-2-5395745316814313319-y

No download or print option
image

Book content only visible for authorised users.
image

@kisiohlova kisiohlova closed this Nov 19, 2023
@kisiohlova kisiohlova deleted the feature/pdf-viewer branch November 19, 2023 14:13
@kisiohlova kisiohlova restored the feature/pdf-viewer branch November 19, 2023 14:14
@kisiohlova kisiohlova reopened this Nov 19, 2023
@kisiohlova kisiohlova changed the base branch from main to feature/elasticsearch-chewy November 19, 2023 14:16
@kisiohlova kisiohlova self-assigned this Nov 19, 2023
@kisiohlova kisiohlova requested a review from loqimean November 19, 2023 14:17

def show
@book = resource
@adobe_pdf_api_key = ENV["ADOBE_PDF_API_KEY"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я не впевнений, що такі штуки тре в контроллері юзати-передавати

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 43 to 56
<script>
const previewConfig = {
showDownloadPDF: false,
showPrintPDF: false,
showAnnotationTools: false
}

document.addEventListener("adobe_dc_view_sdk.ready", function () {
var adobeDCView = new AdobeDC.View({ clientId: "<%= @adobe_pdf_api_key %>", divId: "pdf-viewer" });
adobeDCView.previewFile({
content: { location: { url: "<%= rails_blob_path(@book.content, only_path: true) %>" } },
metaData: { fileName: "<%= @book.content.filename %>" },
}, previewConfig);
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

стімулус контроллери для кого?))

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 14 to 18
if user.present? && book.content.attached?
expect(rendered).to include("src=\"https://documentcloud.adobe.com/view-sdk/main.js\"")
else
expect(rendered).not_to include("src=\"https://documentcloud.adobe.com/view-sdk/main.js\"")
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

це ще що таке?) то щось не гуд

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants