Sha256: 8abe9fd3fd695ac37afb54766e5bde86ae7bcd6bc937f5b23d67e43f94a28738
Contents?: true
Size: 1.65 KB
Versions: 5
Compression:
Stored size: 1.65 KB
Contents
module ApplicationHelper def flash_tag return '' if flash.blank? html = '' flash.each do |name, msg| if msg.is_a?(String) html << "<div class='action-alert alert alert-#{name} text-center m-c'>" html << "<button type='button' class='close'>×</button>" html << "#{msg}" html << '</div>' end end raw html end def aws_s3_json(directory) aws_s3_hash = { bucket: ENV['AWS_S3_BUCKET'], region: ENV['AWS_S3_REGION'], key_start: "#{ENV['AWS_S3_KEY_START']}#{directory}", acl: ENV['AWS_S3_ACL'], access_id: ENV['AWS_S3_ACCESS_ID'], signature: aws_s3_signature(directory), policy: aws_s3_policy(directory), } @aws_s3_json = aws_s3_hash.to_json end def froala_key ENV['FROALA_KEY']; end private def aws_s3_signature(directory) Base64.encode64( OpenSSL::HMAC.digest( OpenSSL::Digest.new('sha1'), ENV['AWS_S3_SECRET_KEY'], aws_s3_policy(directory) ) ).gsub("\n", '') end def aws_s3_policy(directory) Base64.encode64(aws_s3_policy_data(directory).to_json).gsub("\n", '') end def aws_s3_policy_data(directory) { expiration: 10.hours.from_now.utc.iso8601, conditions: [ ['starts-with', '$key', "#{ENV['AWS_S3_KEY_START']}#{directory}"], %w(starts-with $x-requested-with xhr), ['content-length-range', 0, 20.megabytes], ['starts-with', '$content-type', ''], {bucket: ENV['AWS_S3_BUCKET']}, {acl: ENV['AWS_S3_ACL']}, {success_action_status: '201'} ] } end end
Version data entries
5 entries across 5 versions & 1 rubygems