# HG changeset patch # User ymh # Date 1479587396 -3600 # Node ID 4a0fc5c5f4207c601806c92aacdf880108ca0525 # Parent 76a47f714766d6fe9687631443a32aca08d53b67 put language node names in doc-language component diff -r 76a47f714766 -r 4a0fc5c5f420 cms/app-client/mirage/fixtures/lexvos.js --- a/cms/app-client/mirage/fixtures/lexvos.js Fri Nov 18 14:48:49 2016 +0100 +++ b/cms/app-client/mirage/fixtures/lexvos.js Sat Nov 19 21:29:56 2016 +0100 @@ -40,14 +40,4 @@ { 'id': "http://lexvo.org/id/iso639-3/ita", 'name': "italien" }, { 'id': "http://lexvo.org/id/iso639-3/kdk", 'name': "numee" }, { 'id': "http://lexvo.org/id/iso639-3/nua", 'name': "yuaga" }, - { 'id': "corpus-global", 'name': "global" }, - { 'id': "corpus-regionals", 'name': "langues régionales" }, - { 'id': "corpus-oil", 'name': "langues d'oïl" }, - { 'id': "corpus-creoles", 'name': "les créoles" }, - { 'id': "corpus-non-territorials", 'name': "langues non territoriales" }, - { 'id': "corpus-guyane", 'name': "Guyane" }, - { 'id': "corpus-mayotte", 'name': "Mayotte" }, - { 'id': "corpus-polynesia", 'name': "Polynésie française" }, - { 'id': "corpus-wallis-futuna", 'name': "Wallis et Futuna" }, - { 'id': "corpus-new-caledonia", 'name': "Nouvelle-Calédonie" }, ]; diff -r 76a47f714766 -r 4a0fc5c5f420 common/corpus-common-addon/addon/components/doc-language.js --- a/common/corpus-common-addon/addon/components/doc-language.js Fri Nov 18 14:48:49 2016 +0100 +++ b/common/corpus-common-addon/addon/components/doc-language.js Sat Nov 19 21:29:56 2016 +0100 @@ -3,26 +3,35 @@ import layout from '../templates/components/doc-language'; export default Ember.Component.extend({ - layout: layout, - tagName: "span", + layout: layout, + tagName: 'span', + + lexvoResolver: Ember.inject.service(), - lexvoResolver: Ember.inject.service(), + _resolveLexvoIds: Ember.on('init', Ember.observer('url', function () { + this.get('lexvoResolver').getName(this.get('url')).then(function (str) { + if (!(this.get('isDestroyed') || this.get('isDestroying'))) { + this.set('resolvedName', str); + } + }.bind(this)); + })), - _resolveLexvoIds: Ember.on('init', Ember.observer('url', function() { - this.get('lexvoResolver').getName(this.get('url')).then(function(str) { - if (!(this.get('isDestroyed') || this.get('isDestroying'))) { - this.set('resolvedName', str); - } - }.bind(this)); - })), + code: Ember.computed('url', function () { + const rawLanguage = this.get('url'); + + if (this.get('isLanguageNode')) { + return constants.LANGUAGES_NODES[rawLanguage]; + } - code: Ember.computed('url', function() { - var rawLanguage = this.get('url'); - if(rawLanguage && rawLanguage.startsWith(constants.LEXVO_BASE_URL) ) { - return rawLanguage.substr(constants.LEXVO_BASE_URL.length); - } - return rawLanguage; - }), - isLanguageLink: Ember.computed.match('url', /^http\:\/\//) + if (rawLanguage && rawLanguage.startsWith(constants.LEXVO_BASE_URL)) { + return rawLanguage.substr(constants.LEXVO_BASE_URL.length); + } + + return rawLanguage; + }), + isLanguageLink: Ember.computed.match('url', /^http\:\/\//), + isLanguageNode: Ember.computed('url', function () { + return this.get('url') in constants.LANGUAGES_NODES; + }) }); diff -r 76a47f714766 -r 4a0fc5c5f420 common/corpus-common-addon/addon/templates/components/doc-language.hbs --- a/common/corpus-common-addon/addon/templates/components/doc-language.hbs Fri Nov 18 14:48:49 2016 +0100 +++ b/common/corpus-common-addon/addon/templates/components/doc-language.hbs Sat Nov 19 21:29:56 2016 +0100 @@ -1,4 +1,6 @@ -{{#if isLanguageLink}} +{{#if isLanguageNode}} +{{code}} +{{else if isLanguageLink}} {{#if resolvedName}}{{resolvedName}}{{else}}{{code}}{{/if}} diff -r 76a47f714766 -r 4a0fc5c5f420 common/corpus-common-addon/addon/utils/constants.js --- a/common/corpus-common-addon/addon/utils/constants.js Fri Nov 18 14:48:49 2016 +0100 +++ b/common/corpus-common-addon/addon/utils/constants.js Sat Nov 19 21:29:56 2016 +0100 @@ -2,6 +2,18 @@ export const LEXVO_BASE_URL = 'http://lexvo.org/id/iso639-3/'; export const LANGUAGES_NODE_PREFIX = 'corpus-'; +export const LANGUAGES_NODES = { + 'corpus-global': 'global', + 'corpus-regionals': 'langues régionales', + 'corpus-oil': 'langues d\'oïl', + 'corpus-creoles': 'les créoles', + 'corpus-non-territorials': 'langues non territoriales', + 'corpus-guyane': 'Guyane', + 'corpus-mayotte': 'Mayotte', + 'corpus-polynesia': 'Polynésie française', + 'corpus-wallis-futuna': 'Wallis et Futuna', + 'corpus-new-caledonia': 'Nouvelle-Calédonie' +}; export const VIAF_BASE_URL = 'http://viaf.org/viaf/'; @@ -44,7 +56,8 @@ 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z' ]; export const NOID_CHARS_POS = { - '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, - 'b': 10, 'c': 11, 'd': 12, 'f': 13, 'g': 14, 'h': 15, 'j': 16, 'k': 17, 'm': 18, 'n': 19, - 'p': 20, 'q': 21, 'r': 22, 's': 23, 't': 24, 'v': 25, 'w': 26, 'x': 27, 'z': 28 + 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, + b: 10, c: 11, d: 12, f: 13, g: 14, h: 15, j: 16, k: 17, m: 18, n: 19, + p: 20, q: 21, r: 22, s: 23, t: 24, v: 25, w: 26, x: 27, z: 28 }; +