fix story caching stuff once and for all
This commit is contained in:
parent
c09542a80a
commit
4c0aaf7c2e
|
@ -114,6 +114,7 @@ class Sponge
|
|||
end
|
||||
|
||||
host = Net::HTTP.new(ip.to_s, uri.port)
|
||||
host.read_timeout = self.timeout
|
||||
if self.debug
|
||||
host.set_debug_output $stdout
|
||||
end
|
||||
|
@ -161,12 +162,10 @@ class Sponge
|
|||
end
|
||||
|
||||
res = nil
|
||||
Timeout.timeout(self.timeout) do
|
||||
if method == :post
|
||||
res = host.post(path, post_data, headers)
|
||||
else
|
||||
res = host.get(path, headers)
|
||||
end
|
||||
if method == :post
|
||||
res = host.post(path, post_data, headers)
|
||||
else
|
||||
res = host.get(path, headers)
|
||||
end
|
||||
|
||||
if res.get_fields("Set-Cookie")
|
||||
|
|
|
@ -27,9 +27,14 @@ class StoryCacher
|
|||
if res.present?
|
||||
j = JSON.parse(res)
|
||||
|
||||
# turn newlines into double newlines, so they become paragraphs
|
||||
j["text"].gsub!("\n", "\n\n")
|
||||
|
||||
while j["text"].match("\n\n\n")
|
||||
j["text"].gsub!("\n\n\n", "\n\n")
|
||||
end
|
||||
|
||||
return j["text"]
|
||||
end
|
||||
|
||||
rescue => e
|
||||
|
|
Loading…
Reference in a new issue