Skip to content

Commit a472433

Browse files
committed
enh: also patch resource_item listing for dataset view
1 parent 40a4dd8 commit a472433

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
1.1.2
2+
- enh: also patch resource_item listing for dataset view
13
1.1.1
24
- reg: remove some style hints to make line break in resource names work
35
1.1.0

ckanext/dcor_theme/cli/patch_ckan_templates.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)