| author | ymh <ymh.work@gmail.com> |
| Thu, 16 Nov 2017 15:44:36 +0100 | |
| changeset 553 | 251df6cb3afa |
| parent 543 | aaaf9b0b09f6 |
| permissions | -rw-r--r-- |
|
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
|
| 543 | 3 |
const CC_LICENCE_URL_REGEXP = /http:\/\/creativecommons\.org\/licenses\/([byndsac-]+)\/([\d\.]+)\//; // eslint-disable-line no-useless-escape |
|
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
const CC_LICENCE_TEXT = { |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
'by': 'Attribution', |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
'by-nd': 'Attribution - Pas de Modification', |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
'by-sa': 'Attribution - Partage dans les Mêmes Conditions', |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
'by-nc': 'Attribution - Pas d’Utilisation Commerciale', |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
'by-nc-nd': 'Attribution - Pas d\'Utilisation Commerciale - Pas de Modification', |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
'by-nc-sa': 'Attribution - Pas d\'Utilisation Commerciale - Partage dans les Mêmes Conditions' |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
}; |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
|
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
export default Ember.Component.extend({ |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
tagName: 'span', |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
code: Ember.computed('matches', function() { |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
return this.get('matches')[1]; |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
}), |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
version: Ember.computed('matches', function() { |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
return this.get('matches')[2]; |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
}), |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
matches: Ember.computed('url', function() { |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
const url = this.get('url'); |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
if(!url) { |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
return [url,'by', '4.0']; |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
} |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
let m = url.match(CC_LICENCE_URL_REGEXP); |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
if(m === null || m.length !== 3) { |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
return [url,'by', '4.0']; |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
} |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
return m; |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
}), |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
text: Ember.computed('code', function() { |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
const code = this.get('code'); |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
return CC_LICENCE_TEXT[code]; |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
}) |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
|
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
}); |