Skip to content

Commit

Permalink
Merge pull request #27 from o19s/feature-26-add-url-links
Browse files Browse the repository at this point in the history
Convert snippets that start with http into anchor links in search result pane
  • Loading branch information
epugh authored Nov 25, 2019
2 parents 10ad4d6 + cefbd21 commit 639c79b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/javascripts/controllers/searchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,8 @@ angular.module('QuepidApp')
$scope.isJSONObject = function(value) {
return typeof value === 'object' && value instanceof Array !== true;
};
$scope.isUrl = function(value) {
return ( /http/.test(value));
};
}
]);
10 changes: 9 additions & 1 deletion app/assets/templates/views/searchResult.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,24 @@
<span
ng-if="isJSONObject(fieldValue)"
>
<!-- output JSON blob -->
<json-explorer
json-data="fieldValue"
collapsed="false">
</json-explorer>
</span>

<span
ng-if="isUrl(fieldValue)">
<!-- Format a HREF link. Use the original value, not the html escaped snippet. -->
<a ng-href="{{ doc.doc[fieldName] }}" target="_blank">{{ doc.doc[fieldName] }}</a>
</span>

<span
ng-bind-html="fieldValue"
ng-if="!isJSONObject(fieldValue)"
ng-if="!isJSONObject(fieldValue) && !isUrl(fieldValue)"
>
<!-- Normal display of a snippet -->
</span>
</li>

Expand Down

0 comments on commit 639c79b

Please sign in to comment.