Skip to content

Commit b75baad

Browse files
committed
feat: improve resource listing to show full resource names
1 parent 11610ef commit b75baad

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
1.1.0
2+
- feat: improve resource listing to show full resource names
13
1.0.0
24
- declare first stable release
35
0.12.1

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ The CKAN theme of DCOR. What this plugin does:
2222

2323
ckan dcor-theme-main-css-branding
2424

25+
- patch CKAN templates with minor changes that would be too complicated to
26+
implement with jinja templating::
27+
28+
ckan dcor-patch-ckan-templates
29+
2530

2631
Installation
2732
------------

ckanext/dcor_theme/cli/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from .i18n_branding import dcor_theme_i18n_branding
22
from .main_css_branding import dcor_theme_main_css_branding
3+
from .patch_ckan_templates import dcor_patch_ckan_templates
34

45

56
def get_commands():
6-
return [dcor_theme_i18n_branding,
7-
dcor_theme_main_css_branding]
7+
return [
8+
dcor_patch_ckan_templates,
9+
dcor_theme_i18n_branding,
10+
dcor_theme_main_css_branding,
11+
]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import logging
2+
import pathlib
3+
4+
import ckan
5+
import click
6+
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
@click.command()
12+
def dcor_patch_ckan_templates():
13+
"""
14+
patch CKAN templates with minor changes that would be too complicated to
15+
implement with jinja templating
16+
"""
17+
click.secho("Patching templates to improve resource listing")
18+
patch_wider_resource_listing()
19+
20+
21+
def patch_wider_resource_listing():
22+
"""Make sure the full filename is visible in the resource view"""
23+
ckan_path = pathlib.Path(ckan.__file__).parent
24+
25+
# patch page to increase resource file listing width
26+
path_template_page = ckan_path / "templates/page.html"
27+
data_page = path_template_page.read_text()
28+
for old, new in [
29+
('<aside class="secondary col-md-3">',
30+
'<aside class="secondary col-md-5">'),
31+
('<div class="primary col-md-9 col-xs-12" role="main">',
32+
'<div class="primary col-md-7 col-xs-12" role="main">')
33+
]:
34+
data_page = data_page.replace(old, new)
35+
path_template_page.write_text(data_page)
36+
37+
# patch resource listing template, removing the truncate filter
38+
path_template_res = ckan_path / "templates/package/snippets/resources.html"
39+
data_res = path_template_res.read_text()
40+
data_res = data_res.replace("|truncate(25)", "")
41+
path_template_res.write_text(data_res)

0 commit comments

Comments
 (0)