Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

New homepage plumbing #4606

Merged
merged 4 commits into from
Sep 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions defaults.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ BRAINTREE_SANDBOX_MODE=true
BRAINTREE_MERCHANT_ID=bk8h97tqzyqjhtfn
BRAINTREE_PUBLIC_KEY=xbty5dc9bgxpv5nb
BRAINTREE_PRIVATE_KEY=9d8646957c982bb0fb1aac764b582f7a
BRAINTREE_CLIENT_AUTHORIZATION=sandbox_cr9dyy9c_bk8h97tqzyqjhtfn

COINBASE_API_KEY=uETKVUrnPuXzVaVj
COINBASE_API_SECRET=32zAkQCcHHYkGGn29VkvEZvn21PM1lgO
Expand Down
2 changes: 1 addition & 1 deletion gratipay/utils/http_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def concat_files(files, root):
catted.append('/*' + filepath.center(68) + '*/\n')
catted.append('/' + ('*'*70) + '/' + '\n\n')
content = open(os.path.join(root, filepath)).read()
content = content.decode('ascii')
content = content.decode('utf8')
catted.append(content + '\n')
return "".join(catted)

Expand Down
3 changes: 2 additions & 1 deletion gratipay/wireup.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def compile_assets(website):
headers[b'HTTP_HOST'] = str(url.netloc)
content = client.GET(urlpath, **headers).body
tmpfd, tmpfpath = mkstemp(dir='.')
os.write(tmpfd, content)
os.write(tmpfd, content.encode('utf8'))
os.close(tmpfd)
os.rename(tmpfpath, filepath)
atexit.register(lambda: clean_assets(website.www_root))
Expand Down Expand Up @@ -351,6 +351,7 @@ def env():
BRAINTREE_MERCHANT_ID = unicode,
BRAINTREE_PUBLIC_KEY = unicode,
BRAINTREE_PRIVATE_KEY = unicode,
BRAINTREE_CLIENT_AUTHORIZATION = unicode,
GITHUB_CLIENT_ID = unicode,
GITHUB_CLIENT_SECRET = unicode,
GITHUB_CALLBACK = unicode,
Expand Down
11 changes: 9 additions & 2 deletions js/gratipay/homepage.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
Gratipay.homepage = {}

Gratipay.homepage.initForm = function () {
Gratipay.homepage.initForm = function(clientAuthorization) {
$form = $('#homepage #content form');

$submit= $form.find('button[type=submit]');
$submit.click(Gratipay.homepage.submitForm);

$chooseEcosystem = $form.find('.ecosystem-chooser button');
$chooseEcosystem.click(function(e) {
e.preventDefault();
Gratipay.notification('Not implemented.', 'error');
});

$promote = $form.find('.promotion-gate button');
$promote.click(Gratipay.homepage.openPromote);

braintree.dropin.create({
authorization: 'sandbox_cr9dyy9c_bk8h97tqzyqjhtfn',
authorization: clientAuthorization,
container: '#braintree-container'
}, function (createErr, instance) {
$submit.click(function () {
Expand Down
6 changes: 6 additions & 0 deletions js/vendor/braintree.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/py/test_support_gratipay.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TestSupportGratipay(Harness):

def shown(self, to=None):
return 'of active users also' in self.client.GET('/', auth_as=to).body
return 'of active users also' in self.client.GET('/about/', auth_as=to).body

def test_not_shown_to_anon(self):
assert not self.shown()
Expand Down Expand Up @@ -37,7 +37,7 @@ def test_not_shown_to_giver_to_Gratipay(self):

def check_button(self, lang, decimal, currency):
self.test_shown_when_on_the_fence()
body = self.client.GET( '/'
body = self.client.GET( '/about/'
, auth_as='alice'
, HTTP_ACCEPT_LANGUAGE=str(lang)
).body.decode('utf8')
Expand Down
4 changes: 2 additions & 2 deletions tests/ttw/test_homepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def test_loads_for_anon(self):
assert self.css('#banner h1').html == 'Pay for open source.'
assert self.css('#header .sign-in button').html.strip()[:17] == 'Sign in / Sign up'

def test_loads_for_authed(self):
def test_redirects_for_authed_exclamation_point(self):
self.make_participant('alice', claimed_time='now')
self.sign_in('alice')
self.reload()
assert self.css('#banner h1').html == 'Pay for open source.'
assert self.css('#banner h1').html == 'Browse'
assert self.css('.you-are a').html.strip()[:6] == '~alice'
1 change: 1 addition & 0 deletions www/assets/vendors.js.spt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ files = [
'tipr.min.js',
'bootstrap-dropdown.js',
'jquery.mousewheel.min.js',
'braintree.min.js',
]

js = http_caching.concat_files(files, vendor_root)
Expand Down
14 changes: 10 additions & 4 deletions www/index.spt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
suppress_sidebar = True
page_id = "homepage"
banner = "Pay for Open Source"

if not user.ANON:
website.redirect('/browse/projects')
[---] text/html
{% from "templates/nav-tabs.html" import nav_tabs with context %}
{% extends "templates/base.html" %}
Expand All @@ -22,8 +25,11 @@ banner = "Pay for Open Source"
{% endblock %}

{% block scripts %}
<script src="https://js.braintreegateway.com/web/dropin/1.7.0/js/dropin.min.js"></script>
<script>$(document).ready(Gratipay.homepage.initForm);</script>
<script>
$(document).ready(function() {
Gratipay.homepage.initForm('{{ website.env.braintree_client_authorization }}');
});
</script>
{{ super() }}
{% endblock %}

Expand Down Expand Up @@ -109,10 +115,10 @@ banner = "Pay for Open Source"
{{ _('Which do you value most?{br}(JavaScript, Python, etc.)', br='<br>'|safe) }}
</p>

<div class="important-button">
<div class="important-button ecosystem-chooser">
<button class="large">{{ _('Choose an Ecosystem') }}</button>
</div>
<div class="preferences"></div>
<div class="ecosystems"></div>


<h2>{{ _('Promotion') }}</h2>
Expand Down