File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 1.1.2
2+ - enh: also patch resource_item listing for dataset view
131.1.1
24 - reg: remove some style hints to make line break in resource names work
351.1.0
Original file line number Diff line number Diff line change @@ -22,7 +22,24 @@ def patch_wider_resource_listing():
2222 """Make sure the full filename is visible in the resource view"""
2323 ckan_path = pathlib .Path (ckan .__file__ ).parent
2424
25- # patch resource listing template
25+ # patch resource listing package template
26+ path_template_res_item = \
27+ ckan_path / "templates/package/snippets/resource_item.html"
28+ data_res_item = path_template_res_item .read_text ()
29+ # This makes the browser force a line-break even inside a word,
30+ # which means that it breaks long filenames.
31+ st = 'style="word-wrap: break-word"'
32+ for old , new in [
33+ # remove the truncate filter for file names
34+ ("| truncate(50)" , "" ),
35+ # force word wrap of the file names
36+ ('<a class="heading"' ,
37+ f'<a { st } class="heading"' ),
38+ ]:
39+ data_res_item = data_res_item .replace (old , new )
40+ path_template_res_item .write_text (data_res_item )
41+
42+ # patch resource listing details template
2643 path_template_res = ckan_path / "templates/package/snippets/resources.html"
2744 data_res = path_template_res .read_text ()
2845 # This makes the browser force a line-break even inside a word,
You can’t perform that action at this time.
0 commit comments