Skip to content

Commit

Permalink
issue/51 Added alternative title support (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster authored Jul 15, 2021
1 parent 555f327 commit 7ed6f00
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ The attributes listed below are used in *contentObject.json*, *articles.json*, *
### \_search (object):
Container object for the `keywords` setting

### \title (string):
Alternative title for search result.

#### keywords (array):
A list of search keywords/phrases to be associated with the contentObject/article/block/component. Each item in the array must be a string.
**NOTE**: Keywords are exported with the `grunt translate:export` command. When localising content, use a process that ensures translated keywords are found in the actual translated course content.
Expand All @@ -60,7 +63,7 @@ A list of search keywords/phrases to be associated with the contentObject/articl
No known limitations.

----------------------------
**Version number:** 4.1.0 <a href="https://community.adaptlearning.org/" target="_blank"><img src="https://github.com/adaptlearning/documentation/blob/master/04_wiki_assets/plug-ins/images/adapt-logo-mrgn-lft.jpg" alt="adapt learning logo" align="right"></a>
**Version number:** 4.2.0 <a href="https://community.adaptlearning.org/" target="_blank"><img src="https://github.com/adaptlearning/documentation/blob/master/04_wiki_assets/plug-ins/images/adapt-logo-mrgn-lft.jpg" alt="adapt learning logo" align="right"></a>
**Framework versions:** 5.8+
**Author / maintainer:** Kineo and community with [contributors](https://github.com/cgkineo/adapt-search/graphs/contributors)
**Accessibility support:** WAI AA
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "git",
"url": "git://github.com/cgkineo/adapt-search"
},
"version": "4.1.0",
"version": "4.2.0",
"framework": ">=5.8",
"homepage": "https://github.com/cgkineo/adapt-search",
"issues": "https://github.com/cgkineo/adapt-search/issues/",
Expand Down
1 change: 1 addition & 0 deletions example.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// on each searchable contentObject, article, block or component
"_search": {
"_isEnabled": true,
"title": "Alternative title",
"keywords": [
"sentences which can be used",
"to better enhance the component descriptions",
Expand Down
2 changes: 1 addition & 1 deletion js/searchResultsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class SearchResultsView extends Backbone.View {
* of matching multilanguage words, which are sometimes a single character
*/
const bodyPrettify = new RegExp(`(([^${WORD_CHARACTERS}]*[${WORD_CHARACTERS}]{1}){1,${numberOfPreviewWords * 2}}|.{0,${numberOfPreviewCharacters * 2}})`, 'i');
const title = stripHTMLAndHandlebars(result.model.get('title')) || stripHTMLAndHandlebars(result.model.get('displayTitle')) || 'No title found';
const title = stripHTMLAndHandlebars(result.model.get('_search')?.title || '') || stripHTMLAndHandlebars(result.model.get('title')) || stripHTMLAndHandlebars(result.model.get('displayTitle')) || 'No title found';
const safeTitle = replaceAccents(title);
const body = stripHTMLAndHandlebars(result.model.get('body')) || '';
const hasNoFoundPhrases = (result.foundPhrases.length === 0);
Expand Down
36 changes: 36 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"validators": [],
"help": ""
},
"title": {
"type": "string",
"default": "",
"required": false,
"title": "Alternative title",
"inputType": "Text",
"validators": [],
"translatable": true
},
"keywords": {
"type": "string",
"default": "",
Expand Down Expand Up @@ -57,6 +66,15 @@
"validators": [],
"help": ""
},
"title": {
"type": "string",
"default": "",
"required": false,
"title": "Alternative title",
"inputType": "Text",
"validators": [],
"translatable": true
},
"keywords": {
"type": "string",
"default": "",
Expand Down Expand Up @@ -87,6 +105,15 @@
"validators": [],
"help": ""
},
"title": {
"type": "string",
"default": "",
"required": false,
"title": "Alternative title",
"inputType": "Text",
"validators": [],
"translatable": true
},
"keywords": {
"type": "string",
"default": "",
Expand Down Expand Up @@ -117,6 +144,15 @@
"validators": [],
"help": ""
},
"title": {
"type": "string",
"default": "",
"required": false,
"title": "Alternative title",
"inputType": "Text",
"validators": [],
"translatable": true
},
"keywords": {
"type": "string",
"default": "",
Expand Down

0 comments on commit 7ed6f00

Please sign in to comment.