From 4a18f2257166cf59676df1e4a94b9dfc572a4a6b Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 5 Aug 2015 19:41:42 -0400 Subject: [PATCH] camo the emotes on the campaign show page --- app/helpers/application_helper.rb | 14 ++++++++++++++ app/views/campaigns/show.html.haml | 4 ++-- config/initializers/camo.rb | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 config/initializers/camo.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7fe406b4..817cbd4f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/views/campaigns/show.html.haml b/app/views/campaigns/show.html.haml index 730dccec..4ee45f18 100644 --- a/app/views/campaigns/show.html.haml +++ b/app/views/campaigns/show.html.haml @@ -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 - ) + ) 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 - + We determine "good faith" at our sole discretion—not limited to those examples—but we're generally pretty understanding.) diff --git a/config/initializers/camo.rb b/config/initializers/camo.rb new file mode 100644 index 00000000..40f6cbef --- /dev/null +++ b/config/initializers/camo.rb @@ -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']