Skip to content

Commit

Permalink
Brave Rewards Integration
Browse files Browse the repository at this point in the history
Closes #1092
  • Loading branch information
yachtcaptain23 committed Sep 11, 2018
1 parent ba83b1d commit 92c8cec
Show file tree
Hide file tree
Showing 38 changed files with 1,176 additions and 40 deletions.
28 changes: 18 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}]
[
"env",
{
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}
],
"react"
],

"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread",
["transform-class-properties", { "spec": true }]
[
"transform-class-properties",
{
"spec": true
}
]
]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ dump.rdb
yarn-error.log
.DS_Store

# Ignore assets stored in /storage
/storage

# Ignore Byebug command history file.
.byebug_history
/ssl/
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ gem "api-pagination"
# Encrypt DB data at rest
gem "attr_encrypted", "~> 3.1.0"

# Use AWS gem for s3 uploads
gem 'aws-sdk-s3', require: false

gem "bootstrap", "~> 4.1.1"

# browser details
Expand Down
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ GEM
encryptor (~> 3.0.0)
autoprefixer-rails (9.0.0)
execjs
aws-eventstream (1.0.1)
aws-partitions (1.98.0)
aws-sdk-core (3.24.1)
aws-eventstream (~> 1.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-kms (1.7.0)
aws-sdk-core (~> 3)
aws-sigv4 (~> 1.0)
aws-sdk-s3 (1.17.0)
aws-sdk-core (~> 3, >= 3.21.2)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.0)
aws-sigv4 (1.0.3)
bcrypt (3.1.12)
bindex (0.5.0)
bootstrap (4.1.3)
Expand Down Expand Up @@ -158,6 +173,7 @@ GEM
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jmespath (1.4.0)
json (2.1.0)
jsonapi-renderer (0.2.0)
jwt (1.5.6)
Expand Down Expand Up @@ -435,6 +451,7 @@ DEPENDENCIES
activerecord-session_store
api-pagination
attr_encrypted (~> 3.1.0)
aws-sdk-s3
bootstrap (~> 4.1.1)
brakeman
browser
Expand Down
Binary file added app/assets/images/camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/camera@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/camera@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/icn-donation-jar@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/icn-donation-jar@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/icn-donation-jar@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions app/assets/images/icn-editPhoto.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions app/assets/stylesheets/pages/home.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
.camera-background {
background-size: 60px 47px;
width: 60px;
height: 47px;
background-image: url(asset-path("camera@2x.png"));
background-color: transparent;
border-style: none;
}

#icn-donation-jar {
margin-bottom: 30px;
}

.brave-rewards-banner {
&--background {
&-label {
display: block;
margin-left: -4px;
margin-top: 5px;
font-size: 16px;
}

&-camera {
margin-left: 46%;
margin-top: -60px;
}
}
&--logo {
&-parent {
position: relative;
}

&-label {
display: block;
margin-left: -4px;
margin-top: 5px;
font-size: 16px;
}

&-no-attachment {
margin-left: 30%;
position: absolute;
}

&-camera {
margin-left: 30%;
margin-top: 30%;
position: absolute;
}
}
}

.nav {
display: block;

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/banners_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class BannersController < ApplicationController
def new
@publisher_id = current_publisher.id
end
end
56 changes: 56 additions & 0 deletions app/controllers/publishers/site_banners_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class Publishers::SiteBannersController < ApplicationController
def new
@site_banner = current_publisher.site_banner || SiteBanner.new
end

def create
site_banner = current_publisher.site_banner || SiteBanner.new
donation_amounts = JSON.parse(params[:donation_amounts])
site_banner.update(
publisher_id: current_publisher.id,
title: params[:title],
donation_amounts: donation_amounts,
default_donation: donation_amounts[1],
social_links: params[:social_links],
description: params[:description]
)
head :ok
end

def update_logo
site_banner = current_publisher.site_banner
update_image(site_banner.logo)
head :ok
end

def update_background_image
site_banner = current_publisher.site_banner
update_image(site_banner.background_image)
head :ok
end

private

def update_image(attachment)
data_url = params[:image].split(',')[0]
if data_url.starts_with?("data:image/jpeg")
content_type = "image/jpeg"
extension = ".jpg"
elsif data_url.starts_with?("data:image/png")
content_type = "image/png"
extension = ".png"
else
# TODO: Throw an exception here
end
filename = Time.now.to_s.gsub!(" ", "_").gsub!(":", "_") + current_publisher.id + "_logo"

file = Tempfile.new([filename, extension])
File.open(file.path, 'wb') do |f|
f.write(Base64.decode64(params[:image].split(',')[1]))
end
attachment.attach(io: open(file.path),
filename: filename,
content_type: content_type
)
end
end
86 changes: 86 additions & 0 deletions app/javascript/locale/en.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const locale = {
about: 'about',
addFunds: 'add funds',
allowTip: 'Allow tips on',
braveRewards: 'Brave Rewards',
cancel: 'Cancel',
claim: 'Claim',
copy: 'Copy',
currentDonation: 'You’re currently donating {{currentDonation}} BAT to this site every month.',
detail: 'Detail',
donationAmount: 'Donation amount',
done: 'Done',
earningsAds: 'Earnings from Brave Ads',
expiresOn: 'expires on',
import: 'import',
makeMonthly: 'Make this monthly',
monthApr: 'Apr',
monthAug: 'August',
monthDec: 'December',
monthFeb: 'February',
monthJan: 'January',
monthJul: 'July',
monthJun: 'June',
monthMar: 'March',
monthMay: 'May',
monthNov: 'November',
monthOct: 'October',
monthSep: 'September',
noGrants: 'Currently no token grant is available.',
notEnoughTokens: 'Not enough tokens. Please',
on: 'on',
oneTime: 'One time',
oneTimeDonation: 'One-time Donations/Tips',
print: 'Print',
recoveryKeys: 'Recovery Key',
recurring: 'Recurring',
recurringDonations: 'Recurring Donations',
remove: 'remove',
restore: 'Restore',
rewardsBackupText1: 'Backup your Wallet',
rewardsBackupText2: 'Keep this anonymized recovery key for your Brave wallet in the safe place in case you lose access to this browser. Your funds are safe as long as you keep this recovery key either on a paper or in a device with preferably no internet connection.',
rewardsBannerText1: 'Thanks for stopping by. We joined Brave’s vision of protecting your privacy because we believe that fans like you would support us in our effort to keep the web a clean and safe place to be.',
rewardsBannerText2: 'Your donation is much appreciated and it encourages us to continue to improve our content.',
rewardsContribute: 'Brave Contribute',
rewardsContributeAttention: 'Your attention metric',
rewardsContributeText1: 'You’re currently supporting',
rewardsContributeVisited: 'Site visited',
rewardsOffText1: 'Do you know that you’ve been paying for the web content with your data for the digital ads? You didn’t have a voice in it and worse, you’re exposed to privacy and security risks.',
rewardsOffText2: 'Brave Rewards allows you to take control back.',
rewardsOffText3: 'How does it work?',
rewardsOffText4: 'Your attention is valuable. Get paid for the ads. And pay directly the favorite content creators at your will. That way, they can grow and continue delivering the content that delights you.',
rewardsPanelEmptyText1: 'Sadly, no tokens yet.',
rewardsPanelEmptyText2: '3 ways to fill your wallet:',
rewardsPanelEmptyText3: 'You can add funds.',
rewardsPanelEmptyText4: 'You can earn tokens from Brave Ads.',
rewardsPanelEmptyText5: 'Occasionally, you will also received token grants from Brave. So keep an eye out for the alert!',
rewardsPanelOffText1: 'Get Rewarded for Browsing!',
rewardsPanelOffText2: 'Earn tokens for your attention to ads and pay it forward to support content creators you value!',
rewardsPanelText1: 'Add, withdraw and manage funds at',
rewardsPanelText2: 'Brave wallet is managed by',
rewardsRestoreText1: 'Restore your Wallet',
rewardsRestoreText2: 'Enter the recovery key to restore your Brave wallet. Make sure that the current wallet doesn’t have any balance or is backed up safely. Restoring a wallet replaces the current wallet and you will loose any balance if you don’t back up its recovery key.',
rewardsRestoreText3: 'Enter your recovery key or',
rewardsSummary: 'Rewards Summary',
rewardsWhy: 'Why Brave Rewards…',
saveAsFile: 'Save as File',
seeAllItems: 'See all {{numItems}} items',
seeAllSites: 'See all {{numSites}} sites',
sendDonation: 'Send my donation',
sendTip: 'Send my Tip',
settings: 'Settings',
siteVisited: 'Site visited',
sites: 'sites',
tipOnLike: 'Tip on like',
tokenBalance: 'Token balance',
tokenGrant: 'Token Grant',
tokens: 'tokens',
type: 'Type',
verifiedPublisher: 'Brave Verified Publisher',
walletActivity: 'Wallet Activity/ Monthly Statement',
walletBalance: 'wallet balance',
welcome: 'Welcome!',
yourWallet: 'Your wallet'
};

export default locale;
Loading

0 comments on commit 92c8cec

Please sign in to comment.