diff --git a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/read.html b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/read.html index db5061f..a851298 100644 --- a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/read.html +++ b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/read.html @@ -1,21 +1,24 @@ -{% extends "package/read_base.html" %} +{% ckan_extends %} +{% set dataset_extent = h.get_pkg_dict_extra(c.pkg_dict, 'spatial', '') %} +{% set d4science_cms_obj_placeholders = h.d4science_get_content_moderator_system_placeholder() %} +{% set moderation_item_status = h.get_pkg_dict_extra(c.pkg_dict,d4science_cms_obj_placeholders.item_status,'') %} {% block primary_content_inner %} - {{ super() }} - {% set dataset_extent = h.get_pkg_dict_extra(c.pkg_dict, 'spatial', '') %} - {% if dataset_extent %} - {% snippet "spatial/snippets/dataset_map.html", extent=dataset_extent %} - {% endif %} +{% if moderation_item_status %} + + {{ moderation_item_status }} + +{% endif %} {% block package_description %} {% if pkg.private %} - - + + {{ _('Private') }} {% endif %} -

+
{% block page_heading %} - {{ h.dataset_display_name(pkg) }} + {{ pkg.title or pkg.name }} {% if pkg.state.startswith('draft') %} [{{ _('Draft') }}] {% endif %} @@ -23,28 +26,34 @@ [{{ _('Deleted') }}] {% endif %} {% endblock %} -

+ {% block package_notes %} {% if pkg.notes %} -
- {{ h.render_markdown(h.get_translated(pkg, 'notes')) }} +
+ {{ h.render_markdown(pkg.notes) }}
{% endif %} {% endblock %} {# FIXME why is this here? seems wrong #} {% endblock %} + + + {% if dataset_extent %} + {% snippet "spatial/snippets/dataset_map.html", extent=dataset_extent %} + {% endif %} + + {% block package_tags %} +
{{_('Tags')}}
+ {% snippet "package/snippets/tags.html", tags=pkg.tags %} + {% endblock %} {% block package_resources %} {% snippet "package/snippets/resources_list.html", pkg=pkg, resources=pkg.resources %} {% endblock %} - {% block package_tags %} - {% snippet "package/snippets/tags.html", tags=pkg.tags %} - {% endblock %} - {% block package_additional_info %} {% snippet "package/snippets/additional_info.html", pkg_dict=pkg %} {% endblock %} - -{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/additional_info.html b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/additional_info.html index d4070ce..e058199 100644 --- a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/additional_info.html +++ b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/additional_info.html @@ -1,5 +1,74 @@ +{% set key_item_url = _('Item') + ' URL' %} + + + + +
-

{{ _('Additional Info') }}

+ {% block extras scoped %} + {# + This performs a sort + {% for extra in h.sorted_extras(pkg_dict.extras) %} + #} + {% if pkg_dict.extras %} + {# Added by Francesco Mangiacrapa, see 17901 #} + {% set extra_item_url = h.get_pkg_dict_extra(pkg_dict,key_item_url) %} + {% if extra_item_url %} +
{{ key_item_url }}
+ + + + + +
{{ extra_item_url }}{% snippet "package/snippets/qrcode_show.html", package_url=extra_item_url %}
+ {% endif %} + {% set extras_indexed_for_categories = h.d4science_get_extras_indexed_for_namespaces(pkg_dict.extras) %} + {% for k_cat in extras_indexed_for_categories %} + {% set category_idx = extras_indexed_for_categories[k_cat] %} + {% if(k_cat!='nocategory') %} +
{{category_idx.category.title}}
+ {% if category_idx.category.description %} +

Description: {{category_idx.category.description}}

+ {% endif %} + + + + + + + + + {% set my_extras = h.d4science_get_extra_for_category(extras_indexed_for_categories, k_cat) %} + {% snippet "package/snippets/extras_table.html", my_extras=my_extras, key_item_url=key_item_url %} + +
{{ _('Field') }}{{ _('Value') }}
+
+ {% endif %} + {% endfor %} + {% set my_extras = h.d4science_get_extra_for_category(extras_indexed_for_categories, 'nocategory') %} + {% if my_extras|length > 0 %} +
{{ _('Additional Info') }}
+ + + + + + + + + {% snippet "package/snippets/extras_table.html", my_extras=my_extras, key_item_url=key_item_url %} + +
{{ _('Field') }}{{ _('Value') }}
+
+ {% endif %} + {% endif %} + {% endblock %} +
{{ _('Management Info') }}
@@ -13,11 +82,7 @@ {% if h.is_url(pkg_dict.url) %} - + {% else %} {% endif %} @@ -35,16 +100,17 @@ {% endif %} - + {# Added by Francesco Mangiacrapa #} + {% set user_maintainer = h.d4science_get_user_info(pkg_dict.maintainer) %} {% if pkg_dict.maintainer_email %} - + {% elif pkg_dict.maintainer %} - + {% endif %} @@ -78,18 +144,7 @@ {% endif %} - - {% block extras scoped %} - {% for extra in h.sorted_extras(pkg_dict.extras) %} - {% set key, value = extra %} - - - - - {% endfor %} - {% endblock %} - - {% endblock %} - +
{{ _('Source') }} - - {{ pkg_dict.url }} - - {{ h.link_to(pkg_dict.url, pkg_dict.url, rel='foaf:homepage', target='_blank') }}{{ pkg_dict.url }}{{ pkg_dict.author }}
{{ _('Maintainer') }}{{ h.mail_to(email_address=pkg_dict.maintainer_email, name=pkg_dict.maintainer) }}{{ h.mail_to(email_address=pkg_dict.maintainer_email, name=user_maintainer.fullname if (user_maintainer and user_maintainer.fullname) else pkg_dict.maintainer) }}
{{ _('Maintainer') }}{{ pkg_dict.maintainer }}{{ user_maintainer.fullname if (user_maintainer and user_maintainer.fullname) else pkg_dict.maintainer }}
{{ _(key|e) }}{{ value }}
-
+ {% endblock %} + \ No newline at end of file diff --git a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/extras_table.html b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/extras_table.html new file mode 100644 index 0000000..4a809cc --- /dev/null +++ b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/extras_table.html @@ -0,0 +1,59 @@ + + + + {% set d4science_cms_obj_placeholders = h.d4science_get_content_moderator_system_placeholder() %} + {% for extra_lnk in my_extras %} + {% set index = loop.index %} + {% for k in extra_lnk.keys() %} + {# Added by Francesco Mangiacrapa, see: #21701 #} + {% set extra_value = extra_lnk[k] %} + + {% if extra_value is defined and extra_value|length %} + {# Added by Francesco Mangiacrapa, see: #7055 #} + {% set isHttp = extra_value.startswith(('http://', 'https://')) %} + + + {% if k != key_item_url and (not k.startswith(d4science_cms_obj_placeholders.prefix)) %} + {{ _(k) }} + {% if isHttp %} + {% if k == 'graphic-preview-file'%} + {{ + {% else %} + {{ extra_value }} + {% endif %} + {% elif k == 'responsible-party' %} +
{{ extra_value }}
+ {% elif k == 'dataset-reference-date' %} +
{{ extra_value }}
+ {% elif k == 'coupled-resource' %} +
{{ extra_value }}
+ {% elif k.startswith('Zenodo') %} + + {% elif k == 'spatial' %} +
{{ extra_value }}
+ {% else %} + {{ extra_value }} + {% endif %} + {% endif %} + {% endif %} + {% endfor %} + {% endfor %} \ No newline at end of file diff --git a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/info.html b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/info.html index 20678ff..60420b8 100644 --- a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/info.html +++ b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/info.html @@ -1,41 +1,48 @@ {# -Displays a sidebar module with information for given package - -pkg - The package dict that owns the resources. - -Example: - - {% snippet "package/snippets/info.html", pkg=pkg %} - -#} -{% block package_info %} - {% if pkg %} -
-
-
- {% block package_info_inner %} - {% block heading %} -

{{ h.dataset_display_name(pkg) }}

- {% endblock %} - {% block nums %} - {% set num_followers = h.follow_count('dataset', pkg.id) %} -
-
-
{{ _('Followers') }}
-
{{ h.SI_number_span(num_followers) }}
-
-
- {% endblock %} - {% block follow_button %} - {% if not hide_follow_button %} - -
- {% endif %} -{% endblock %} + + {% endif %} + {% endblock %} + \ No newline at end of file diff --git a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/qrcdode_show.html b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/qrcdode_show.html new file mode 100644 index 0000000..a0ec361 --- /dev/null +++ b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/qrcdode_show.html @@ -0,0 +1,6 @@ +{% set qr_code_image = h.d4science_get_qrcode_for_url(package_url) %} +{% block package_qrcode_for_url %} +
{{
+{% endblock %} + + \ No newline at end of file diff --git a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/resource_item.html b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/resource_item.html index 31d1c56..0f668fc 100644 --- a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/resource_item.html +++ b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/resource_item.html @@ -1,82 +1,108 @@ -{# - Renders a single resource with icons and view links. - - res - A resource dict to render - pkg - A package dict that the resource belongs to - can_edit - Whether the user is allowed to edit the resource - url_is_edit - Whether the link to the resource should be to editing it (set to False to make the link view the resource) - url - URL of the resource details page(resource edit/read depending on url_is_edit, by default). - - Example: - - {% snippet "package/snippets/resource_item.html", res=resource, pkg=pkg, can_edit=True, url_is_edit=False %} - -#} -{% set url_action = pkg.type ~ ('_resource.edit' if url_is_edit and can_edit else '_resource.read') %} -{% set url = url or h.url_for(url_action, id=pkg.name, resource_id=res.id) %} - +{% set can_edit = h.check_access('package_update', {'id':pkg.id }) %} +{% set url_action = 'resource_edit' if url_is_edit and can_edit else 'resource_read' %} +{# {% set url = h.url_for(controller='package', action=url_action, id=pkg.name, resource_id=res.id) %} #} +{% set url = h.url_for('dataset_resource.read', id=pkg.name, resource_id=res.id) %}
  • +{# Added by Francesco Mangiacrapa block custom_view_on_resources see:4851 #} +{% block custom_view_on_resources %} +{% set user = c.user %} +{% if user %} {% block resource_item_title %} - {{ h.resource_display_name(res) | truncate(50) }}{{ h.get_translated(res, 'format') }} - {{ h.popular('views', res.tracking_summary.total, min=10) if res.tracking_summary }} + {{ h.resource_display_name(res) | truncate(50) }}{{ res.format }} + {{ h.popular('views', res.tracking_summary.total, min=10) }} {% endblock %} {% block resource_item_description %}

    {% if res.description %} - {{ h.markdown_extract(h.get_translated(res, 'description'), extract_length=80) }} + {{ h.markdown_extract(res.description, extract_length=80) }} {% endif %}

    {% endblock %} {% block resource_item_explore %} {% if not url_is_edit %} + {# Only if can edit, explorer button is shown with several facility #} + {% if can_edit %} + {% else %} + + {{ _('Go to resource') }} + + {% endif %} {% endif %} {% endblock %} +{% else %} + {% block resource_item_title2 %} + {# Updated by Francesco Mangiacrapa, see: #10056 #} + + {{ h.resource_display_name(res) | truncate(50) }}{{ res.format }} + {{ h.popular('views', res.tracking_summary.total, min=10) }} + + {% endblock %} +
    + {% block resource_item_description2 %} +

    + {% if res.description %} + {{ h.markdown_extract(res.description, extract_length=80) }} + {% endif %} +

    + {% endblock %} + The resource: '{{ h.resource_display_name(res) | truncate(30) }}' is not accessible as guest user. You must login to access it! +
    +{% endif %} +{% endblock %}
  • + diff --git a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/resources_list.html b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/resources_list.html index 9c6dd63..3ab3b78 100644 --- a/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/resources_list.html +++ b/ckanext-d4science_theme/ckanext/d4science_theme/templates/package/snippets/resources_list.html @@ -1,37 +1,77 @@ -{# +{# Renders a list of resources with icons and view links. - - resources - A list of resources (dicts) to render - pkg - A package dict that the resources belong to. - + + resources - A list of resources to render + pkg - A package object that the resources belong to. + Example: - - {% snippet "package/snippets/resources_list.html", pkg=pkg, resources=pkg.resources %} - + + {% snippet "package/snippets/resources_list.html", pkg=pkg, resources=pkg.resources %} + #} - -
    -

    {{ _('Data and Resources') }}

    - {% block resource_list %} - {% if resources %} -
      - {% block resource_list_inner %} - {% set can_edit = can_edit or h.check_access('package_update', {'id':pkg.id }) %} - {% for resource in resources %} - {% snippet 'package/snippets/resource_item.html', pkg=pkg, res=resource, can_edit=can_edit %} - {% endfor %} - {% endblock %} -
    - {% else %} - {% block resource_list_empty %} - {% if h.check_access('resource_create', {'package_id': pkg['id']}) %} - {% trans url=h.url_for(pkg.type ~ '_resource.new', id=pkg.name) %} -

    This dataset has no data, why not add some?

    - {% endtrans %} - {% else %} -

    {{ _('This dataset has no data') }}

    - {% endif %} - {% endblock %} + + + +
    +
    {{ _('Data and Resources') }}
    + {% set user = c.user %} + {# Added by Francesco Mangiacrapa #10389 #} + {% if not user %} +
    To access the resources you must log in
    {% endif %} - {% endblock %} -
    + {# end #} + {% block resource_list %} + {% if resources %} +
      + {% block resource_list_inner %} + {% for resource in resources %} + {% snippet 'package/snippets/resource_item.html', pkg=pkg, res=resource %} + {% endfor %} + {% endblock %} +
    + {% else %} + {% if h.check_access('resource_create', {'package_id': pkg['id']}) %} + {% trans url=h.url_for(controller='package', action='new_resource', id=pkg.name) %} +

    This dataset has no data, why not add some?

    + {% endtrans %} + {% else %} +

    {{ _('This dataset has no data') }}

    + {% endif %} + {% endif %} + {% endblock %} +
    + \ No newline at end of file diff --git a/ckanext-d4science_theme/ckanext/d4science_theme/templates/snippets/tag_list.html b/ckanext-d4science_theme/ckanext/d4science_theme/templates/snippets/tag_list.html index 77f753e..52c9c8d 100644 --- a/ckanext-d4science_theme/ckanext/d4science_theme/templates/snippets/tag_list.html +++ b/ckanext-d4science_theme/ckanext/d4science_theme/templates/snippets/tag_list.html @@ -13,7 +13,7 @@