From c2d82755f5378dfa2fb4e369cbdc59b26bd8f8dc Mon Sep 17 00:00:00 2001 From: mattbk Date: Fri, 2 Dec 2016 16:19:51 -0600 Subject: [PATCH 01/23] Get search teams by name to barely work. --- www/search.spt | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/www/search.spt b/www/search.spt index b511b243ed..9d06d20930 100644 --- a/www/search.spt +++ b/www/search.spt @@ -38,6 +38,18 @@ if query: LIMIT 10 """, locals()) + if action in (None, 'search_teams'): + results['teams'] = website.db.all(""" + SELECT name, product_or_service, similarity(name, %(q)s) AS rank + FROM teams + WHERE name %% %(q)s + AND ctime IS NOT NULL + AND NOT is_closed + AND is_approved + ORDER BY rank DESC, name + LIMIT 10 + """, locals()) + if user.ADMIN: if action in (None, 'search_emails'): results['emails'] = website.db.all(""" @@ -116,6 +128,7 @@ if query: {% set usernames = results.get('usernames') %} {% set statements = results.get('statements') %} {% set emails = results.get('emails') %} + {% set teams = results.get('teams') %} {% if usernames %}

{{ ngettext("Found a matching username", @@ -149,6 +162,22 @@ if query: {% endif %} +{% if teams %} +

{{ ngettext("Found a matching team name", + "Found matching team names", + len(teams)) }}

+
+ {% for result in teams %} + + + + {{ result.name }} + + + {% endfor %} +
+ {% endif %} + {% if statements %}

{{ ngettext("Found a matching user statement", @@ -170,7 +199,7 @@ if query:

{% endif %} - {% if query and not (usernames or statements or emails) %} + {% if query and not (usernames or statements or emails or teams) %}

{{ _("Sorry, we didn't find anything matching your query.") }}

{% endif %} From cca07466ae41c51e04fa242685ae4726f39b4506 Mon Sep 17 00:00:00 2001 From: mattbk Date: Fri, 2 Dec 2016 17:31:33 -0600 Subject: [PATCH 02/23] Add first 100 chars of product statement to search results. --- www/search.spt | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/www/search.spt b/www/search.spt index 9d06d20930..25e27631a1 100644 --- a/www/search.spt +++ b/www/search.spt @@ -40,7 +40,7 @@ if query: if action in (None, 'search_teams'): results['teams'] = website.db.all(""" - SELECT name, product_or_service, similarity(name, %(q)s) AS rank + SELECT name, similarity(name, %(q)s) AS rank FROM teams WHERE name %% %(q)s AND ctime IS NOT NULL @@ -50,6 +50,18 @@ if query: LIMIT 10 """, locals()) + if action in (None, 'search_products'): + results['products'] = website.db.all(""" + SELECT name, product_or_service, similarity(name, %(q)s) AS rank + FROM teams + WHERE product_or_service %% %(q)s + AND ctime IS NOT NULL + AND NOT is_closed + AND is_approved + ORDER BY rank DESC, name + LIMIT 10 + """, locals()) + if user.ADMIN: if action in (None, 'search_emails'): results['emails'] = website.db.all(""" @@ -129,6 +141,7 @@ if query: {% set statements = results.get('statements') %} {% set emails = results.get('emails') %} {% set teams = results.get('teams') %} + {% set products = results.get('products') %} {% if usernames %}

{{ ngettext("Found a matching username", @@ -199,7 +212,28 @@ if query: {% endif %} - {% if query and not (usernames or statements or emails or teams) %} + {% if products %} +
+

{{ ngettext("Found a matching team", + "Found matching teams", + len(products)) }}

+ {% for result in products %} +
+
+ {{ result.name }} +
+ {{result.product_or_service[0:100]}} + {% if len(result.product_or_service) > 100 %} + ... + {% endif %} +
+
+
+ {% endfor %} +
+ {% endif %} + + {% if query and not (usernames or statements or emails or teams or products) %}

{{ _("Sorry, we didn't find anything matching your query.") }}

{% endif %} From f9d15ae1396583219835f2445c72c69302421a7c Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 2 Dec 2016 22:26:36 -0600 Subject: [PATCH 03/23] Improve team display. --- www/search.spt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/www/search.spt b/www/search.spt index 25e27631a1..e738746c1f 100644 --- a/www/search.spt +++ b/www/search.spt @@ -1,5 +1,7 @@ -from gratipay.utils import markdown +from gratipay.utils import markdown, get_team from gratipay.utils.i18n import LANGUAGES_2, SEARCH_CONFS, strip_accents +from gratipay.models.team import Team +from aspen import Response [---] @@ -52,7 +54,7 @@ if query: if action in (None, 'search_products'): results['products'] = website.db.all(""" - SELECT name, product_or_service, similarity(name, %(q)s) AS rank + SELECT name, slug, product_or_service, similarity(name, %(q)s) AS rank FROM teams WHERE product_or_service %% %(q)s AND ctime IS NOT NULL @@ -219,6 +221,7 @@ if query: len(products)) }}

{% for result in products %}
+
{{ result.name }}
From 62ed189484015ed67afd58cf68b5c8342112e147 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 3 Dec 2016 21:36:54 -0600 Subject: [PATCH 04/23] Add table classes like front page, but doesn't display right. --- www/search.spt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/www/search.spt b/www/search.spt index e738746c1f..b217d00864 100644 --- a/www/search.spt +++ b/www/search.spt @@ -219,20 +219,22 @@ if query:

{{ ngettext("Found a matching team", "Found matching teams", len(products)) }}

+ {% for result in products %} -
+
+ + {% endfor %} +
-
- {{ result.name }} + {{ result.name }}
{{result.product_or_service[0:100]}} {% if len(result.product_or_service) > 100 %} ... {% endif %}
-
- +
{% endif %} From b6455ee793623c41b0252ea64328d0e9980e88a6 Mon Sep 17 00:00:00 2001 From: mattbk Date: Mon, 5 Dec 2016 14:51:57 -0600 Subject: [PATCH 05/23] Tweaks. --- www/search.spt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/search.spt b/www/search.spt index b217d00864..a482d38af2 100644 --- a/www/search.spt +++ b/www/search.spt @@ -54,7 +54,7 @@ if query: if action in (None, 'search_products'): results['products'] = website.db.all(""" - SELECT name, slug, product_or_service, similarity(name, %(q)s) AS rank + SELECT name, slug, product_or_service, similarity(product_or_service, %(q)s) AS rank FROM teams WHERE product_or_service %% %(q)s AND ctime IS NOT NULL @@ -226,7 +226,7 @@ if query: {{ result.name }}
- {{result.product_or_service[0:100]}} + {{markdown.render(result.product_or_service[0:100])}} {% if len(result.product_or_service) > 100 %} ... {% endif %} From e1125f910f51680e7d747f5335145b563b35827b Mon Sep 17 00:00:00 2001 From: mattbk Date: Mon, 5 Dec 2016 17:16:44 -0600 Subject: [PATCH 06/23] Fool around with variables. --- www/search.spt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/search.spt b/www/search.spt index a482d38af2..093d4cf33f 100644 --- a/www/search.spt +++ b/www/search.spt @@ -53,6 +53,7 @@ if query: """, locals()) if action in (None, 'search_products'): + #q = "%%"+(q)+"%%" results['products'] = website.db.all(""" SELECT name, slug, product_or_service, similarity(product_or_service, %(q)s) AS rank FROM teams @@ -144,7 +145,8 @@ if query: {% set emails = results.get('emails') %} {% set teams = results.get('teams') %} {% set products = results.get('products') %} - + {{ q }} + {{ results }} {% if usernames %}

{{ ngettext("Found a matching username", "Found matching usernames", From 2508ab134586218b53a741246dd4526522436089 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 7 Dec 2016 19:45:12 -0600 Subject: [PATCH 07/23] Put the right syntax together. --- www/search.spt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/www/search.spt b/www/search.spt index 093d4cf33f..eb11b1b2f6 100644 --- a/www/search.spt +++ b/www/search.spt @@ -53,12 +53,11 @@ if query: """, locals()) if action in (None, 'search_products'): - #q = "%%"+(q)+"%%" + q = "%%"+(q)+"%%" #search for the string everywhere results['products'] = website.db.all(""" SELECT name, slug, product_or_service, similarity(product_or_service, %(q)s) AS rank FROM teams - WHERE product_or_service %% %(q)s - AND ctime IS NOT NULL + WHERE product_or_service ILIKE %(q)s #http://stackoverflow.com/a/8218451/2152245 AND NOT is_closed AND is_approved ORDER BY rank DESC, name @@ -145,8 +144,7 @@ if query: {% set emails = results.get('emails') %} {% set teams = results.get('teams') %} {% set products = results.get('products') %} - {{ q }} - {{ results }} + {% if usernames %}

{{ ngettext("Found a matching username", "Found matching usernames", From 955f69d0864cd64819ce1744f841c32b8bde83e8 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 7 Dec 2016 19:48:54 -0600 Subject: [PATCH 08/23] Fix comment. --- www/search.spt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/search.spt b/www/search.spt index eb11b1b2f6..0afc8f0cff 100644 --- a/www/search.spt +++ b/www/search.spt @@ -54,10 +54,11 @@ if query: if action in (None, 'search_products'): q = "%%"+(q)+"%%" #search for the string everywhere + #http://stackoverflow.com/a/8218451/2152245 for ILIKE reasoning results['products'] = website.db.all(""" SELECT name, slug, product_or_service, similarity(product_or_service, %(q)s) AS rank FROM teams - WHERE product_or_service ILIKE %(q)s #http://stackoverflow.com/a/8218451/2152245 + WHERE product_or_service ILIKE %(q)s AND NOT is_closed AND is_approved ORDER BY rank DESC, name From 980e19c04d1a20cba91b680095531a1e6baed9ae Mon Sep 17 00:00:00 2001 From: mattbk Date: Thu, 8 Dec 2016 09:49:52 -0600 Subject: [PATCH 09/23] Smooth out team display. --- www/search.spt | 112 +++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 70 deletions(-) diff --git a/www/search.spt b/www/search.spt index 0afc8f0cff..94f1e0ea9f 100644 --- a/www/search.spt +++ b/www/search.spt @@ -41,24 +41,13 @@ if query: """, locals()) if action in (None, 'search_teams'): - results['teams'] = website.db.all(""" - SELECT name, similarity(name, %(q)s) AS rank - FROM teams - WHERE name %% %(q)s - AND ctime IS NOT NULL - AND NOT is_closed - AND is_approved - ORDER BY rank DESC, name - LIMIT 10 - """, locals()) - - if action in (None, 'search_products'): q = "%%"+(q)+"%%" #search for the string everywhere - #http://stackoverflow.com/a/8218451/2152245 for ILIKE reasoning - results['products'] = website.db.all(""" + # http://stackoverflow.com/a/8218451/2152245 for ILIKE reasoning + results['teams'] = website.db.all(""" SELECT name, slug, product_or_service, similarity(product_or_service, %(q)s) AS rank FROM teams - WHERE product_or_service ILIKE %(q)s + WHERE (product_or_service ILIKE %(q)s + OR name %% %(q)s) AND NOT is_closed AND is_approved ORDER BY rank DESC, name @@ -144,7 +133,30 @@ if query: {% set statements = results.get('statements') %} {% set emails = results.get('emails') %} {% set teams = results.get('teams') %} - {% set products = results.get('products') %} + + {% if teams %} +
+

{{ ngettext("Found a matching team", + "Found matching teams", + len(teams)) }}

+ + {% for result in teams %} + + + + {% endfor %} +
+ + {{ result.name }} +
+ {{markdown.render(result.product_or_service[0:100])}} + {% if len(result.product_or_service) > 100 %} + ... + {% endif %} +
+
+
+ {% endif %} {% if usernames %}

{{ ngettext("Found a matching username", @@ -162,38 +174,6 @@ if query:

{% endif %} - {% if emails %} -

{{ ngettext("Found a matching email address", - "Found matching email addresses", - len(usernames)) }}

-
- {% for result in emails %} - - - - {{ result.username }} - - - {% endfor %} -
- {% endif %} - -{% if teams %} -

{{ ngettext("Found a matching team name", - "Found matching team names", - len(teams)) }}

-
- {% for result in teams %} - - - - {{ result.name }} - - - {% endfor %} -
- {% endif %} - {% if statements %}

{{ ngettext("Found a matching user statement", @@ -215,31 +195,23 @@ if query:

{% endif %} - {% if products %} -
-

{{ ngettext("Found a matching team", - "Found matching teams", - len(products)) }}

- - {% for result in products %} - - - + {% if emails %} +

{{ ngettext("Found a matching email address", + "Found matching email addresses", + len(usernames)) }}

+
+ {% for result in emails %} + + + + {{ result.username }} + + {% endfor %} -
- - {{ result.name }} -
- {{markdown.render(result.product_or_service[0:100])}} - {% if len(result.product_or_service) > 100 %} - ... - {% endif %} -
-
-
+ {% endif %} - {% if query and not (usernames or statements or emails or teams or products) %} + {% if query and not (usernames or statements or emails or teams) %}

{{ _("Sorry, we didn't find anything matching your query.") }}

{% endif %} From 0379dc0c1fa782a7350ac7fe227567b5bda98a65 Mon Sep 17 00:00:00 2001 From: mattbk Date: Thu, 8 Dec 2016 09:52:38 -0600 Subject: [PATCH 10/23] Replace team with project where possible. --- www/search.spt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/www/search.spt b/www/search.spt index 94f1e0ea9f..9d504e2b68 100644 --- a/www/search.spt +++ b/www/search.spt @@ -40,10 +40,10 @@ if query: LIMIT 10 """, locals()) - if action in (None, 'search_teams'): + if action in (None, 'search_projects'): q = "%%"+(q)+"%%" #search for the string everywhere # http://stackoverflow.com/a/8218451/2152245 for ILIKE reasoning - results['teams'] = website.db.all(""" + results['projects'] = website.db.all(""" SELECT name, slug, product_or_service, similarity(product_or_service, %(q)s) AS rank FROM teams WHERE (product_or_service ILIKE %(q)s @@ -132,17 +132,17 @@ if query: {% set usernames = results.get('usernames') %} {% set statements = results.get('statements') %} {% set emails = results.get('emails') %} - {% set teams = results.get('teams') %} + {% set projects = results.get('projects') %} - {% if teams %} + {% if projects %}
-

{{ ngettext("Found a matching team", - "Found matching teams", - len(teams)) }}

+

{{ ngettext("Found a matching project", + "Found matching projects", + len(projects)) }}

- {% for result in teams %} + {% for result in projects %} - From 888b96b4ac0c03b03fe4281fdaa9c6e5122bdc61 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 14 Dec 2016 12:28:43 -0500 Subject: [PATCH 12/23] Only populate results['usernames'] once --- www/search.spt | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/www/search.spt b/www/search.spt index 31a67b2ce2..0dc945d5d4 100644 --- a/www/search.spt +++ b/www/search.spt @@ -15,20 +15,20 @@ if query: title = _("Results for: ") + query q = strip_accents(query) - if action in (None, 'search_usernames'): - results['usernames'] = website.db.all(""" - SELECT username, avatar_url, similarity(username, %(q)s) AS rank - FROM participants - WHERE username %% %(q)s - AND claimed_time IS NOT NULL - """ - +("" if user.ADMIN else " AND is_searchable") - +""" AND NOT is_closed - ORDER BY rank DESC, username - LIMIT 10 - """, locals()) - - if user.ADMIN: + if not user.ADMIN: + if action in (None, 'search_usernames'): + results['usernames'] = website.db.all(""" + SELECT username, avatar_url, similarity(username, %(q)s) AS rank + FROM participants + WHERE username %% %(q)s + AND claimed_time IS NOT NULL + AND is_searchable + AND NOT is_closed + ORDER BY rank DESC, username + LIMIT 10 + """, locals()) + + else: if action in (None, 'search_usernames'): results['usernames'] = website.db.all(""" SELECT username, avatar_url, similarity(username, %(q)s) AS rank From 52c02fb9e2217b854e31564c47fa5f523f74a784 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 14 Dec 2016 12:30:19 -0500 Subject: [PATCH 13/23] Consolidate ADMIN search --- www/search.spt | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/www/search.spt b/www/search.spt index 0dc945d5d4..844b9e85c6 100644 --- a/www/search.spt +++ b/www/search.spt @@ -39,6 +39,15 @@ if query: ORDER BY rank DESC, username LIMIT 10 """, locals()) + if action in (None, 'search_emails'): + results['emails'] = website.db.all(""" + SELECT username, avatar_url, similarity(email_address, %(q)s) AS rank + FROM participants + WHERE email_address %% %(q)s + AND claimed_time IS NOT NULL + ORDER BY rank DESC, username + LIMIT 10 + """, locals()) if action in (None, 'search_projects'): q = "%%"+(q)+"%%" #search for the string everywhere @@ -54,17 +63,6 @@ if query: LIMIT 10 """, locals()) - if user.ADMIN: - if action in (None, 'search_emails'): - results['emails'] = website.db.all(""" - SELECT username, avatar_url, similarity(email_address, %(q)s) AS rank - FROM participants - WHERE email_address %% %(q)s - AND claimed_time IS NOT NULL - ORDER BY rank DESC, username - LIMIT 10 - """, locals()) - if action in (None, 'search_statements'): langs = tuple(l for l in request.accept_langs if l in LANGUAGES_2) search_confs = list(set(SEARCH_CONFS.get(lang, 'simple') for lang in langs)) From c325f48287dd45ed3df06a51d458c5b073759753 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 14 Dec 2016 12:55:20 -0500 Subject: [PATCH 14/23] Drop back to just searching project names And style the results like usernames --- www/search.spt | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/www/search.spt b/www/search.spt index 844b9e85c6..195039fffb 100644 --- a/www/search.spt +++ b/www/search.spt @@ -50,18 +50,16 @@ if query: """, locals()) if action in (None, 'search_projects'): - q = "%%"+(q)+"%%" #search for the string everywhere - # http://stackoverflow.com/a/8218451/2152245 for ILIKE reasoning results['projects'] = website.db.all(""" - SELECT name, slug, product_or_service, similarity(product_or_service, %(q)s) AS rank - FROM teams - WHERE (product_or_service ILIKE %(q)s - OR name %% %(q)s) + SELECT project FROM ( + SELECT t.*::teams AS project, similarity(name, %(q)s) AS rank + FROM teams t + WHERE name %% %(q)s AND NOT is_closed AND is_approved ORDER BY rank DESC, name LIMIT 10 - """, locals()) + ) _""", locals()) if action in (None, 'search_statements'): langs = tuple(l for l in request.accept_langs if l in LANGUAGES_2) @@ -137,23 +135,16 @@ if query:

{{ ngettext("Found a matching project", "Found matching projects", len(projects)) }}

-
+ {{ result.name }}
@@ -211,7 +211,7 @@ if query: {% endif %} - {% if query and not (usernames or statements or emails or teams) %} + {% if query and not (usernames or statements or emails or projects) %}

{{ _("Sorry, we didn't find anything matching your query.") }}

{% endif %} From 8e2cd048a4765a76ec14b413eb15ed8063ba4566 Mon Sep 17 00:00:00 2001 From: mattbk Date: Thu, 8 Dec 2016 10:13:29 -0600 Subject: [PATCH 11/23] Clean up string truncation. --- www/search.spt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/www/search.spt b/www/search.spt index 9d504e2b68..31a67b2ce2 100644 --- a/www/search.spt +++ b/www/search.spt @@ -146,9 +146,10 @@ if query: {{ result.name }}
- {{markdown.render(result.product_or_service[0:100])}} {% if len(result.product_or_service) > 100 %} - ... + {{markdown.render(result.product_or_service[0:100]+"...")}} + {% else %} + {{markdown.render(result.product_or_service[0:100])}} {% endif %}
+
{% for result in projects %} -
- - + + + + {{ result.name }} + + {% endfor %} -
- - {{ result.name }} -
- {% if len(result.product_or_service) > 100 %} - {{markdown.render(result.product_or_service[0:100]+"...")}} - {% else %} - {{markdown.render(result.product_or_service[0:100])}} - {% endif %} -
-
+
{% endif %} From 25cdf133f84e88b6a61817507de345cab78e4b08 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 14 Dec 2016 13:02:13 -0500 Subject: [PATCH 15/23] Allow admins to search unapproved projects --- www/search.spt | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/www/search.spt b/www/search.spt index 195039fffb..1d3039fe4a 100644 --- a/www/search.spt +++ b/www/search.spt @@ -27,6 +27,17 @@ if query: ORDER BY rank DESC, username LIMIT 10 """, locals()) + if action in (None, 'search_projects'): + results['projects'] = website.db.all(""" + SELECT project FROM ( + SELECT t.*::teams AS project, similarity(name, %(q)s) AS rank + FROM teams t + WHERE name %% %(q)s + AND NOT is_closed + AND is_approved + ORDER BY rank DESC, name + LIMIT 10 + ) _""", locals()) else: if action in (None, 'search_usernames'): @@ -48,18 +59,16 @@ if query: ORDER BY rank DESC, username LIMIT 10 """, locals()) - - if action in (None, 'search_projects'): - results['projects'] = website.db.all(""" - SELECT project FROM ( - SELECT t.*::teams AS project, similarity(name, %(q)s) AS rank - FROM teams t - WHERE name %% %(q)s - AND NOT is_closed - AND is_approved - ORDER BY rank DESC, name - LIMIT 10 - ) _""", locals()) + if action in (None, 'search_projects'): + results['projects'] = website.db.all(""" + SELECT project FROM ( + SELECT t.*::teams AS project, similarity(name, %(q)s) AS rank + FROM teams t + WHERE name %% %(q)s + AND NOT is_closed + ORDER BY rank DESC, name + LIMIT 10 + ) _""", locals()) if action in (None, 'search_statements'): langs = tuple(l for l in request.accept_langs if l in LANGUAGES_2) From 8fba7b637a913bb91cce23b614002ce04524557b Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 14 Dec 2016 13:03:54 -0500 Subject: [PATCH 16/23] Preserve parallelism with existing search sections --- www/search.spt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/search.spt b/www/search.spt index 1d3039fe4a..3841080c06 100644 --- a/www/search.spt +++ b/www/search.spt @@ -141,8 +141,8 @@ if query: {% if projects %}
-

{{ ngettext("Found a matching project", - "Found matching projects", +

{{ ngettext("Found a matching project name", + "Found matching project names", len(projects)) }}

{% for result in projects %} From e5cae9ad8586873e3a4a66d7b784542cf322a220 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 14 Dec 2016 13:04:52 -0500 Subject: [PATCH 17/23] Remove now-unnecessary imports --- www/search.spt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/www/search.spt b/www/search.spt index 3841080c06..2ebcb32d69 100644 --- a/www/search.spt +++ b/www/search.spt @@ -1,7 +1,5 @@ -from gratipay.utils import markdown, get_team +from gratipay.utils import markdown from gratipay.utils.i18n import LANGUAGES_2, SEARCH_CONFS, strip_accents -from gratipay.models.team import Team -from aspen import Response [---] From fbbde03f98b065751183a91696d7acf70ef6e241 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 15 Dec 2016 11:26:28 -0500 Subject: [PATCH 18/23] Remove "jump to elsewhere" We added this way back in our first pull request, #2. As it suggests there, this was in lieu of a real search feature. I think we should remove it because: - We no longer focus on individuals through their social network accounts - We have a real search feature - This clutters up the search page - It's sugar for going to /on/twitter/foo/ directly; you can still get there --- js/gratipay/jump.js | 10 ---------- scss/pages/search.scss | 4 ---- www/search.spt | 15 --------------- 3 files changed, 29 deletions(-) delete mode 100644 js/gratipay/jump.js diff --git a/js/gratipay/jump.js b/js/gratipay/jump.js deleted file mode 100644 index 73ec2c78ba..0000000000 --- a/js/gratipay/jump.js +++ /dev/null @@ -1,10 +0,0 @@ -$(document).ready(function() { - $('.jump-box').submit(function (e) { - e.preventDefault(); - e.stopPropagation(); - - var platform = Gratipay.trim($('.jump-box select').val()), - val = Gratipay.trim($('.jump-box input').val()); - if (val) window.location = '/on/' + platform + '/' + val + '/'; - }); -}); diff --git a/scss/pages/search.scss b/scss/pages/search.scss index 889accc6a7..40d9a40be8 100644 --- a/scss/pages/search.scss +++ b/scss/pages/search.scss @@ -29,7 +29,3 @@ padding: 0.5em 0 0 1em; } } - -.jump-box { - margin-top: 40px; -} diff --git a/www/search.spt b/www/search.spt index 2ebcb32d69..236c6adf93 100644 --- a/www/search.spt +++ b/www/search.spt @@ -113,21 +113,6 @@ if query: value="{{ query or '' }}" autofocus /> - -
-

{{ _("Looking for a specific user of a social network?") }}

-

{{ _("{0} on {1}", - """"""|safe, - """"""|safe) }} -

-
- {% endblock %} {% block content %} From d15bab19973857d98be1f1f7815c0be775ebbfee Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 15 Dec 2016 11:44:04 -0500 Subject: [PATCH 19/23] Factor out homepage listing styles --- scss/components/listing.scss | 102 +++++++++++++++++++++++++++++++++++ scss/pages/homepage.scss | 102 ----------------------------------- www/assets/gratipay.css.spt | 1 + www/index.html.spt | 4 +- 4 files changed, 105 insertions(+), 104 deletions(-) create mode 100644 scss/components/listing.scss diff --git a/scss/components/listing.scss b/scss/components/listing.scss new file mode 100644 index 0000000000..b27a75dde4 --- /dev/null +++ b/scss/components/listing.scss @@ -0,0 +1,102 @@ +table.listing { + width: 100%; + + tr:first-child td { border-top: 0; } + tr:last-child td { border-bottom: 0; } + + td.item { + position: relative; + color: $medium-gray; + border: 1px solid $light-brown; + border-style: solid none; + + a { + color: $medium-gray; + position: relative; + z-index: 2; + } + a:hover { + background: none !important; + color: $green !important; + } + img { + width: 48px; + height: 48px; + position: absolute; + top: 8px; + left: 0; + } + .name { + display: block; + color: $black; + font: bold 20px/24px $Ideal; + position: absolute; + z-index: 1; + top: 0; + left: 56px; + padding: 12px 0 0; + width: 100%; + height: 100%; + } + .details { + font: normal 12px/15px $Ideal; + min-height: 64px; + padding: 38px 144px 0 56px; + .owner a { + color: $medium-gray; + position: relative; + z-index: 2; + } + span { + white-space: nowrap; + } + .status-icon { + font-size: 12px; + padding: 0; + } + } + .numbers { + position: absolute; + bottom: 8px; + right: 0; + z-index: 0; + font-size: 11px; + line-height: 13px; + th { + text-align: right; + border-bottom: 1px solid transparent; + } + .label { + text-align: left; + } + td { + text-align: right; + padding: 1px 0 0 12px; + &:first-child { + padding-left: 0; + } + } + th, .label { + color: $medium-gray; + visibility: hidden; + } + } + + &:hover { + color: $black; + .status a { + color: $black; + } + .owner a { + color: $black; + } + th, .label { + visibility: visible; + } + th { + border-bottom: 1px solid $light-brown; + } + } + } +} + diff --git a/scss/pages/homepage.scss b/scss/pages/homepage.scss index ed9ae1da9c..f8010fdff8 100644 --- a/scss/pages/homepage.scss +++ b/scss/pages/homepage.scss @@ -11,106 +11,4 @@ top: 0; right: 0; } - - table.teams { - width: 100%; - - tr:first-child td { border-top: 0; } - tr:last-child td { border-bottom: 0; } - - td.team { - position: relative; - color: $medium-gray; - border: 1px solid $light-brown; - border-style: solid none; - - a { - color: $medium-gray; - position: relative; - z-index: 2; - } - a:hover { - background: none !important; - color: $green !important; - } - img { - width: 48px; - height: 48px; - position: absolute; - top: 8px; - left: 0; - } - .name { - display: block; - color: $black; - font: bold 20px/24px $Ideal; - position: absolute; - z-index: 1; - top: 0; - left: 56px; - padding: 12px 0 0; - width: 100%; - height: 100%; - } - .details { - font: normal 12px/15px $Ideal; - min-height: 64px; - padding: 38px 144px 0 56px; - .owner a { - color: $medium-gray; - position: relative; - z-index: 2; - } - span { - white-space: nowrap; - } - .status-icon { - font-size: 12px; - padding: 0; - } - } - .numbers { - position: absolute; - bottom: 8px; - right: 0; - z-index: 0; - font-size: 11px; - line-height: 13px; - th { - text-align: right; - border-bottom: 1px solid transparent; - } - .label { - text-align: left; - } - td { - text-align: right; - padding: 1px 0 0 12px; - &:first-child { - padding-left: 0; - } - } - th, .label { - color: $medium-gray; - visibility: hidden; - } - } - - &:hover { - color: $black; - .status a { - color: $black; - } - .owner a { - color: $black; - } - th, .label { - visibility: visible; - } - th { - border-bottom: 1px solid $light-brown; - } - } - } - } } diff --git a/www/assets/gratipay.css.spt b/www/assets/gratipay.css.spt index d0d63664a2..26b96b2531 100644 --- a/www/assets/gratipay.css.spt +++ b/www/assets/gratipay.css.spt @@ -34,6 +34,7 @@ @import "scss/components/emails"; @import "scss/components/js-edit"; @import "scss/components/linear_gradient"; +@import "scss/components/listing"; @import "scss/components/loading-indicators"; @import "scss/components/long-form"; @import "scss/components/memberships"; diff --git a/www/index.html.spt b/www/index.html.spt index a82af8d7d5..3400824913 100644 --- a/www/index.html.spt +++ b/www/index.html.spt @@ -97,10 +97,10 @@ page_id = "homepage" {% for tab in tabs %} - +
{% for i, team in enumerate(tabs[tab]['teams'], start=1) %} -
+ {{ team.name }} From c7d06474eced71a62512865000e585df994f688f Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 15 Dec 2016 15:06:40 -0500 Subject: [PATCH 20/23] Restyle search results page to look like homepage --- scss/components/listing.scss | 24 +++- scss/fragments/mini-user.scss | 65 --------- scss/layouts/layout.scss | 9 +- scss/pages/search.scss | 48 +++---- templates/base.html | 2 +- templates/list-participants.html | 29 ++++ www/assets/gratipay.css.spt | 1 - www/index.html.spt | 2 +- www/search.spt | 226 +++++++++++++++++-------------- 9 files changed, 206 insertions(+), 200 deletions(-) delete mode 100644 scss/fragments/mini-user.scss create mode 100644 templates/list-participants.html diff --git a/scss/components/listing.scss b/scss/components/listing.scss index b27a75dde4..1e6bc7cdfe 100644 --- a/scss/components/listing.scss +++ b/scss/components/listing.scss @@ -9,6 +9,8 @@ table.listing { color: $medium-gray; border: 1px solid $light-brown; border-style: solid none; + height: 64px; + padding-top: 38px; a { color: $medium-gray; @@ -39,21 +41,33 @@ table.listing { height: 100%; } .details { + display: block; + + /* duplicate width/max-width from layouts#wrapper to get overflow to work */ + width: 98vw; + max-width: 576px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + + padding-left: 56px; + font: normal 12px/15px $Ideal; - min-height: 64px; - padding: 38px 144px 0 56px; + &.room-for-numbers { + padding-right: 144px; + } .owner a { color: $medium-gray; position: relative; z-index: 2; } - span { - white-space: nowrap; - } .status-icon { font-size: 12px; padding: 0; } + .description { + & * { display: inline; } + } } .numbers { position: absolute; diff --git a/scss/fragments/mini-user.scss b/scss/fragments/mini-user.scss deleted file mode 100644 index 6a956f5ee5..0000000000 --- a/scss/fragments/mini-user.scss +++ /dev/null @@ -1,65 +0,0 @@ -.mini-user, .search-result { - background: white !important; - border: 4px solid #DEE0E0; - box-shadow: inset 0 0 0 1px #B6B7B9; - display: block; - overflow: hidden; - @include border-radius(3px); - &:hover { - border-color: $light-brown; - box-shadow: inset 0 0 0 1px $brown; - text-decoration: none; - } -} - -.mini-user { - float: left; - width: $people-column-width - 4px; - - span.inner { - display: block; - min-height: 50px; - padding: 5px; - - span.avatar { - background: transparent url('avatar-default.png') center center no-repeat; - background-size: cover; - display: block; - height: 66px; - position: relative; - } - span.age, - span.money { - color: $black; - display: block; - font: bold 16px $Ideal; - margin: 7px 0 5px 0; - } - span.age { - font-size: 11px; - } - span.name { - display: block; - font: normal 11px $Ideal; - margin: 3px 0; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - } - - &.anonymous { - opacity: 0.33; - } -} -a.mini-user { - span.name { - color: $green; - } -} -span.mini-user { - border-color: white; - span.name { - color: $black; - } -} diff --git a/scss/layouts/layout.scss b/scss/layouts/layout.scss index 886bb640dd..9043f318de 100644 --- a/scss/layouts/layout.scss +++ b/scss/layouts/layout.scss @@ -1,8 +1,5 @@ -body { - padding: 0 12px; -} - #wrapper { + width: 98vw; max-width: 576px; margin: 0 auto; } @@ -85,6 +82,10 @@ body { #content { width: 384px; display: table-cell; + &.without-sidebar { + width: auto; + } + vertical-align: top; font: 300 14px/24px $Chronicle; diff --git a/scss/pages/search.scss b/scss/pages/search.scss index 40d9a40be8..0f09183524 100644 --- a/scss/pages/search.scss +++ b/scss/pages/search.scss @@ -1,31 +1,31 @@ -.search-box { - input { - width: 136px; - } -} +#search { -.search-results { - .mini-user { - margin: 2px; + form { + text-align: center; + margin: 0 0 40px; + button { + font: normal 14pt/20pt $Ideal; + padding: 4pt 10pt; + height: 26pt; + } + input { + font: normal 16pt/20pt $Ideal; + width: 50%; + height: 24pt; + } } -} -.search-result { - margin-bottom: 0.8em; - padding-left: 0.5em; - @include clearfix; - .avatar { - float: left; - margin: 0.5em 0; - max-height: 66px; - max-width: 66px; + .sorry { + text-align: center; + font: normal 12px/15px $Ideal; + color: $medium-gray; } - .col-right { - margin-left: 74px; + + h2 { + margin-top: 4em; } - .excerpt { - font-size: 80%; - line-height: 130%; - padding: 0.5em 0 0 1em; + + .description strong { + font-weight: bold; } } diff --git a/templates/base.html b/templates/base.html index 46b251f2f5..c836761f9d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -85,7 +85,7 @@

{% block sidebar %}{% endblock %} {% endif %} -
+
{% block subnav %}{% endblock %} {% if title %}

{{ title }}

{% endif %} {% block content %}{% endblock %} diff --git a/templates/list-participants.html b/templates/list-participants.html new file mode 100644 index 0000000000..1fc18c6a72 --- /dev/null +++ b/templates/list-participants.html @@ -0,0 +1,29 @@ +{% from 'templates/avatar-url.html' import avatar_url, avatar_img with context %} +{% macro list_participants(participants_and_excerpts, show_emails) %} + + {% for i, (participant, excerpts) in enumerate(participants_and_excerpts, start=1) %} + + + + {% endfor %} +
+ {{ avatar_img(participant) }} + {{ participant.username }} + +
+ {{ i }} + · {{ _("joined {ago}", + ago=to_age(participant.claimed_time, add_direction=True)) }} + {% if show_emails %}{% endif %} + {% if excerpts %} + + {{ process_excerpt('… ' + excerpts[0]['excerpt'] + ' …') }} + + {% else %} + {{ get_processed_excerpt(participant) }} + {% endif%} +
+
+{% endmacro %} diff --git a/www/assets/gratipay.css.spt b/www/assets/gratipay.css.spt index 26b96b2531..30ea3a2ebe 100644 --- a/www/assets/gratipay.css.spt +++ b/www/assets/gratipay.css.spt @@ -53,7 +53,6 @@ @import "scss/fragments/accounts"; @import "scss/fragments/members"; -@import "scss/fragments/mini-user"; @import "scss/fragments/notifications"; @import "scss/fragments/pagination"; diff --git a/www/index.html.spt b/www/index.html.spt index 3400824913..6033f7df2b 100644 --- a/www/index.html.spt +++ b/www/index.html.spt @@ -104,7 +104,7 @@ page_id = "homepage"
{{ team.name }} -
+
{{ i }} · - - - -{% endblock %} - +{% from 'templates/list-participants.html' import list_participants with context %} {% block content %} - {% set usernames = results.get('usernames') %} +
+ + +
+ + {% set usernames = zip(results.get('usernames', []), empty_excerpts()) %} {% set statements = results.get('statements') %} - {% set emails = results.get('emails') %} + {% set emails = zip(results.get('emails', []), empty_excerpts()) %} {% set projects = results.get('projects') %} {% if projects %} -
-

{{ ngettext("Found a matching project name", - "Found matching project names", - len(projects)) }}

-
- {% for result in projects %} - - - - {{ result.name }} +

{{ ngettext("Found a matching project", + "Found matching projects", + len(projects)) }}

+ + {% for i, team in enumerate(projects, start=1) %} + + + {% endfor %} - - +
+ + {{ team.name }} + + + {{ i }} + · + {{ status_icons[team.status]|safe }}{{ i18ned_statuses[team.status] }} + + · {{ _("created {ago}", + ago=to_age(team.ctime, add_direction=True)) }} + · + {{ _( "owned by {a}{owner}{_a}" + , owner='~'+team.owner + , a=(''|safe).format(team.owner) + , _a=''|safe + ) }} + - + + {% if team.status == 'approved' %} + + + + + + + + + + + +
{{ _("Weekly") }}Σ  n
{{ _("Receiving") }}{{ format_currency(team.receiving, 'USD') + if team.receiving else '-  '|safe }}{{ team.nreceiving_from if team.nreceiving_from else '-' }}
+ {% endif %} +
{% endif %} {% if usernames %} -

{{ ngettext("Found a matching username", - "Found matching usernames", - len(usernames)) }}

-
+

{{ ngettext("Found a matching username", + "Found matching usernames", + len(usernames)) }}

+ {{ list_participants(usernames) }} {% endif %} {% if statements %} -
-

{{ ngettext("Found a matching user statement", - "Found matching user statements", - len(statements)) }}

- {% for result in statements %} -
- {{ avatar_img(result) }} -
- {{ result.username }} - {% if len(result.excerpts) == 1 %} -
{{ - markdown.render(result.excerpts[0].excerpt) - }}
- {% endif %} -
-
- {% endfor %} -
+

{{ ngettext("Found a matching user statement", + "Found matching user statements", + len(statements)) }}

+ {{ list_participants(statements, extract_statement) }} {% endif %} {% if emails %} -

{{ ngettext("Found a matching email address", - "Found matching email addresses", - len(usernames)) }}

-
- {% for result in emails %} - - - - {{ result.username }} - - - {% endfor %} -
+

{{ ngettext("Found a matching email address", + "Found matching email addresses", + len(emails)) }}

+ {{ list_participants(emails, show_emails=True) }} {% endif %} {% if query and not (usernames or statements or emails or projects) %} -

{{ _("Sorry, we didn't find anything matching your query.") }}

+

{{ _("Sorry, we didn't find anything matching your query.") }}

{% endif %} {% endblock %} - -{% block scripts %} - -{% endblock %} [---] application/json via json_dump results From a4a4a8c209a8680bae45bcbe5be7d83668dcbd8f Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 15 Dec 2016 15:20:20 -0500 Subject: [PATCH 21/23] Tighten up layout of numbers chart in listing --- scss/components/listing.scss | 9 +++++++-- www/search.spt | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scss/components/listing.scss b/scss/components/listing.scss index 1e6bc7cdfe..f40bb2f8c2 100644 --- a/scss/components/listing.scss +++ b/scss/components/listing.scss @@ -10,7 +10,7 @@ table.listing { border: 1px solid $light-brown; border-style: solid none; height: 64px; - padding-top: 38px; + padding-top: 35px; a { color: $medium-gray; @@ -54,7 +54,7 @@ table.listing { font: normal 12px/15px $Ideal; &.room-for-numbers { - padding-right: 144px; + padding-right: 80px; } .owner a { color: $medium-gray; @@ -69,6 +69,11 @@ table.listing { & * { display: inline; } } } + &:hover { + .room-for-numbers { + padding-right: 144px; + } + } .numbers { position: absolute; bottom: 8px; diff --git a/www/search.spt b/www/search.spt index 7700f408c9..044d5c84ab 100644 --- a/www/search.spt +++ b/www/search.spt @@ -170,7 +170,7 @@ zip = zip {{ team.name }} - +
{{ i }} · - +
{% if team.status == 'approved' %} From 003d2c4a0c33d4e1d75ec87d930b9557ebd45562 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 15 Dec 2016 15:28:29 -0500 Subject: [PATCH 22/23] Tighten up vertical spacing of search input --- scss/layouts/responsiveness.scss | 3 +++ scss/pages/search.scss | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scss/layouts/responsiveness.scss b/scss/layouts/responsiveness.scss index a524a8c395..c13bdf90e1 100644 --- a/scss/layouts/responsiveness.scss +++ b/scss/layouts/responsiveness.scss @@ -89,6 +89,9 @@ margin: 10px 0 40px; min-height: 0; } + #search form { + margin-top: 50px !important; /* compensate for smaller #main margin */ + } #sidebar { padding-top: 20px; } diff --git a/scss/pages/search.scss b/scss/pages/search.scss index 0f09183524..a60ddc57b1 100644 --- a/scss/pages/search.scss +++ b/scss/pages/search.scss @@ -2,7 +2,7 @@ form { text-align: center; - margin: 0 0 40px; + margin: 20px 0 60px; button { font: normal 14pt/20pt $Ideal; padding: 4pt 10pt; @@ -12,6 +12,7 @@ font: normal 16pt/20pt $Ideal; width: 50%; height: 24pt; + margin-right: 8px; } } @@ -23,6 +24,9 @@ h2 { margin-top: 4em; + &:first-of-type { + margin-top: 0; + } } .description strong { From 4da29819ffb91b5dd3678b7c13df7d717b563297 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 15 Dec 2016 15:38:53 -0500 Subject: [PATCH 23/23] Fix regression with header sign-in drop-down --- scss/pages/search.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scss/pages/search.scss b/scss/pages/search.scss index a60ddc57b1..9275a7eff8 100644 --- a/scss/pages/search.scss +++ b/scss/pages/search.scss @@ -1,4 +1,4 @@ -#search { +#search #content { form { text-align: center;