Skip to content

Commit

Permalink
Record view / Improve support of HTML in abstract
Browse files Browse the repository at this point in the history
When harvesting some ODS portal eg.

```
{"@id":"4284","@type":"simpleurl","owner":["70"],"ownerGroup":[14697],"ownerUser":["70"],"site":{"name":"odwb","uuid":"1f4e3e33-be43-486e-a371-f9fed31d4df1","account":{"use":false,"username":[],"password":[]},"url":"https://www.odwb.be/api/explore/v2.0/catalog/datasets?limit=10&offset=0&timezone=UTC&include_links=false&include_app_metas=false","icon":"blank.png","loopElement":"/datasets","numberOfRecordPath":"/total_count","recordIdPath":"/dataset/dataset_id","pageSizeParam":"limit","pageFromParam":"offset","toISOConversion":"schema:iso19115-3.2018:convert/fromJsonOpenDataSoft"},"content":{"validate":"NOVALIDATION","importxslt":"none","batchEdits":"[]"},"options":{"every":"0 0 0 ? * *","oneRunOnly":false,"overrideUuid":"SKIP","status":"active"},"privileges":[{"@id":"1","operation":[{"@name":"view"},{"@name":"dynamic"},{"@name":"download"}]}],"ifRecordExistAppendPrivileges":false,"info":{"lastRun":"2024-09-09T08:21:08.124161Z","running":false,"result":{"added":"1036","atomicDatasetRecords":"0","badFormat":"0","collectionDatasetRecords":"0","datasetUuidExist":"0","privilegesAppendedOnExistingRecord":"0","doesNotValidate":"0","xpathFilterExcluded":"0","duplicatedResource":"0","fragmentsMatched":"0","fragmentsReturned":"0","fragmentsUnknownSchema":"0","incompatible":"0","recordsBuilt":"0","recordsUpdated":"0","removed":"0","serviceRecords":"0","subtemplatesAdded":"0","subtemplatesRemoved":"0","subtemplatesUpdated":"0","total":"1036","unchanged":"0","unknownSchema":"0","unretrievable":"0","updated":"0","thumbnails":"0","thumbnailsFailed":"0"}}}
```

Some records use HTML in abstract
eg. https://www.odwb.be/explore/dataset/ares-referentiel-des-bassins-enseignement-qualifiant-formation-emploi-efe/information/?disjunctive.te_arrond_adm&disjunctive.te_province&disjunctive.te_region

Linky directive breaks the HTML and should not be used when the text is
HTML.
  • Loading branch information
fxprunayre committed Sep 9, 2024
1 parent 677dc26 commit 49b0b0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2220,6 +2220,7 @@
};
}
]);

module.filter("signInLink", [
"$location",
"$filter",
Expand All @@ -2233,6 +2234,23 @@
};
}
]);

module.filter("isHtml", [
"$location",
"$filter",
function ($location, $filter) {
return function (str) {
var a = new DOMParser().parseFromString(str, "text/html");

for (var c = a.body.childNodes, i = c.length; i--; ) {
if (c[i].nodeType == 1) return true;
}

return false;
};
}
]);

module.filter("getMailDomain", [
function () {
return function (mail) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ <h1 class="gn-break">
data-types="parent"
></div>

<p data-ng-bind-html="(mdView.current.record.resourceAbstract) | linky | newlines"></p>
<p
data-ng-if="mdView.current.record.resourceAbstract | isHtml"
data-ng-bind-html="mdView.current.record.resourceAbstract"
></p>
<p
data-ng-if="!(mdView.current.record.resourceAbstract | isHtml)"
data-ng-bind-html="(mdView.current.record.resourceAbstract) | linky | newlines"
></p>
</div>

0 comments on commit 49b0b0c

Please sign in to comment.