diff --git a/app/assets/javascripts/channels/web_notification_channel.js b/app/assets/javascripts/channels/web_notification_channel.js index 34997ad..b94dea9 100644 --- a/app/assets/javascripts/channels/web_notification_channel.js +++ b/app/assets/javascripts/channels/web_notification_channel.js @@ -13,11 +13,6 @@ App.notifications = App.cable.subscriptions.create({ disconnected() { // Called when the subscription has been terminated by the server - // Display the connection has been lost message - this.container().innerHTML = '

Disconneced from server

' - setTimeout(() => { - this.container().innerHTML = ''; - }, 3000); console.log('Disconneced'); }, diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index aee6989..cbc0334 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -7,6 +7,7 @@ def index def show @collection = current_user.collection + #@collection.recipes.with_preloaded_image begin PdfGeneratorService.new(@collection).generate_pdf message ='Your Recipe book has been created' diff --git a/app/models/recipe.rb b/app/models/recipe.rb index 4ff52ed..76f8e37 100644 --- a/app/models/recipe.rb +++ b/app/models/recipe.rb @@ -11,6 +11,8 @@ class Recipe < ApplicationRecord belongs_to :category has_many :ratings + scope :with_preloaded_image, -> { preload(image_attachment: :blob) } + update_index('recipes') { self } after_create :notify diff --git a/app/services/pdf_generator_service.rb b/app/services/pdf_generator_service.rb index f4d3b50..e6e23ef 100644 --- a/app/services/pdf_generator_service.rb +++ b/app/services/pdf_generator_service.rb @@ -49,15 +49,15 @@ def create_and_configure_pdf end def front_page(pdf) - logo = "#{Rails.root}/app/assets/images/foodhublogo.png" + logo = "#{Rails.root}/app/assets/images/foodhub-logo.png" pdf.move_down 100 - pdf.image logo, position: :center, width: 450, height: 150 + pdf.image logo, position: :center, width: 200 pdf.move_down 100 pdf.text 'My Recipe Book', size: 48, align: :center pdf.move_down 150 pdf.text "by: #{ @collection.user.full_name}", size: 25, align: :right pdf.move_down 10 - pdf.text 'With Recipes from FoodHub', size: 18, align: :right + pdf.text 'With recipes from FoodHub', size: 18, align: :right end def add_attachment(filename) @@ -65,7 +65,10 @@ def add_attachment(filename) end def insert_image(pdf, recipe) - pdf.image open(recipe.image.service_url), width: 300, height: 250, position: :center + image_url = recipe.image.attachment.blob.service_url(expires_in: 1.hour) + #image_url = Rails.application.routes.url_helpers.rails_service_blob_url(recipe.image) + pdf.move_down 10 + pdf.image open(image_url), width: 500, position: :center if image_url pdf.move_down 15 end diff --git a/app/views/collections/index.html.haml b/app/views/collections/index.html.haml index 8627b56..a73b9b1 100644 --- a/app/views/collections/index.html.haml +++ b/app/views/collections/index.html.haml @@ -33,7 +33,7 @@ } if ( isPdfGenerated === true) { - setVisibilityOfViewPdfLink("#{rails_blob_url(@collection.pdf) if @collection.pdf.attached?}"); + setVisibilityOfViewPdfLink("#{rails_blob_url(@collection.pdf, disposition: "attachment") if @collection.pdf.attached?}"); } generateLink.addEventListener('ajax:success', event => { diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index d392534..005723e 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -mcBgmrthdyS3CpNPVFH7T5y4nPZDhTzbFSVom+tOU725XVrQhxbR7Pu8V9rYo80vcY7NUUlNlYCFnF8b+pYImbD/KAZ57PwBoUz37TsSfffCmQXBYs4MUsmFgh1MTzAL8KZktT7tMsAPkzf3mlxontNFz881umah9oV78LqHedlAKFrSRardhgv5T6BQQXD/6V0HKGe6zU9eBwtldrt/B7YeVwfjfKBPjv66rswbGS5UhMn6f/oA/1NYbZH0RDaQzooY77xjwZefX0gNJH1PxuEcE3svwk8ui5S7O1ILLX2euWMKEJCvG/RlboHGFXSM77wac0gIvkzlQaAvI7lN8s6+LOOKHhUG5nm+NWj6CPy/pnnUZNXN9yYBfj4bQdETAQhFjzOEG5l8kysYTW5rWJHyDuq5deqQqcUumBprN8AiWo2/akBJgqG6WgfqBbt8dZvyEYeRFESYYNPu24BlQlEuvUQW3wXVFBI3FwUWeGll8JKRNqsQiyufPCGx8cRg1S6woEIrcKJvTAIdVDEIC+XAXNPIoIVgWWxsRI54bQttW7WsMxbhQBVReF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