_docker/lib/export/export_html_post_processor.rb
#
# access.redhat.com links are broken when we strip off the trailing "/index.html" to fix the site export structure.
# This fixes that.
#
access.redhat.com links are broken when we strip off the trailing "/index.html" to fix the site export structure.
This fixes that.
access . redhat . com links are broken when we strip off the trailing " / index . html " to fix the site export structure . This fixes that .
def rewrite_access_redhat_com_links(html_doc, html_file_name)
    links_to_modify = html_doc.css("body a[href*=\"access.redhat.com\"]")
    modified = false
    links_to_modify.each do | link |
      if link.attributes['href'].value.include?('documentation')
        uri = URI(link.attributes['href'].value)
         Only perform processing on the link if it doesn't already link to an allowed
         documentation suffix e.g. .html, .pdf or .epub
        allowed_link_suffix = @documentation_link_suffixes.any? { | suffix | uri.path.to_s.end_with?(suffix)}
        unless allowed_link_suffix
          new_path = uri.path.end_with?('/') ? "{uri.path}index.html" : "{uri.path}/index.html"
          uri.path = new_path
          new_href = uri.to_s
          @log.info("\tModifying documentation link {link.attributes['href'].to_s} to {new_href}")
          link.attributes['href'].value = new_href
          modified = true
        end
      end
    end
    modified
  end
def rewrite_access_redhat_com_links ( html_doc , html_file_name ) links_to_modify = html_doc . css ( "body a[href*=\"access.redhat.com\"]" ) modified = false links_to_modify . each do | link | if link . attributes [ 'href' ] . value . include? ( 'documentation' ) uri = URI ( link . attributes [ 'href' ] . value ) allowed_link_suffix = @documentation_link_suffixes . any? { | suffix | uri . path . to_s . end_with? ( suffix ) } unless allowed_link_suffix new_path = uri . path . end_with? ( '/' ) ? "#{uri.path}index.html" : "#{uri.path}/index.html" uri . path = new_path new_href = uri . to_s @log . info ( "\tModifying documentation link #{link.attributes['href'].to_s} to #{new_href}" ) link . attributes [ 'href' ] . value = new_href modified = true end end end modified end
access.redhat.com links are broken when we strip off the trailing "/index.html" to fix the site export structure.
access . redhat . com links are broken when we strip off the trailing " / index . html " to fix the site export structure .
# # Only perform processing on the link if it doesn't already link to an allowed # documentation suffix e.g. .html, .pdf or .epub #
html_doc
html_file_name