aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/i18n_fixes.rb11
-rw-r--r--lib/quiet_opener.rb12
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/i18n_fixes.rb b/lib/i18n_fixes.rb
index a85faddcb..82d1b2c3a 100644
--- a/lib/i18n_fixes.rb
+++ b/lib/i18n_fixes.rb
@@ -14,6 +14,17 @@ def _(key, options = {})
gettext_interpolate(translation, options)
end
+def n_(*keys)
+ # The last parameter should be the values to do the interpolation with
+ if keys.count > 3
+ options = keys.pop
+ else
+ options = {}
+ end
+ translation = FastGettext.n_(*keys).html_safe
+ gettext_interpolate(translation, options)
+end
+
MATCH = /\{\{([^\}]+)\}\}/
def gettext_interpolate(string, values)
diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb
index bde645d0b..ae6605c43 100644
--- a/lib/quiet_opener.rb
+++ b/lib/quiet_opener.rb
@@ -3,7 +3,7 @@ require 'net-purge'
require 'net/http/local'
def quietly_try_to_open(url)
- begin
+ begin
result = open(url).read.strip
rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET
Rails.logger.warn("Unable to open third-party URL #{url}")
@@ -11,12 +11,12 @@ def quietly_try_to_open(url)
end
return result
end
-
+
def quietly_try_to_purge(host, url)
- begin
+ begin
result = ""
result_body = ""
- Net::HTTP.bind '127.0.0.1' do
+ Net::HTTP.bind '127.0.0.1' do
Net::HTTP.start(host) {|http|
request = Net::HTTP::Purge.new(url)
response = http.request(request)
@@ -24,7 +24,7 @@ def quietly_try_to_purge(host, url)
result_body = response.body
}
end
- rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET
+ rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET, Errno::ENETUNREACH
Rails.logger.warn("PURGE: Unable to reach host #{host}")
end
if result == "200"
@@ -34,4 +34,4 @@ def quietly_try_to_purge(host, url)
end
return result
end
-
+