Skip to content

Commit 9a7f593

Browse files
authored
Merge pull request #83 from OpenDataServices/77-relevance-score
Updated layout and ranking
2 parents 52f2501 + 0ed9c88 commit 9a7f593

File tree

5 files changed

+210
-77
lines changed

5 files changed

+210
-77
lines changed

prefix_finder/frontend/templates/base.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@
8383
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
8484
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
8585
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.0/js/bootstrap-select.min.js"></script>
86-
<script>$(function () {$('[data-toggle="tooltip"]').tooltip()})</script>
86+
<script>$(function () {$('[data-toggle="tooltip"]').tooltip()})
87+
$(function () { $('[data-toggle="popover"]').popover({
88+
container: 'body'})})</script>
8789

8890
{% block extra_scripts %}{% endblock %}
8991
{% if piwik.url and piwik.site_id %}

prefix_finder/frontend/templates/home.html

Lines changed: 63 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,53 @@
77
<div class="container">
88
<div class="row">
99
<div class="col-xs-12">
10-
<h2 class="text-center">Find a List of Organization Identifiers </h2>
11-
<br>
12-
<h5 class="indent">Describe the organization(s) you want to provide identifiers for:</h5>
10+
<h2 class="text-center">Find an organization identifier...</h2>
1311
<br>
1412
<form>
1513
<div class="form-group col-md-4">
16-
<div class="select-label">Geographical coverage</div>
17-
<select name="coverage" class="selectpicker has-suboption" data-live-search="true" data-width="300px">
18-
<option value="">Any country</option>
19-
{% for code, title, disabled in lookups.coverage %}
20-
<option {% if query.coverage == code %} selected {% elif disabled %} disabled {% endif %} value="{{code}}">{{title}}</option>
14+
<div class="select-label">I need identifiers for...</div>
15+
<select name="structure" class="selectpicker has-suboption" data-live-search="true" data-width="300px">
16+
<option value="">Any type of organisation</option>
17+
{% for code, title, disabled in lookups.structure %}
18+
<option {% if query.structure == code %} selected {% elif disabled %} disabled {% endif %} value="{{code}}">{% if title|slice:"1" in "A,E,I,O,U"|slice:',' %}An{%else%}A{%endif%} {{title|lower}}</option>
2119
{% endfor %}
2220
</select>
23-
{% if lookups.subnational %}
21+
{% if lookups.substructure %}
2422
<div class="indented-option">
25-
<div class="select-label">Subnational coverage</div>
26-
<select name="subnational" class="selectpicker" data-live-search="true" data-width="280px" onchange="this.form.submit()">
27-
<option value="">Any subnational location</option>
28-
{% for code, title, disabled in lookups.subnational %}
29-
<option {% if query.subnational == code %} selected {% elif disabled %} disabled {% endif %} value="{{code}}">{{title}}</option>
23+
<div class="select-label">In particular...</div>
24+
<select name="substructure" class="selectpicker" data-live-search="true" data-width="280px" onchange="this.form.submit()">
25+
<option value="">Any type</option>
26+
{% for code, title, disabled in lookups.substructure %}
27+
<option {% if query.substructure == code %} selected {% elif disabled %} disabled {% endif %} value="{{code}}">{% if title|slice:"1" in "A,E,I,O,U"|slice:',' %}An{%else%}A{%endif%} {{title|lower}}</option>
3028
{% endfor %}
3129
</select>
3230
</div>
3331
{% endif %}
3432
</div>
33+
3534
<div class="form-group col-md-4">
36-
<div class="select-label">Organization type</div>
37-
<select name="structure" class="selectpicker has-suboption" data-live-search="true" data-width="300px">
38-
<option value="">Any type</option>
39-
{% for code, title, disabled in lookups.structure %}
40-
<option {% if query.structure == code %} selected {% elif disabled %} disabled {% endif %} value="{{code}}">{{title}}</option>
35+
<div class="select-label">Registered in...</div>
36+
<select name="coverage" class="selectpicker has-suboption" data-live-search="true" data-width="300px">
37+
<option value="">Any country</option>
38+
{% for code, title, disabled in lookups.coverage %}
39+
<option {% if query.coverage == code %} selected {% elif disabled %} disabled {% endif %} value="{{code}}">{{title}}</option>
4140
{% endfor %}
4241
</select>
43-
{% if lookups.substructure %}
42+
{% if lookups.subnational %}
4443
<div class="indented-option">
45-
<div class="select-label">Organisation subtype</div>
46-
<select name="substructure" class="selectpicker" data-live-search="true" data-width="280px" onchange="this.form.submit()">
47-
<option value="">Any subtype</option>
48-
{% for code, title, disabled in lookups.substructure %}
49-
<option {% if query.substructure == code %} selected {% elif disabled %} disabled {% endif %} value="{{code}}">{{title}}</option>
44+
<div class="select-label">In the state or region of...</div>
45+
<select name="subnational" class="selectpicker" data-live-search="true" data-width="280px" onchange="this.form.submit()">
46+
<option value="">Any subnational location</option>
47+
{% for code, title, disabled in lookups.subnational %}
48+
<option {% if query.subnational == code %} selected {% elif disabled %} disabled {% endif %} value="{{code}}">{{title}}</option>
5049
{% endfor %}
5150
</select>
5251
</div>
5352
{% endif %}
5453
</div>
54+
5555
<div class="form-group col-md-4">
56-
<div class="select-label">Organisation sector</div>
56+
<div class="select-label">Working in...</div>
5757
<select name="sector" class="selectpicker" data-live-search="true" data-width="300px" onchange="this.form.submit()">
5858
<option value="">Any sector</option>
5959
{% for code, title, disabled in lookups.sector %}
@@ -68,35 +68,63 @@ <h5 class="indent">Describe the organization(s) you want to provide identifiers
6868
{% if query %}
6969
{% if all_results.suggested %}
7070
{% with all_results.suggested as results %}
71-
<h3 id="results" class="text-center">We suggest that you look first at:</h3>
72-
<br>
71+
<h3 id="results" class="text-center">Suggested lists:</h3>
72+
<p>
73+
We think one of the lists below will have a good chance of including the organisation(s) you are looking for...
74+
</p>
7375
{% include 'results.html' %}
74-
<br>
75-
<h5 class="text-center">Not relevant? Narrow your search from the options above</h5>
7676
{% endwith %}
7777
{% else %}
78-
<h3 id="results" class="text-center">No Suggested Results</h3>
78+
<p>
79+
We can't provide any <strong>suggested results</strong> for your query. Either narrow your query, or move to look at alternative lists below.
80+
</p>
7981
{% endif %}
8082

8183
{% if all_results.recommended %}
8284
{% with all_results.recommended as results %}
83-
<h3 id="results" class="text-center">Other recommended lists include:</h3>
84-
<br>
85+
<h3 id="results" class="text-center">Possible lists:</h3>
86+
<p>
87+
It's possible you will find the organisation(s) you are looking for in one of the lists below...
88+
</p>
8589
{% include 'results.html' %}
8690
{% endwith %}
8791
{% else %}
88-
<h3 id="results" class="text-center">No Recommended Results</h3>
92+
<h3 id="results" class="text-center">No alternative results</h3>
8993
{% endif %}
9094

9195
{% if all_results.other %}
9296
{% with all_results.other as results %}
93-
<h3 id="results" class="text-center">Alternative identifier sources:</h3>
97+
<h3 id="results" class="text-center">Fall back identifier sources:</h3>
98+
<p>
99+
The following lists provide a fall back option when no other identifier sources are available.
100+
</p>
94101
<br>
95102
{% include 'results.html' %}
96103
{% endwith %}
97104
{% else %}
98105
<h3 id="results" class="text-center">No Other Results</h3>
99106
{% endif %}
107+
{% else %}
108+
109+
<div class="jumbotron">
110+
<h1>org-id.guide</h1>
111+
<p>
112+
Data is more valuable when you include recognised <strong>organisation identifiers</strong>.
113+
</p>
114+
<p>
115+
We'll help you to find the best available source of identifiers for any kind of organisation: so you can provide better quality open data.
116+
</p>
117+
<h2>Get started</h2>
118+
<p>
119+
Start searching above, or find out <a href="/about/">how to integrate org-id.guide into your application</a>.
120+
</p>
121+
<h2>Get involved</h2>
122+
<p>
123+
Are we missing a list? <a href="https://github.com/OpenDataServices/org-ids/issues">Get in touch to suggest additions or updates</a>.
124+
</p>
125+
</div>
126+
127+
100128
{% endif %}
101129
</div>
102130
</div>
Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,63 @@
11
{% load static %}
22
{% load results %}
33

4+
<div class="row">
45
{% for result in results %}
6+
<div class="col-xs-12 col-md-6">
57
<div class="panel panel-default">
6-
<div class="panel-heading">
7-
<h4><a href="{% url 'list' result.code %}" data-toggle="tooltip" data-placement="top" title="More info">{{result.name.en}} ({{result.code}})</a></h4>
8+
<div class="panel-heading"><span class="badge pull-right" data-toggle="popover" data-placement="bottom" title="Quality score" data-html="true" data-content="{% for key,value in result.quality_explained.items %}{{ key }} - {{ value }}<br/>{% endfor %} data-trigger="hover">Quality score: {{ result.quality }}</span>
9+
<h4><a href="{% url 'list' result.code %}" data-toggle="tooltip" data-placement="top" title="More info">{{ result.name.en }} ({{ result.code }})</a> </h4>
10+
811
</div>
912
<div class="panel-body">
10-
<dl class="dl-horizontal">
11-
{% for key, value in result|tidy_results %}
12-
{% if value %}
13-
<dt> {{key|capfirst}} </dt>
14-
<dd>
15-
{% if value|slice:":4" == "http" %}
16-
<a href="{{value}}">{{value}}</a>
17-
{% else %}
18-
{{value|capfirst}}
19-
{% endif %}
20-
</dd>
21-
{% endif %}
22-
{% endfor %}
23-
<dt>URL</dt>
24-
<dd>
25-
<a href="{{result.url}}">{{result.url}}</a>
26-
</dd>
27-
</dl>
28-
<a class="pull-right" href="{% url 'list' result.code %}"><button class="btn">More info</button></a>
13+
<p style="font-size:larger;">
14+
Use the list code <code>{{ result.code }}</code> and an identifier found at <a href="{{ result.url }}" target="_blank">{{ result.url|truncatechars:100 }}</a>
15+
</p>
16+
<p>
17+
{{ result.description.en|truncatewords_html:50 }} <a href="{% url 'list' result.code %}">Read more</a>
18+
</p>
19+
<p>
20+
This is a <strong>{{ result.listType }}</strong> list.
21+
{% if result.listType = "primary" %}
22+
Organisations are generally entered into this list when they are registered
23+
{% if result.structure %} as a {{ result.structure_titles|join_with:'or'|lower }} {% endif %}
24+
{% if result.subnationalCoverage %}
25+
in {{ result.subnationalCoverage_titles|join_with:'or' }}.
26+
{% else %}
27+
in {{ result.coverage_titles|join_with:'or' }}.
28+
{% endif %}
29+
{% endif %}
30+
{% if result.listType = "secondary" %}
31+
{% if result.structure %}{{ result.structure_titles|join_with:'or' }} organisations{% else %}{% if result.sector %}{{ result.sector_titles|join_with:'or' }} organisations{% else %} Organisations{% endif %}{% endif %} may be entered onto this offical list as a result of a transaction with the list owner.
32+
{% endif %}
33+
{% if result.listType = "third_party" %}
34+
This list is maintained by a third-party who may or may not have had interactions or transactions with the organiastions listed.
35+
{% endif %}
36+
{% if result.listType = "local" %}
37+
This list is maintained by a single organisation for their own business purpose.
38+
{% endif %}
39+
</p>
40+
{% if result.coverage %}<p>
41+
This list covers the following countries: {{ result.coverage_titles|join_with:'and' }}.
42+
</p>{% endif %}
43+
{% if result.structure %}<p>
44+
It includes organisations of the following types: {{ result.structure_titles|join_with:'or' }}.
45+
</p>{% endif %}
46+
{% if result.sector %}<p>
47+
It includes organisations working in the following sectors: {{ result.sector_titles|join_with:'or' }}
48+
</p>{% endif %}
49+
<a class="pull-right" href="{% url 'list' result.code %}"><button class="btn" style="margin-top:25px;">More info</button></a>
50+
<hr/>
51+
<p>
52+
<strong>Example identifiers</strong>: {{ result.access.exampleIdentifiers }}
53+
</p>
54+
{% if local %}
55+
<strong>Debug info</strong>
56+
{{ result.relevance }} | {{ result.relevance_debug }}
57+
{% endif %}
2958
</div>
3059
</div>
60+
</div>
61+
{% if forloop.counter|divisibleby:2 %}</div><div class="row">{% endif %}
3162
{% endfor %}
63+
</div>

prefix_finder/frontend/templatetags/results.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
(('listType', ), 'List type'),
1111
(('data', 'licenseStatus'), 'Data license status'),
1212
(('relevance', ), 'Relevance'),
13-
(('quality', ), 'Quality')
13+
(('quality', ), 'Quality'),
14+
(('relevance_debug', ), 'Relevance Debug'),
1415
))
1516

17+
1618
paths_display_name_long = OrderedDict((
1719
(('data', 'licenseDetails'), 'Data license details'),
1820
# (('data', 'dataAccessDetails'), 'Data access'),
@@ -60,7 +62,7 @@ def tidy_results(results, length=None):
6062
if length == 'long':
6163
continue
6264
else:
63-
info = info.split('.')[0] # (naively) shorten description
65+
info = info.split(". ")[0] # (naively) shorten description
6466
tidied_results[key_name] = '{}.'.format(info)
6567
else:
6668
for field_name, details in info.items():
@@ -75,3 +77,24 @@ def tidy_results(results, length=None):
7577
tidied_results[key_name] = info
7678

7779
return tidied_results.items()
80+
81+
82+
@register.filter
83+
def join_with(value, conj):
84+
"""Given a list of strings, format them with commas and spaces, but
85+
with 'and' or 'or' at the end.
86+
87+
>>> join_with(['apples', 'oranges', 'pears'], 'and')
88+
"apples, oranges, and pears"
89+
"""
90+
if not value:
91+
return ""
92+
if len(value) == 1:
93+
return value[0]
94+
95+
# convert numbers to strings
96+
value = [str(item) for item in value]
97+
98+
# join all but the last element
99+
all_but_last = ", ".join(value[:-1])
100+
return "%s %s %s" % (all_but_last, conj, value[-1])

0 commit comments

Comments
 (0)