Skip to content

Commit

Permalink
Merge pull request #224 from razeware/WEB-6548
Browse files Browse the repository at this point in the history
WEB-6548: We mostly don't care about widths
  • Loading branch information
jellodiil authored Oct 12, 2023
2 parents fc7ff5f + 7827a97 commit 456e0e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions app/lib/image_provider/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/renderer/rw_markdown_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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('<figure title="', title, '"', ' class="', classes, '">')
out(' <picture>')
if svg?(alt_text, node.url)
Expand Down
12 changes: 6 additions & 6 deletions app/lib/runner/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 456e0e1

Please sign in to comment.