Skip to content

Commit

Permalink
[Backport][Fixes #6977] Images inside resource abstract are not rende…
Browse files Browse the repository at this point in the history
…red correctly in GeoNode (#6978)

[Backport][Fixes #6975] GeoNode client catalogue must use the abstract stripped of HTML tags (#6976)
  • Loading branch information
afabiani committed Mar 18, 2021
1 parent c6bfd80 commit 48fa8a2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 32 deletions.
7 changes: 5 additions & 2 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,11 @@ def __str__(self):
return "{0}".format(self.title)

def _remove_html_tags(self, attribute_str):
pattern = re.compile('<.*?>')
return re.sub(pattern, '', attribute_str)
try:
pattern = re.compile('<.*?>')
return re.sub(pattern, '', attribute_str)
except Exception:
return attribute_str

@property
def raw_abstract(self):
Expand Down
22 changes: 11 additions & 11 deletions geonode/base/templates/base/_resourcebase_info_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

{% if resource.abstract %}
<dt>{% trans "Abstract" %}</dt>
<dd itemprop="description">{{ resource.abstract|safe|escape|urlize|linebreaks|safe|truncatechars:500 }}</dd>
<dd itemprop="description">{{ resource.abstract|safe }}</dd>
{% endif %}

{% if resource.date %}
{% if resource.date_type == 'creation' %}
<dt>{% trans "Creation Date" %}</dt>
{% elif resource.date_type == 'publication' %}
<dt>{% trans "Pubblication Date" %}</dt>
<dt>{% trans "Publication Date" %}</dt>
{% elif resource.date_type == 'revision' %}
<dt>{% trans "Revision Date" %}</dt>
{% else %}
Expand Down Expand Up @@ -158,31 +158,31 @@

{% if resource.maintenance_frequency %}
<dt>{% trans "Maintenance Frequency" %}</dt>
<dd>{{ resource.maintenance_frequency_title }}</dd>
<dd>{{ resource.maintenance_frequency_title|safe }}</dd>
{% endif %}

{% if resource.restriction_code_type or resource.constraints_other %}
<dt>{% trans "Restrictions" %}</dt>
<dd>{% if resource.constraints_other %}
{{ resource.constraints_other }}
{{ resource.constraints_other|safe }}
{% else %}
{{ resource.restriction_code_type }}
{{ resource.restriction_code_type|safe }}
{% endif %}</dd>
{% endif %}

{% if resource.edition %}
<dt>{% trans "Edition" %}</dt>
<dd>{{ resource.edition}}</dd>
<dd>{{ resource.edition }}</dd>
{% endif %}

{% if resource.purpose %}
<dt>{% trans "Purpose" %}</dt>
<dd>{{ resource.purpose|escape|urlize|linebreaks|safe|truncatechars:160 }}</dd>
<dd>{{ resource.purpose|safe }}</dd>
{% endif %}

{% if resource.language %}
<dt>{% trans "Language" %}</dt>
<dd>{{ resource.language_title }}</dd>
<dd>{{ resource.language_title|safe }}</dd>
{% endif %}

{% if resource.temporal_extent_start and resource.temporal_extent_end %}
Expand All @@ -192,17 +192,17 @@

{% if resource.data_quality_statement %}
<dt>{% trans "Data Quality" %}</dt>
<dd>{{ resource.data_quality_statement }}</dd>
<dd>{{ resource.data_quality_statement|safe }}</dd>
{% endif %}

{% if resource.supplemental_information %}
<dt>{% trans "Supplemental Information" %}</dt>
<dd>{{ resource.supplemental_information|truncatechars:160|escape|urlize|linebreaks|safe }}</dd>
<dd>{{ resource.supplemental_information|safe }}</dd>
{% endif %}

{% if resource.spatial_representation_type %}
<dt>{% trans "Spatial Representation Type" %}</dt>
<dd>{{ resource.spatial_representation_type }}</dd>
<dd>{{ resource.spatial_representation_type|safe }}</dd>
{% endif %}

</div>
Expand Down
20 changes: 12 additions & 8 deletions geonode/base/templates/base/_resourcebase_snippet.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<article ng-repeat="item in results" resource_id="{{ item.id }}" ng-cloak class="ng-cloak">
<div class="col-lg-12 item-container">
<div class="col-lg-12 profile-avatar">
<div class="col-lg-12">
<div class="col-lg-4 item-thumb">
<a href="{{ item.detail_url }}">
<img ng-src="{{ item.thumbnail_url }}" />
Expand All @@ -36,33 +36,37 @@ <h4>
<a href="{{ item.detail_url }}">{{ item.title }}</a>
</h4>
</div>
{% endverbatim %}

{% if facet_type == 'layers' %}
<div class="col-xs-2">
<h4>{% endverbatim %}
<h4>
<button
class="btn btn-default btn-xs pull-right"
ng-if="cart"
ng-click="cart.toggleItem(item)"
data-toggle="tooltip"
data-placement="bottom"
title="{% trans "Select" %}"><i ng-class="cart.getFaClass(item.id)" class="fa fa-lg"></i></button>{% verbatim %}
title="{% trans "Select" %}"><i ng-class="cart.getFaClass(item.id)" class="fa fa-lg"></i></button>
</h4>
</div>
{% endif %}
</div>
<em ng-if="item.store_type == 'remoteStore'">
{% endverbatim %}
<span ng-if="item.online == true"><i class="fa fa-power-off text-success"></i> {% trans "Service is" %} {% trans "online" %}</span>
<span ng-if="item.online == false"><i class="fa fa-power-off text-danger"></i> {% trans "Service is" %} {% trans "offline" %}</span>
{% verbatim %}
</em>
{% endverbatim %}
<em ng-if="item.processed == false">
<i class="fa fa-cog fa-spin fa-fw"></i>{% trans "Layer not ready yet. Still finalizing layer ingestion..." %}
</em>
<div class="alert alert-danger" ng-if="item.dirty_state == true">{% trans "SECURITY NOT YET SYNCHRONIZED" %}
{% verbatim %}<a href="{{ item.detail_url }}" class="btn btn-primary btn-block" data-dismiss="modal" ng-click="securityRefreshButton($event)">{% endverbatim %}{% trans "Sync permissions immediately" %}</a>
</div>
<div class="alert alert-warning" ng-if="item.dirty_state == false && item.is_approved == false">{% trans "PENDING APPROVAL" %}</div>
<div class="alert alert-danger" ng-if="item.dirty_state == false && item.is_approved == true && item.is_published == false">{% trans "UNPUBLISHED" %}</div>
{% verbatim %}

<div class="abstract" ng-bind-html="item.abstract | limitTo: 300"></div>
{% verbatim %}
<div class="abstract" ng-bind-html="item.abstract"></div>
<p class="abstract">{{ item.abstract.length > 300 ? '...' : ''}}</p>
<div class="row">
<div class="col-lg-12 item-items">
Expand Down
4 changes: 2 additions & 2 deletions geonode/catalogue/backends/pycsw_local_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'pycsw:AnyText': 'csw_anytext',
'pycsw:Language': 'language',
'pycsw:Title': 'title',
'pycsw:Abstract': 'abstract',
'pycsw:Abstract': 'raw_abstract',
'pycsw:Keywords': 'keyword_csv',
'pycsw:KeywordType': 'keywordstype',
'pycsw:Format': 'spatial_representation_type_string',
Expand Down Expand Up @@ -66,7 +66,7 @@
'pycsw:OperatesOnName': 'operatesoname',
'pycsw:Degree': 'degree',
'pycsw:AccessConstraints': 'restriction_code',
'pycsw:OtherConstraints': 'constraints_other',
'pycsw:OtherConstraints': 'raw_constraints_other',
'pycsw:Classification': 'classification',
'pycsw:ConditionApplyingToAccessAndUse': 'conditionapplyingtoaccessanduse',
'pycsw:Lineage': 'lineage',
Expand Down
12 changes: 6 additions & 6 deletions geonode/catalogue/templates/catalogue/full_metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@
</gmd:CI_Citation>
</gmd:citation>
<gmd:abstract>
<gco:CharacterString>{{layer.abstract}}</gco:CharacterString>
<gco:CharacterString>{{layer.raw_abstract}}</gco:CharacterString>
</gmd:abstract>
<gmd:purpose {% if not layer.purpose %}gco:nilReason="missing"{% endif %}>
{% if layer.purpose %}<gco:CharacterString>{{layer.purpose}}</gco:CharacterString>{% endif %}
<gmd:purpose {% if not layer.raw_purpose %}gco:nilReason="missing"{% endif %}>
{% if layer.raw_purpose %}<gco:CharacterString>{{layer.raw_purpose}}</gco:CharacterString>{% endif %}
</gmd:purpose>
<gmd:status>
<gmd:MD_ProgressCode codeSpace="ISOTC211/19115" codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ProgressCode" codeListValue="completed">completed</gmd:MD_ProgressCode>
Expand Down Expand Up @@ -398,7 +398,7 @@
<gmd:MD_RestrictionCode codeSpace="ISOTC211/19115" codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode" codeListValue="{{layer.restriction_code_type.identifier}}">{{layer.restriction_code_type.identifier}}</gmd:MD_RestrictionCode>
</gmd:useConstraints>
<gmd:otherConstraints>
<gco:CharacterString>{{layer.constraints_other}}</gco:CharacterString>
<gco:CharacterString>{{layer.raw_constraints_other}}</gco:CharacterString>
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
Expand Down Expand Up @@ -453,7 +453,7 @@
</gmd:extent>
{% endif %}
<gmd:supplementalInformation>
<gco:CharacterString>{{ layer.supplemental_information }}</gco:CharacterString>
<gco:CharacterString>{{ layer.raw_supplemental_information }}</gco:CharacterString>
</gmd:supplementalInformation>
</gmd:MD_DataIdentification>
</gmd:identificationInfo>
Expand Down Expand Up @@ -543,7 +543,7 @@
</gmd:scope>
<gmd:lineage>
<gmd:LI_Lineage>
<gmd:statement {% if not layer.data_quality_statement %}gco:nilReason="missing"/>{% else %}><gco:CharacterString>{{layer.data_quality_statement}}</gco:CharacterString></gmd:statement>{% endif %}
<gmd:statement {% if not layer.raw_data_quality_statement %}gco:nilReason="missing"/>{% else %}><gco:CharacterString>{{layer.raw_data_quality_statement}}</gco:CharacterString></gmd:statement>{% endif %}
</gmd:LI_Lineage>
</gmd:lineage>
</gmd:DQ_DataQuality>
Expand Down
6 changes: 3 additions & 3 deletions geonode/templates/metadata_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h2 class="page-title">{% trans "Metadata" %} : {{ resource.title }}</h2>

{% if resource.abstract %}
<dt>{% trans "Abstract" %}</dt>
<dd>{{ resource.abstract|safe|escape|urlize|linebreaks|safe|truncatechars:1000 }}</dd>
<dd>{{ resource.abstract|safe }}</dd>
{% endif %}

</dl>
Expand Down Expand Up @@ -236,7 +236,7 @@ <h2 class="page-title">{% trans "Metadata" %} : {{ resource.title }}</h2>

{% if resource.purpose %}
<dt>{% trans "Purpose" %}</dt>
<dd>{{ resource.purpose|safe|escape|urlize|linebreaks|safe|truncatechars:160 }}</dd>
<dd>{{ resource.purpose|safe }}</dd>
{% endif %}

{% if resource.language %}
Expand All @@ -256,7 +256,7 @@ <h2 class="page-title">{% trans "Metadata" %} : {{ resource.title }}</h2>

{% if resource.supplemental_information %}
<dt>{% trans "Supplemental Information" %}</dt>
<dd>{{ resource.supplemental_information|safe|truncatechars:160|escape|urlize|linebreaks|safe }}</dd>
<dd>{{ resource.supplemental_information|safe }}</dd>
{% endif %}

{% if resource.spatial_representation_type %}
Expand Down

0 comments on commit 48fa8a2

Please sign in to comment.