imporvised smart_converter method to parsse content better
This commit is contained in:
parent
8171fddea6
commit
ad76febf40
|
@ -47,6 +47,8 @@ class AnnouncementFeedsController < ApplicationController
|
||||||
def smart_convertor(text)
|
def smart_convertor(text)
|
||||||
html_string = text
|
html_string = text
|
||||||
links = html_string.scan(/img.*?src="(.*?)"/i)
|
links = html_string.scan(/img.*?src="(.*?)"/i)
|
||||||
|
links = links + html_string.scan(/a.*?href="(.*?)"/i)
|
||||||
|
links.uniq!
|
||||||
links.each do |link|
|
links.each do |link|
|
||||||
l = link.first
|
l = link.first
|
||||||
new_link = nil
|
new_link = nil
|
||||||
|
@ -56,7 +58,7 @@ class AnnouncementFeedsController < ApplicationController
|
||||||
l1 = l.gsub("../","")
|
l1 = l.gsub("../","")
|
||||||
new_link = request.protocol + request.host_with_port + "/" + l1
|
new_link = request.protocol + request.host_with_port + "/" + l1
|
||||||
end
|
end
|
||||||
html_string = html_string.sub(l,new_link) if !new_link.nil?
|
html_string = html_string.gsub(l,new_link) if !new_link.nil?
|
||||||
end
|
end
|
||||||
return html_string
|
return html_string
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue