Skip to content

Commit

Permalink
use breadcrumb trail guidance to improve breadcrumbs on Portal
Browse files Browse the repository at this point in the history
  • Loading branch information
RabiaSajjad committed Sep 9, 2024
1 parent f8567f5 commit 212e2fa
Show file tree
Hide file tree
Showing 9 changed files with 369 additions and 261 deletions.
3 changes: 3 additions & 0 deletions changes/1505.changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
- 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
- use the breadcrumb trail guidance to not display the current page
at the end of the breadcrumb trail (linked or unlinked) for the Portal only
https://design.canada.ca/common-design-patterns/breadcrumb-trail.html
8 changes: 8 additions & 0 deletions ckanext/canada/assets/internal/canada_internal.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
ol.breadcrumb {
margin-bottom: 0px;
}
.breadcrumb li:last-child a {
background: transparent !important;
color: black;
pointer-events: none;
cursor: default;
text-decoration: none;
}

#wb-info a {
text-decoration: none;
}
Expand Down
8 changes: 0 additions & 8 deletions ckanext/canada/assets/public/canada_public.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ details.alert-error {
color: #295376;
}

.breadcrumb li:last-child a {
background: transparent !important;
color: black;
pointer-events: none;
cursor: default;
text-decoration: none;
}

.fgpv {
height: 700px;
border: 1px solid black;
Expand Down
32 changes: 25 additions & 7 deletions ckanext/canada/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,17 +853,35 @@ def ckan_to_cdts_breadcrumbs(breadcrumb_content):
See: https://cdts.service.canada.ca/app/cls/WET/gcweb/v4_1_0/cdts/samples/breadcrumbs-en.html
"""
breadcrumb_html = BeautifulSoup(breadcrumb_content, 'html.parser')
cdts_breadcrumbs = [{
'title': _('Registry Home') if g.is_registry else _('Open Government Portal'),
'href': '/%s' % h.lang(),
}]
cdts_breadcrumbs = []
if g.is_registry:
cdts_breadcrumbs.append({
'title': _('Registry Home'),
'href': '/%s' % h.lang(),
})
else:
cdts_breadcrumbs.extend([{
'title': _('Open Government'),
'href': '/%s' % h.lang(),
},{
'title': _('Search'),
'href': adv_search_url(),
}])

for breadcrumb in breadcrumb_html.find_all('li'):
anchor = breadcrumb.find('a')
cdts_breadcrumbs.append({
link = {
'title': breadcrumb.text if not anchor else anchor.text,
'acronym': '' if not anchor else anchor.get('title', ''),
'href': '' if not anchor else anchor['href'],
})
}
if anchor and anchor.get('title'):
link['acronym'] = anchor.get('title')

if g.is_registry:
cdts_breadcrumbs.append(link)
elif 'active' not in breadcrumb.get('class', []):
cdts_breadcrumbs.append(link)

return cdts_breadcrumbs


Expand Down
Loading

0 comments on commit 212e2fa

Please sign in to comment.