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

Commit

Permalink
Merge pull request #2938 from gratipay/fix-layout
Browse files Browse the repository at this point in the history
fix layout
  • Loading branch information
Changaco committed Jan 6, 2015
2 parents a10525d + 41f732f commit d71e38b
Show file tree
Hide file tree
Showing 104 changed files with 2,600 additions and 2,848 deletions.
17 changes: 0 additions & 17 deletions 404.spt

This file was deleted.

50 changes: 9 additions & 41 deletions 410.spt
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
from aspen.http import status_strings
[---]
title = 'Closed' if 'username' in path else '410'
[---] text/html via jinja2
{% if 'username' in path %}

{% extends "templates/base.html" %}
{% block heading %}<h1>Closed</h1>{% endblock %}
{% block box %}

<div class="as-content">

<p style="margin: 3em 0;">The account owner has closed this account.</p>

{% block content %}
{% if 'username' in path %}
<p>The account owner has closed this account.</p>
{% if user.ANON %}
<h2>Are you the account owner?</h2>

<p>{% include "templates/sign-in-using.html" %} to reopen your account.</p>
<h2>Are you the account owner?</h2>
<p>{% include "templates/sign-in-using.html" %} to reopen your account.</p>
{% endif %}

</div>

<div class="nav level-1"><a href="/"><button>Home</button></a></div>

{% endblock %}

{% else %}
<html>
<head>
<title>410 Gone</title>
<style>
{{style}}
BODY {
margin: 0;
padding: 200px 0 0;
text-align: center;
font: normal 18pt/18pt Georgia, serif;
}
PRE {
text-align: left;
font: normal 10pt/12pt monospace;
margin: 50px 200px 0;
}
</style>
</head>
<body>
Gone, program!
</body>
</html>
<p>{{ status_strings[410] }}</p>
{% endif %}
{% endblock %}
22 changes: 17 additions & 5 deletions configure-aspen.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def _set_cookie(response, *args, **kw):
website.renderer_default = "jinja2"

website.renderer_factories['jinja2'].Renderer.global_context = {
'range': range,
'unicode': unicode,
'b64encode': base64.b64encode,
'enumerate': enumerate,
'len': len,
'float': float,
'type': type,
'len': len,
'range': range,
'str': str,
'b64encode': base64.b64encode
'type': type,
'unicode': unicode,
}


Expand Down Expand Up @@ -115,6 +115,18 @@ def f():
def add_stuff_to_context(request):
request.context['username'] = None

def filter_profile_subnav(user, participant, pages):
out = []
for foo, bar, show_them, show_others in pages:
if (user.participant == participant and show_them) \
or (user.participant is None and show_others) \
or (user.participant != participant and show_others) \
or user.ADMIN:
out.append((foo, bar, show_them, show_others))
return out
request.context['filter_profile_subnav'] = filter_profile_subnav


# Helpers for global call to action to support Gratipay itself.
user = request.context.get('user')
p = user.participant if user else None
Expand Down
40 changes: 5 additions & 35 deletions error.spt
Original file line number Diff line number Diff line change
@@ -1,49 +1,19 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from aspen import json
from aspen.http import status_strings

try:
from pygments.lexers import PythonTracebackLexer
from pygments.formatters import HtmlFormatter
from StringIO import StringIO
pygmentize = True
except ImportError:
from aspen.logging import log
import sys
exc = sys.exc_info()[1]
log("Cannot import pygments: " + str(exc))
pygmentize = False

[----------------------------------------]

style = ''
msg = status_strings.get(response.code, 'Sorry').title()
msg = status_strings.get(response.code, 'Unknown Error').title()
err = response.body
if website.show_tracebacks and pygmentize:
sio = StringIO()
formatter = HtmlFormatter()
tokens = PythonTracebackLexer().get_tokens(response.body)
formatter.format(tokens, sio)
sio.seek(0)
err = sio.read()
style = formatter.get_style_defs()

title = str(response.code)
[----------------------------------------] text/html
{% extends "templates/base.html" %}

{% block heading %}
<h1>{{ response.code }}</h1>
{% endblock %}
{% block box %}

<div class="as-content">
<p style="margin: 3em 0;">{{ msg|e }}</p>
<pre>{{err|e}}</pre>
</div>

<div class="nav level-1"><a href="/"><button>Home</button></a></div>

{% block content %}
<p>{{ msg|e }}</p>
<pre>{{ err|e }}</pre>
{% endblock %}
[----------------------------------------] application/json via json_dump
{ "error_code": response.code
Expand Down
2 changes: 2 additions & 0 deletions gratipay/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ def get_giving_for_profile(self):
amount
, tippee
, t.ctime
, t.mtime
, p.claimed_time
, p.username_lower
, p.number
Expand All @@ -1065,6 +1066,7 @@ def get_giving_for_profile(self):
amount
, tippee
, t.ctime
, t.mtime
, p.claimed_time
, e.platform
, e.user_name
Expand Down
5 changes: 3 additions & 2 deletions gratipay/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ def get_participant(request, restrict=True, resolve_unclaimed=True):
user = request.context['user']
slug = request.line.uri.path['username']
qs = request.line.uri.querystring
_ = request.context['_']

if restrict:
if user.ANON:
raise Response(403)
raise Response(403, _("You need to log in to access this page."))

from gratipay.models.participant import Participant # avoid circular import
participant = Participant.from_username(slug)
Expand All @@ -78,7 +79,7 @@ def get_participant(request, restrict=True, resolve_unclaimed=True):
if restrict:
if participant != user.participant:
if not user.ADMIN:
raise Response(403)
raise Response(403, _("You are not authorized to access this page."))

return participant

Expand Down
10 changes: 5 additions & 5 deletions gratipay/utils/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def n_get_text(tell_sentry, request, loc, s, p, n, *a, **kw):
return s2.format(*a, **kw)


def to_age(dt, loc):
return format_timedelta(dt - utcnow(), add_direction=True, locale=loc)
def to_age(dt, loc, **kw):
return format_timedelta(dt - utcnow(), locale=loc, **kw)


def regularize_locale(loc):
Expand Down Expand Up @@ -184,11 +184,11 @@ def add_helpers_to_context(tell_sentry, context, loc, request=None):
context['format_currency'] = lambda *a, **kw: format_currency_with_options(*a, locale=loc, **kw)
context['format_percent'] = lambda *a: format_percent(*a, locale=loc)
context['parse_decimal'] = lambda *a: parse_decimal(*a, locale=loc)
def _to_age(delta):
def _to_age(delta, **kw):
try:
return to_age(delta, loc)
return to_age(delta, loc, **kw)
except:
return to_age(delta, 'en')
return to_age(delta, 'en', **kw)
context['to_age'] = _to_age


Expand Down
4 changes: 2 additions & 2 deletions js/gratipay/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Gratipay.account.init = function() {
, success: function(data) {
Gratipay.notification("Your account type has been changed.", 'success');
if (data.number === 'plural') {
$("#members-button").removeClass("hidden");
$("li.members").removeClass("hidden");
} else {
$("#members-button").addClass("hidden");
$("li.members").addClass("hidden");
}
}
, error: function(r) {
Expand Down
8 changes: 8 additions & 0 deletions js/gratipay/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,20 @@ Gratipay.forms.jsEdit = function(params) {
else $editButton.prop('disabled', true);
$form.css('display', $form.data('display') || 'block');
$view.hide();

// prompt the user if they try leaving the page before saving
if (params.confirmBeforeUnload) {
$(window).on('beforeunload.js_edit', function(e) {
e.preventDefault();
});
}
});

function finish_editing() {
$editButton.show().prop('disabled', false);
$form.hide();
$view.show();
$(window).off('beforeunload.js_edit');
}
$root.find('button.cancel').click(finish_editing);

Expand Down
52 changes: 0 additions & 52 deletions js/gratipay/modal.js

This file was deleted.

5 changes: 4 additions & 1 deletion js/gratipay/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ Gratipay.profile.init = function() {

$('textarea').focus();

Gratipay.forms.jsEdit({root: $('.statement.js-edit')});
Gratipay.forms.jsEdit({
confirmBeforeUnload: true,
root: $('.statement.js-edit'),
});

$('.statement textarea').on('change keyup paste', function(){
var changed = $(this).val() !== $(this).data('original');
Expand Down
5 changes: 1 addition & 4 deletions js/gratipay/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ Gratipay.team = (function() {
var $team = $('#team');

var $indicator = $('<div class="loading-indicator"/>');
$indicator.appendTo($('#page'));
$indicator.appendTo($team);

$('#lookup-container form').submit(add);
$('#lookup-results').on('click', 'li', selectLookupResult);
$('#query').focus().keyup(lookup);

$team.css('opacity', 0);

jQuery.get("index.json").success(function(members) {
$team.css('opacity', 1);
$indicator.remove();
drawRows(members);
});
Expand Down
Loading

0 comments on commit d71e38b

Please sign in to comment.