8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/odania/filter.rb', line 8
def filter_html(obj, html, host)
doc = Nokogiri::HTML.fragment(html)
doc.css('a').each do |link|
unless link.attributes['href'].nil?
link.attributes['href'].value = get_click_counter_url(obj, link.attributes['href'].value, host)
link['rel'] = 'nofollow'
end
end
filtered_html = doc.to_s
tags = []
html.gsub(/#[a-z0-9\-]*[^< ]/i) do |match|
tag = match[1, match.length]
filtered_html.gsub!(match, "<a href=\"/#{obj.language.iso_639_1}/tags/#{tag.parameterize}\">#{tag}</a>")
tags << tag
end
return tags.join(','), filtered_html
end
|