Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/brave rewards ui rebase2 #1162

Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
04ba6a6
Migration for SiteBanner
yachtcaptain23 Aug 10, 2018
4dfadcc
Include social links and donation amounts
yachtcaptain23 Aug 27, 2018
6b20c03
Brave Rewards Integration
yachtcaptain23 Jul 31, 2018
59e7d13
Remove commented code
yachtcaptain23 Sep 11, 2018
0f69b44
Fix broken headers for editing contact info
yachtcaptain23 Sep 13, 2018
5316d07
Test to make sure instant donation button is only there for whitelisted
yachtcaptain23 Sep 17, 2018
ed1c97a
Test for saving a site banner
yachtcaptain23 Sep 17, 2018
6979ddb
Use the latest chromedriver-helper to resolve travis install
yachtcaptain23 Sep 18, 2018
9dc5778
Update the channels json
yachtcaptain23 Sep 18, 2018
367975a
Add BRAVE_REWARDS_EMAIL_WHITELIST to base.yml for docker users
nvonpentz Sep 18, 2018
160467f
Fix instant donation modal
nvonpentz Sep 18, 2018
2a503f5
Merge pull request #7 from nvonpentz/brave-rewards/add-envar
yachtcaptain23 Sep 18, 2018
8cdc4f6
Merge pull request #8 from nvonpentz/brave-rewards/fix/instant-donati…
yachtcaptain23 Sep 18, 2018
6439374
Use S3 bucket specified by ENV
yachtcaptain23 Sep 18, 2018
f583149
Use Rails.application.secrets
yachtcaptain23 Sep 18, 2018
ca34e5c
Don't lock the ts-loader and brave-ui packages
yachtcaptain23 Sep 18, 2018
a91ea90
Pending Tests: Cannot upload image
yachtcaptain23 Sep 18, 2018
d199dc3
Disable fade as this prevents new uploads for background image
yachtcaptain23 Sep 18, 2018
556b0e7
Merge pull request #9 from yachtcaptain23/feature/url_s3_brave_rewards
yachtcaptain23 Sep 18, 2018
f8dc6b9
Test image upload and disallow files too large
yachtcaptain23 Sep 18, 2018
203b088
Don't hard lock brave-ui
yachtcaptain23 Sep 18, 2018
56e5910
Fixes social links. Improved testing to use fixtures.
yachtcaptain23 Sep 19, 2018
db7c46e
Merge pull request #10 from yachtcaptain23/feature/security_fixes_ins…
yachtcaptain23 Sep 19, 2018
6f668e1
Indicate editable content
dlipeles Sep 19, 2018
1a576f5
Revert "Indicate editable content"
dlipeles Sep 19, 2018
43c9811
Indicate editable content
dlipeles Sep 19, 2018
00ba18c
Merge pull request #11 from dlipeles/indicate-editable-content
yachtcaptain23 Sep 19, 2018
799bd93
Don't include unused locale
yachtcaptain23 Sep 19, 2018
66c4706
Remove deadcode
yachtcaptain23 Sep 19, 2018
26e4a12
Fixes background image effect
dlipeles Sep 19, 2018
68d8fb0
Merge pull request #12 from dlipeles/patch/image-effect
yachtcaptain23 Sep 19, 2018
b44b4bd
Editing mode to preview
dlipeles Sep 20, 2018
c6047b5
Merge pull request #14 from dlipeles/patch/editing-to-preview
yachtcaptain23 Sep 21, 2018
fa51e61
Merge branch 'staging' into feature/brave_rewards_ui_rebase2
yachtcaptain23 Sep 29, 2018
a135e81
Initial commit, rewards banner overhaul
dlipeles Sep 26, 2018
a91d37e
Add intro, social links update, cleanup controller
dlipeles Sep 27, 2018
3573733
Numerical values only for donations, fix bottom padding for rewards b…
dlipeles Sep 27, 2018
a346724
Image cropping / Retina support for logo
dlipeles Sep 28, 2018
1a01c39
Retina mobile support, automatic cropping
dlipeles Sep 28, 2018
cf30298
Fix image issues for local files
yachtcaptain23 Sep 29, 2018
4509679
Merge pull request #17 from yachtcaptain23/site-banner-overhaul-rebase
yachtcaptain23 Sep 29, 2018
410ff60
Restores modal to original size
dlipeles Oct 1, 2018
8561b00
Continue checking against uploads of large image sizes
yachtcaptain23 Oct 1, 2018
841b573
Merge pull request #18 from dlipeles/feature/rewards-banner
yachtcaptain23 Oct 1, 2018
1cf4841
Include mini_magick
yachtcaptain23 Sep 20, 2018
6d32826
Convert to single image size
yachtcaptain23 Sep 21, 2018
326f9eb
Initial commit for site banner resizing logic
yachtcaptain23 Sep 24, 2018
6692337
Fix background saving by limiting file size
yachtcaptain23 Sep 25, 2018
e82e3dc
Add tests for padding logo. Increased number of resizing loops
yachtcaptain23 Sep 25, 2018
419028e
Test to make sure hashing is always consistent
yachtcaptain23 Sep 26, 2018
ed19b8a
Improved padding calculation for image conversion.
yachtcaptain23 Sep 27, 2018
07d7abf
Handle cases of file sizes being too big
yachtcaptain23 Sep 27, 2018
de107af
Document file size limits for the site banner
yachtcaptain23 Sep 27, 2018
bef7467
Change resolution for publisher's logo to 240x240
yachtcaptain23 Sep 27, 2018
1e20f8f
Ignore .DS_STORE file
yachtcaptain23 Oct 1, 2018
2ca0dc6
Support upscaled image size
yachtcaptain23 Oct 1, 2018
821b892
Merge pull request #15 from yachtcaptain23/feature/resize_images
yachtcaptain23 Oct 1, 2018
2ad4fb4
Fixes modal expansion bug
dlipeles Oct 1, 2018
a1c0a28
Merge pull request #19 from dlipeles/feature/rewards-banner
yachtcaptain23 Oct 1, 2018
c52a014
Fix file size restriction and logo image restrictions
yachtcaptain23 Oct 1, 2018
59c9344
Merge pull request #20 from yachtcaptain23/bugfix/brave_rewards_file_…
yachtcaptain23 Oct 1, 2018
fc4ae8d
Fix extension to use image/jpg instead of image/jpeg
yachtcaptain23 Oct 1, 2018
6cdd5c4
Remove debug statement
yachtcaptain23 Oct 1, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -19,6 +19,9 @@ gem "attr_encrypted", "~> 3.1.0"
# Integration with Matomo Piwik
gem 'autometal-piwik', :require => 'piwik', git: "https://github.com/matomo-org/piwik-ruby-api.git", branch: "master"

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

gem "bootstrap", "~> 4.1.1"

# browser details
Expand Down
19 changes: 18 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ GEM
encryptor (~> 3.0.0)
autoprefixer-rails (9.0.0)
execjs
aws-eventstream (1.0.1)
aws-partitions (1.104.0)
aws-sdk-core (3.27.0)
aws-eventstream (~> 1.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-kms (1.9.0)
aws-sdk-core (~> 3, >= 3.26.0)
aws-sigv4 (~> 1.0)
aws-sdk-s3 (1.19.0)
aws-sdk-core (~> 3, >= 3.26.0)
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 @@ -106,7 +121,7 @@ GEM
activesupport
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (1.2.0)
chromedriver-helper (2.0.1)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
chunky_png (1.3.10)
Expand Down Expand Up @@ -170,6 +185,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 @@ -457,6 +473,7 @@ DEPENDENCIES
api-pagination
attr_encrypted (~> 3.1.0)
autometal-piwik!
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],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we verify these params anywhere?

donation_amounts: donation_amounts,
default_donation: donation_amounts[1],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use some syntactic sugar and say something like donation_amounts.second. Up to you if you wanna change it

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an attachment size limit anywhere? otherwise someone can try to take up all our s3 space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in f8dc6b9c53d10642367ddfddb6c199fd0b3723a6. Test is in publishers/test/controllers/publishers/site_banners_controller.rb

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we resolve this TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
14 changes: 7 additions & 7 deletions app/controllers/publishers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ def update
end

respond_to do |format|
format.json {
if success
head :no_content
else
render(json: { errors: publisher.errors }, status: 400)
end
}
if success
format.json { head :no_content }
format.html { redirect_to home_publishers_path }
else
format.json { render(json: { errors: publisher.errors }, status: 400) }
format.html { render(status: 400) }
end
end
end

Expand Down
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