1
0
Fork 0
forked from OpenNeo/impress

camo the emotes on the campaign show page

This commit is contained in:
Matchu 2015-08-05 19:41:42 -04:00
parent 5d2c226357
commit 4a18f22571
3 changed files with 20 additions and 2 deletions

View file

@ -214,5 +214,19 @@ module ApplicationHelper
:contributions_link_url => user_contributions_path(user),
:user_points => user.points
end
def camo_image_url(image_url)
if CAMO_KEY
hexdigest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), CAMO_KEY, image_url)
uri = Addressable::URI.parse("#{CAMO_HOST}/#{hexdigest}")
uri.query_values = { 'url' => image_url, 'repo' => '', 'path' => '' }
uri.to_s
else
uri = Addressable::URI.parse(image_url)
query_values = uri.query_values || {}
uri.query_values = query_values.merge(NO_CAMO_CONFIG: nil)
uri.to_s
end
end
end

View file

@ -76,7 +76,7 @@
However, there are a few important bits of legal whatnot to keep in mind.
(Mostly, it's the list of things that we expect to do but in no legally
binding way promise to do. Just in case
<img src="http://images.neopets.com/neoboards/smilies/tongue.gif" />)
<img src="#{camo_image_url 'http://images.neopets.com/neoboards/smilies/tongue.gif'}" />)
Featuring your outfit is a thank-you gift that we like to give our donors;
it is *not* a purchased service. We make no guarantee that we'll post your
@ -98,7 +98,7 @@
Posting an obscene outfit then requesting a refund once we take it down is
*not* acting in good faith, and we don't want our refund policy to
encourage that behavior
<img src="http://images.neopets.com/neoboards/smilies/tongue.gif" />
<img src="#{camo_image_url 'http://images.neopets.com/neoboards/smilies/tongue.gif'}" />
We determine "good faith" at our sole discretion—not limited to those
examples—but we're generally pretty understanding.)

View file

@ -0,0 +1,4 @@
# For the openneo-camo.herokuapps.com server, which proxies assets through HTTPS.
# If you have no config, that's okay; we'll just serve the regular URL instead of the Camo URL.
CAMO_HOST = ENV['CAMO_HOST']
CAMO_KEY = ENV['CAMO_KEY']