Skip to content

Commit

Permalink
Add more log and copy images to another location
Browse files Browse the repository at this point in the history
  • Loading branch information
b123400 committed Dec 30, 2023
1 parent 10ad378 commit 8701d11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/model/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Text
class ImageLink
attr_accessor :src, :style
def attributes
{ 'src' => @src, 'style' => @style }
{ 'src' => @src, 'style' => @style, 'alt' => '' }
end
def clean!
end
Expand Down
13 changes: 12 additions & 1 deletion src/plugin/text_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ def match(node_set, iksnr)
return name
end
def extract_image(html_file, name, type, lang, iksnrs)
LogFile.debug "Extracting image to #{name}"
if html_file && File.exist?(html_file)
resource_dir = (File.join(ODDB::IMAGE_DIR, type.to_s, lang.to_s))
FileUtils.mkdir_p(resource_dir)
Expand Down Expand Up @@ -1274,7 +1275,7 @@ def parse_textinfo(meta_info)
return
end
styles = res[1]
extract_image(html_name, meta_info.title, meta_info.type, meta_info.lang, meta_info.authNrs)
textinfo_pi_name = nil
if type == :fi
if is_same_html && !@options[:reparse] && reg && reg.fachinfo && text_info.descriptions.keys.index(meta_info.lang)
LogFile.debug "parse_textinfo #{__LINE__} #{meta_info.iksnr} at #{nr_uptodate}: #{type} #{html_name} is_same_html #{html_name}"
Expand All @@ -1292,8 +1293,18 @@ def parse_textinfo(meta_info)
end
textinfo_pi = @parser.parse_patinfo_html(html_name, @format, meta_info.title, styles)
update_patinfo_lang(meta_info, { meta_info.lang => textinfo_pi } )
textinfo_pi_name = textinfo_pi.name
textinfo_pi = nil
end
# Extract image to path generated from XML title,
# This should be the "correct" path
extract_image(html_name, meta_info.title, meta_info.type, meta_info.lang, meta_info.authNrs)
# However, ODBA is always buggy, sometimes it just doesn't like saving objects #231
# There's case which the Html pointed the image to a wrong path, and we cannot update
# the HTML because ODBA's problem, so here we extract image to path generated from the wrong H1 title,
if !textinfo_pi_name.nil?
extract_image(html_name, textinfo_pi_name, meta_info.type, meta_info.lang, meta_info.authNrs)
end
LogFile.debug "parse_textinfo #{__LINE__} at #{nr_uptodate}: #{type} textinfo #{textinfo.to_s.split("\n")[0..2]}" if self.respond_to?(:textinfo)
if reg
reg.odba_store
Expand Down

0 comments on commit 8701d11

Please sign in to comment.