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

add title to truncated links #1505

Merged
merged 12 commits into from
Sep 13, 2024
4 changes: 4 additions & 0 deletions changes/1505.changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- show title with truncated link text
- show title in breadcrumbs
- increase breadcrumb length to 80 for package and resource
- increase title length from ckan's default 80 to 150 before truncating
1 change: 1 addition & 0 deletions ckanext/canada/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ def ckan_to_cdts_breadcrumbs(breadcrumb_content):
anchor = breadcrumb.find('a')
cdts_breadcrumbs.append({
'title': breadcrumb.text if not anchor else anchor.text,
'acronym': '' if not anchor else anchor.get('title', ''),
'href': '' if not anchor else anchor['href'],
})
return cdts_breadcrumbs
Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/admin/trash.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ul class="user-list list-group">
{% for pkg in g.deleted_packages %}
{% set title = pkg.title or pkg.name %}
<li class="list-group-item">{{ h.link_to(h.truncate(title, truncate_title), h.url_for(pkg.type + '.read', id=pkg.name)) }}</li>
<li class="list-group-item">{{ h.link_to(h.truncate(title, truncate_title), h.url_for(pkg.type + '.read', id=pkg.name), title=title) }}</li>
RabiaSajjad marked this conversation as resolved.
Show resolved Hide resolved
{% endfor %}
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% set html_title = h.truncate(organization.description, length=80, whole_word=True) %}
{% endif %}
<dt style="width:auto;"><a href="{{ url }}" title="{{ html_title }}">
{{ h.truncate(h.split_piped_bilingual_field(organization.display_name, h.lang()), length=70, whole_word=True) }}</a>
{{ h.truncate(h.split_piped_bilingual_field(organization.display_name, h.lang()), length=80, whole_word=True) }}</a>
</dt>
<dd class="text-right">
{%- if organization.package_count -%}
Expand Down
3 changes: 1 addition & 2 deletions ckanext/canada/templates/package/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{% set pkg_url = h.url_for(pkg.type ~ '.read', id=pkg.id if is_activity_archive else pkg.name, **({'activity_id': request.args['activity_id']} if 'activity_id' in request.args else {})) %}
{% if g.action != 'new' and pkg %}
{% set dataset = h.get_translated(pkg, 'title') %}
<li><a href="{{ pkg_url }}">{{ dataset|truncate(30) }}</a></li>
<li><a href="{{ pkg_url }}" title="{{ dataset }}">{{ dataset|truncate(80) }}</a></li>
{% endif %}
{% endblock %}

5 changes: 5 additions & 0 deletions ckanext/canada/templates/package/resource_read.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
{% endif %}
{% endblock %}

{% block breadcrumb_content %}
{{ super.super() }}
<li class="active"><a href="" title="{{ h.resource_display_name(res) }}">{{ h.resource_display_name(res)|truncate(80) }}</a></li>
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK <a> tags without an href are bad for a11y. Are we allowed to add a title to another type of tag?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can do javascript void into the href to fix the a11y complaints.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also put tabindex="-1" to prevent tabbing

{% endblock %}

{% block resource_actions %}
<div class="resource-actions-toolbar">{{ super() }}</div>
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/recombinant/resource_edit.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% ckan_extends %}

{% block organization_display %}
{{- h.split_piped_bilingual_field(org.title, h.lang()) | truncate(60) -}}
{{- h.split_piped_bilingual_field(org.title, h.lang()) | truncate(80) -}}
{% endblock %}

{%- block subtitle_2 -%}
Expand Down
4 changes: 0 additions & 4 deletions ckanext/canada/templates/snippets/cdts/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@
"subhref": {{ recombinant_menu_link('travela') | tojson }},
"subtext": {{ recombinant_menu_text('travela') | tojson }},
},
{
"subhref": {{ recombinant_menu_link('qpnotes') | tojson }},
"subtext": {{ recombinant_menu_text('qpnotes') | tojson }},
},
JVickery-TBS marked this conversation as resolved.
Show resolved Hide resolved
{
"subhref": {{ h.url_for('info_new', collection='transition') | tojson }},
"subtext": {{ _('New or incoming ministers') | tojson }},
Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/snippets/package_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h3 class="panel-title">
{% block heading_private %}
{{ super() }}
{% endblock %}
{{ h.link_to(h.truncate(my_title, truncate_title), h.url_for(package.type ~ '.read', id=package.name)) }}
{{ h.link_to(h.truncate(my_title, 150), h.url_for(package.type ~ '.read', id=package.name), title=my_title) }}
{% block heading_meta %}
{{ super() }}
{% endblock %}
Expand Down
Loading