Skip to content

Commit e840772

Browse files
committed
optional ckanext.datagovtheme.harvest_next for catalog-next
1 parent 42dce54 commit e840772

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ CKAN version | Compatibility
4747
### Configuration
4848

4949
[Optional]
50-
`ckanext.datagovtheme.js_recent_view = true`
50+
`ckanext.datagovtheme.harvest_next = false`
51+
52+
By default, this setting is `false`. The template relies on `ckanext-harvest` to display Harvest Object and Harvest Source information in the **Metadata Source** block. For catalog-next, datasets are added via API calls, eliminating the need for the `ckanext-harvest` dependency. Set this to `true` for the harvest_next version of the **Metadata Source** block.
53+
54+
55+
[Optional]
56+
`ckanext.datagovtheme.js_recent_view = false`
5157

5258

5359
This defaults to `false`. If displaying the recent view count slows down page loading, the optional parameter can be set to `true` to make the recent view count an AJAX call, improving page loading speed. If the recent view count information (package['tracking_summary']) is already present, the AJAX call is disabled to reduce overhead. Therefore, the built-in recent view count rendering must be disabled for this mechanism to take effect. For catalog.data.gov, it means set setting `ckanext.datagovcatalog.add_packages_tracking_info` to false.

ckanext/datagovtheme/helpers.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,14 @@ def render_datetime_datagov(date_str):
265265
return value
266266

267267

268-
def get_harvest_object_formats(harvest_object_id):
268+
def get_harvest_object_formats(harvest_object_id, dataset_is_datajson=False):
269+
# simplified return for harvest_next
270+
harvest_next = asbool(config.get('ckanext.datagovtheme.harvest_next', 'false'))
271+
if harvest_next:
272+
return {
273+
'object_format': 'data.json' if dataset_is_datajson else 'ISO-19139'
274+
}
275+
269276
try:
270277
obj = p.toolkit.get_action('harvest_object_show')({}, {'id': harvest_object_id})
271278
except p.toolkit.ObjectNotFound:
@@ -325,7 +332,11 @@ def get_harvest_source_link(package_dict):
325332

326333
if harvest_source_id and harvest_source_title:
327334
msg = p.toolkit._('Harvested from')
328-
url = h.url_for('harvest_read', id=harvest_source_id)
335+
harvest_next = asbool(config.get('ckanext.datagovtheme.harvest_next', 'false'))
336+
if harvest_next:
337+
url = h.url_for(f'/harvest/{harvest_source_id}')
338+
else:
339+
url = h.url_for('harvest_read', id=harvest_source_id)
329340
link = '{msg} <a href="{url}">{title}</a>'.format(url=url, msg=msg, title=harvest_source_title)
330341
return p.toolkit.literal(link)
331342

@@ -683,8 +694,10 @@ def get_pkg_dict_extra(pkg_dict, key, default=None):
683694
if k == key:
684695
return value
685696

697+
harvest_next = asbool(config.get('ckanext.datagovtheme.harvest_next', 'false'))
686698
# Also include harvest information if exists
687-
if key in ['harvest_object_id', 'harvest_source_id', 'harvest_source_title']:
699+
if key in ['harvest_object_id', 'harvest_source_id', 'harvest_source_title'] \
700+
and not harvest_next:
688701

689702
harvest_object = model.Session.query(HarvestObject) \
690703
.filter(HarvestObject.package_id == pkg_dict['id']) \

ckanext/datagovtheme/templates/package/read.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ <h3>{{ _('Dates') }}</h3>
232232

233233
{% set harvest_object_id = h.get_pkg_dict_extra(pkg, 'harvest_object_id', None) %}
234234
{% if harvest_object_id %}
235-
{% set ho_formats = h.get_harvest_object_formats(harvest_object_id) %}
235+
{% set ho_formats = h.get_harvest_object_formats(harvest_object_id, dataset_is_datajson=dataset_is_datajson) %}
236236
{% if ho_formats.object_format %}
237237
<section id="dataset-metadata-source" class="resources module-content">
238238
<h3>{{ _('Metadata Source') }}</h3>

0 commit comments

Comments
 (0)