diff --git a/app/lib/image_provider/provider.rb b/app/lib/image_provider/provider.rb index 7eefc88..1a0b863 100644 --- a/app/lib/image_provider/provider.rb +++ b/app/lib/image_provider/provider.rb @@ -5,10 +5,11 @@ module ImageProvider class Provider include Util::Logging - attr_reader :extractor + attr_reader :extractor, :width_required - def initialize(extractor:) + def initialize(extractor:, width_required:) @extractor = extractor + @width_required = width_required end def process diff --git a/app/lib/renderer/rw_markdown_renderer.rb b/app/lib/renderer/rw_markdown_renderer.rb index 426289f..9e147a0 100644 --- a/app/lib/renderer/rw_markdown_renderer.rb +++ b/app/lib/renderer/rw_markdown_renderer.rb @@ -22,7 +22,7 @@ def image(node) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics alt_text = node.each.select { |child| child.type == :text }.map { |child| escape_html(child.string_content) }.join(' ') classes = class_list(alt_text) - if width_class?(alt_text) + if width_class?(alt_text) || @image_provider.width_required == false out('
') out(' ') if svg?(alt_text, node.url) diff --git a/app/lib/runner/base.rb b/app/lib/runner/base.rb index f6ccaed..819465b 100644 --- a/app/lib/runner/base.rb +++ b/app/lib/runner/base.rb @@ -19,7 +19,7 @@ def render_book(publish_file:, local: false) parser = Parser::Publish.new(file: publish_file) book = parser.parse image_extractor = ImageProvider::BookExtractor.new(book) - image_provider = local ? nil : ImageProvider::Provider.new(extractor: image_extractor) + image_provider = local ? nil : ImageProvider::Provider.new(extractor: image_extractor, width_required: true) image_provider&.process renderer = Renderer::Book.new(book, image_provider:) renderer.render @@ -31,7 +31,7 @@ def publish_book(publish_file:) parser = Parser::Publish.new(file: publish_file) book = parser.parse image_extractor = ImageProvider::BookExtractor.new(book) - image_provider = ImageProvider::Provider.new(extractor: image_extractor) + image_provider = ImageProvider::Provider.new(extractor: image_extractor, width_required: true) image_provider.process Renderer::Book.new(book, image_provider:).render Api::Alexandria::BookUploader.upload(book) @@ -60,7 +60,7 @@ def render_video_course(release_file:, local: false) parser = Parser::Release.new(file: release_file) video_course = parser.parse image_extractor = ImageProvider::VideoCourseExtractor.new(video_course) - image_provider = local ? nil : ImageProvider::Provider.new(extractor: image_extractor) + image_provider = local ? nil : ImageProvider::Provider.new(extractor: image_extractor, width_required: false) image_provider&.process renderer = Renderer::VideoCourse.new(video_course, image_provider:) renderer.render @@ -112,7 +112,7 @@ def publish_pablo(source:, output:) output ||= default_pablo_output image_extractor = ImageProvider::DirectoryExtractor.new(source) - image_provider = ImageProvider::Provider.new(extractor: image_extractor) + image_provider = ImageProvider::Provider.new(extractor: image_extractor, width_required: false) image_provider.process paths = image_extractor.categories.map { "/#{_1}" }.push('/', '/license', '/instructions', '/styles.css', '/javascript/search.js') @@ -130,7 +130,7 @@ def render_content_module(module_file:, local: false) parser = Parser::Circulate.new(file: module_file) content_module = parser.parse image_extractor = ImageProvider::ContentModuleExtractor.new(content_module) - image_provider = local ? nil : ImageProvider::Provider.new(extractor: image_extractor) + image_provider = local ? nil : ImageProvider::Provider.new(extractor: image_extractor, width_required: false) image_provider&.process renderer = Renderer::ContentModule.new(content_module, image_provider:) renderer.render @@ -156,7 +156,7 @@ def circulate_content_module(module_file:) content_module = parser.parse image_extractor = ImageProvider::ContentModuleExtractor.new(content_module) - image_provider = ImageProvider::Provider.new(extractor: image_extractor) + image_provider = ImageProvider::Provider.new(extractor: image_extractor, width_required: false) image_provider.process Renderer::ContentModule.new(content_module, image_provider:).render Api::Alexandria::ContentModuleUploader.upload(content_module)