Sha256: 270b86f82c1440a12dde9fbe364ad7ca32c66618bd8776e5c89a49be3fb8a6f8
Contents?: true
Size: 836 Bytes
Versions: 30
Compression:
Stored size: 836 Bytes
Contents
module Wovnrb class MetaReplacer < ReplacerBase def initialize(text_index) @text_index = text_index end def replace(dom, lang) dom.xpath('//meta').select { |node| next if wovn_ignore?(node) (node.get_attribute('name') || node.get_attribute('property') || '') =~ /^(description|title|og:title|og:description|twitter:title|twitter:description)$/ }.each do |node| node_content = node.get_attribute('content').strip # shouldn't need size check, but for now... if @text_index[node_content] && @text_index[node_content][lang.lang_code] && @text_index[node_content][lang.lang_code].size > 0 node.set_attribute('content', replace_text(node.get_attribute('content'), @text_index[node_content][lang.lang_code][0]['data'])) end end end end end
Version data entries
30 entries across 30 versions & 1 rubygems