extract common functionalities to common module. First application to lexvo name resolving
--- a/.hgignore Mon Feb 22 18:06:39 2016 +0100
+++ b/.hgignore Tue Feb 23 17:47:57 2016 +0100
@@ -44,3 +44,13 @@
^build/root
^build/.*\.rpm
^dev2/
+^common/corpus-common-addon/dist
+^common/corpus-common-addon/tmp
+^common/corpus-common-addon/node_modules
+^common/corpus-common-addon/bower_components
+^common/corpus-common-addon/.sass-cache
+^common/corpus-common-addon/connect.lock
+^common/corpus-common-addon/coverage/*
+^common/corpus-common-addon/libpeerconnection.log
+^common/corpus-common-addonnpm-debug.log
+^common/corpus-common-addontestem.log
--- a/cms/app-client/app/mirage/config.js Mon Feb 22 18:06:39 2016 +0100
+++ b/cms/app-client/app/mirage/config.js Tue Feb 23 17:47:57 2016 +0100
@@ -1,5 +1,6 @@
import ENV from 'app-client/config/environment';
import _ from 'lodash/lodash';
+import * as constants from 'corpus-common-addon/utils/constants';
export default function() {
@@ -18,7 +19,6 @@
this.get('/documents');
this.get('/documents/:id', function(db, request) {
var docId = decodeURIComponent(request.params.id);
- console.log("DOC ID", docId);
return {
'document': db.documents.find(docId)
@@ -33,6 +33,24 @@
return res;
});
+ this.get('/lexvo/:ids', function(db, request) {
+ var langIds = decodeURIComponent(request.params.ids);
+ var resMap = _.reduce(langIds.split(','), function(res, id) {
+ var fullId = id;
+ if(!_.startsWith(fullId, constants.LEXVO_BASE_URL)) {
+ fullId = constants.LEXVO_BASE_URL + id;
+ }
+ var lexvoRes = db.lexvo.find(fullId);
+ res[id] = lexvoRes?lexvoRes.name:null;
+ return res;
+ }, {});
+
+ return {
+ 'lexvoids': resMap
+ };
+
+ });
+
/*
Route shorthand cheatsheet
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/mirage/fixtures/lexvo.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,43 @@
+export default [
+ { 'id': "http://lexvo.org/id/iso639-3/fra", 'name': "français" },
+ { 'id': "http://lexvo.org/id/iso639-3/gsw", 'name': "alémanique" },
+ { 'id': "http://lexvo.org/id/iso639-3/oci", 'name': "occitan" },
+ { 'id': "http://lexvo.org/id/iso639-3/bre", 'name': "breton" },
+ { 'id': "http://lexvo.org/id/iso639-3/djk", 'name': "ndjuka" },
+ { 'id': "http://lexvo.org/id/iso639-3/lad", 'name': "ladino" },
+ { 'id': "http://lexvo.org/id/iso639-3/pcd", 'name': "picard" },
+ { 'id': "http://lexvo.org/id/iso639-3/frp", 'name': "arpitan" },
+ { 'id': "http://lexvo.org/id/iso639-3/und", 'name': "indéterminé" },
+ { 'id': "http://lexvo.org/id/iso639-3/cos", 'name': "corse" },
+ { 'id': "http://lexvo.org/id/iso639-3/fsl", 'name': "langue des signes française" },
+ { 'id': "http://lexvo.org/id/iso639-3/rcf", 'name': "créole réunionnais" },
+ { 'id': "http://lexvo.org/id/iso639-3/fud", 'name': "futunien" },
+ { 'id': "http://lexvo.org/id/iso639-3/wls", 'name': "wallisien" },
+ { 'id': "http://lexvo.org/id/iso639-3/lsy", 'name': "mauritian sign language" },
+ { 'id': "http://lexvo.org/id/iso639-3/gcf", 'name': "guadeloupean creole french" },
+ { 'id': "http://lexvo.org/id/iso639-3/nem", 'name': "nemi" },
+ { 'id': "http://lexvo.org/id/iso639-3/uve", 'name': "fagauvea" },
+ { 'id': "http://lexvo.org/id/iso639-3/ane", 'name': "xârâcùù" },
+ { 'id': "http://lexvo.org/id/iso639-3/axx", 'name': "xaragure" },
+ { 'id': "http://lexvo.org/id/iso639-3/cam", 'name': "cèmuhî" },
+ { 'id': "http://lexvo.org/id/iso639-3/eng", 'name': "anglais" },
+ { 'id': "http://lexvo.org/id/iso639-3/iai", 'name': "iaai" },
+ { 'id': "http://lexvo.org/id/iso639-3/kab", 'name': "kabyle" },
+ { 'id': "http://lexvo.org/id/iso639-3/plu", 'name': "palikur" },
+ { 'id': "http://lexvo.org/id/iso639-3/bwa", 'name': "bwatoo" },
+ { 'id': "http://lexvo.org/id/iso639-3/car", 'name': "karib" },
+ { 'id': "http://lexvo.org/id/iso639-3/gcr", 'name': "créole guyanais" },
+ { 'id': "http://lexvo.org/id/iso639-3/nee", 'name': "nêlêmwa-nixumwak" },
+ { 'id': "http://lexvo.org/id/iso639-3/ell", 'name': "grec" },
+ { 'id': "http://lexvo.org/id/iso639-3/deu", 'name': "allemand" },
+ { 'id': "http://lexvo.org/id/iso639-3/dhv", 'name': "drehu" },
+ { 'id': "http://lexvo.org/id/iso639-3/nen", 'name': "nengone" },
+ { 'id': "http://lexvo.org/id/iso639-3/spa", 'name': "espagnol" },
+ { 'id': "http://lexvo.org/id/iso639-3/srn", 'name': "sranan" },
+ { 'id': "http://lexvo.org/id/iso639-3/swb", 'name': "mahorais" },
+ { 'id': "http://lexvo.org/id/iso639-3/tur", 'name': "turc" },
+ { 'id': "http://lexvo.org/id/iso639-3/aji", 'name': "ajië" },
+ { '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" }
+];
--- a/cms/app-client/app/templates/application.hbs Mon Feb 22 18:06:39 2016 +0100
+++ b/cms/app-client/app/templates/application.hbs Tue Feb 23 17:47:57 2016 +0100
@@ -19,7 +19,7 @@
</div>
<div class="dialog-body">
<p><b>Titre </b>{{modalItem.title}}</p>
- <p><b>Langue </b>{{modalItem.language}}</p>
+ <p><b>Langue </b>{{doc-language language=modalItem.language}}</p>
<p><b>Enregistré le </b>{{modalItem.modified}}</p>
<p><b>Interviewer </b>{{modalItem.publishers}}</p>
<p><b>Description </b>{{modalItem.description}}</p>
--- a/cms/app-client/app/templates/player.hbs Mon Feb 22 18:06:39 2016 +0100
+++ b/cms/app-client/app/templates/player.hbs Tue Feb 23 17:47:57 2016 +0100
@@ -3,5 +3,5 @@
{{player-component action="changeDocument" document=currentItem}}
<p><strong>{{ currentItem.title }}</strong></p>
- <p>{{ currentItem.language }}</p>
+ <p>{{doc-language language=currentItem.language}}</p>
</div>
--- a/cms/app-client/app/templates/results.hbs Mon Feb 22 18:06:39 2016 +0100
+++ b/cms/app-client/app/templates/results.hbs Tue Feb 23 17:47:57 2016 +0100
@@ -26,7 +26,7 @@
<span class="playing-indicator fa fa-play-circle fa-lg fa-fw pull-right" {{action 'play' item}}></span>
<strong>{{ item.title }}</strong>
<div class="description">
- {{item.language}}
+ {{doc-language language=item.language}}
</div>
<div class="hidden-elt">
<button class="pull-right" {{action 'toggleModal' item}}>Details</button>
--- a/cms/app-client/app/templates/tabs/detail.hbs Mon Feb 22 18:06:39 2016 +0100
+++ b/cms/app-client/app/templates/tabs/detail.hbs Tue Feb 23 17:47:57 2016 +0100
@@ -4,7 +4,7 @@
</div>
<div class="notice-body">
<p><b>Titre </b>{{model.title}}</p>
- <p><b>Langue </b>{{model.language}}</p>
+ <p><b>Langue </b>{{doc-language language=model.language}}</p>
<p><b>Enregistré le </b>{{model.modified}}</p>
<p><b>Interviewer </b>{{model.publishers}}</p>
<p><b>Description </b>{{model.description}}</p>
--- a/cms/app-client/bower.json Mon Feb 22 18:06:39 2016 +0100
+++ b/cms/app-client/bower.json Tue Feb 23 17:47:57 2016 +0100
@@ -12,7 +12,8 @@
"font-awesome": "~4.4.0",
"pretender": "~0.10.1",
"lodash": "~3.7.0",
- "Faker": "~3.0.0"
+ "Faker": "~3.0.0",
+ "store": "https://github.com/marcuswestin/store.js.git#v1.3.20"
},
"resolutions": {
"jquery": "^2.2"
--- a/cms/app-client/package.json Mon Feb 22 18:06:39 2016 +0100
+++ b/cms/app-client/package.json Tue Feb 23 17:47:57 2016 +0100
@@ -24,6 +24,7 @@
"broccoli-funnel": "^1.0.1",
"broccoli-merge-trees": "^1.1.0",
"broccoli-static-compiler": "^0.2.2",
+ "corpus-common-addon": "file:../../common/corpus-common-addon",
"ember-ajax": "0.7.1",
"ember-cli": "2.3.0",
"ember-cli-app-version": "^1.0.0",
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/.bowerrc Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,4 @@
+{
+ "directory": "bower_components",
+ "analytics": false
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/.editorconfig Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,34 @@
+# EditorConfig helps developers define and maintain consistent
+# coding styles between different editors and IDEs
+# editorconfig.org
+
+root = true
+
+
+[*]
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+indent_style = space
+indent_size = 2
+
+[*.js]
+indent_style = space
+indent_size = 2
+
+[*.hbs]
+insert_final_newline = false
+indent_style = space
+indent_size = 2
+
+[*.css]
+indent_style = space
+indent_size = 2
+
+[*.html]
+indent_style = space
+indent_size = 2
+
+[*.{diff,md}]
+trim_trailing_whitespace = false
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/.ember-cli Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,9 @@
+{
+ /**
+ Ember CLI sends analytics information by default. The data is completely
+ anonymous, but there are times when you might want to disable this behavior.
+
+ Setting `disableAnalytics` to true will prevent any data from being sent.
+ */
+ "disableAnalytics": false
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/.jshintrc Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,32 @@
+{
+ "predef": [
+ "document",
+ "window",
+ "-Promise"
+ ],
+ "browser": true,
+ "boss": true,
+ "curly": true,
+ "debug": false,
+ "devel": true,
+ "eqeqeq": true,
+ "evil": true,
+ "forin": false,
+ "immed": false,
+ "laxbreak": false,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": false,
+ "nomen": false,
+ "onevar": false,
+ "plusplus": false,
+ "regexp": false,
+ "undef": true,
+ "sub": true,
+ "strict": false,
+ "white": false,
+ "eqnull": true,
+ "esnext": true,
+ "unused": true
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/.npmignore Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,16 @@
+/bower_components
+/config/ember-try.js
+/dist
+/tests
+/tmp
+**/.gitkeep
+.bowerrc
+.editorconfig
+.ember-cli
+.gitignore
+.jshintrc
+.watchmanconfig
+.travis.yml
+bower.json
+ember-cli-build.js
+testem.json
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/.travis.yml Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,34 @@
+---
+language: node_js
+node_js:
+ - "0.12"
+
+sudo: false
+
+cache:
+ directories:
+ - node_modules
+
+env:
+ - EMBER_TRY_SCENARIO=default
+ - EMBER_TRY_SCENARIO=ember-release
+ - EMBER_TRY_SCENARIO=ember-beta
+ - EMBER_TRY_SCENARIO=ember-canary
+
+matrix:
+ fast_finish: true
+ allow_failures:
+ - env: EMBER_TRY_SCENARIO=ember-canary
+
+before_install:
+ - export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
+ - "npm config set spin false"
+ - "npm install -g npm@^2"
+
+install:
+ - npm install -g bower
+ - npm install
+ - bower install
+
+script:
+ - ember try $EMBER_TRY_SCENARIO test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/.watchmanconfig Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,3 @@
+{
+ "ignore_dirs": ["tmp", "dist"]
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/LICENSE.md Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,9 @@
+The MIT License (MIT)
+
+Copyright (c) 2016
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/README.md Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,26 @@
+# Corpus-common-addon
+
+This README outlines the details of collaborating on this Ember addon.
+
+## Installation
+
+* `git clone` this repository
+* `npm install`
+* `bower install`
+
+## Running
+
+* `ember server`
+* Visit your app at http://localhost:4200.
+
+## Running Tests
+
+* `npm test` (Runs `ember try:testall` to test your addon against multiple Ember versions)
+* `ember test`
+* `ember test --server`
+
+## Building
+
+* `ember build`
+
+For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/addon/utils/constants.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,4 @@
+
+
+export const LEXVO_BASE_URL = "http://lexvo.org/id/iso639-3/";
+export const DEFAULT_STORE_EXP = 3600000;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/addon/utils/store.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,19 @@
+import store from 'store';
+import * as constants from 'corpus-common-addon/utils/constants';
+
+export default {
+ set: function(key, val, exp) {
+ var expiration = exp;
+ if(typeof exp === 'undefined') {
+ expiration = constants.DEFAULT_STORE_EXP;
+ }
+ store.set(key, { val:val, exp:expiration, time:new Date().getTime() });
+ return val;
+ },
+ get: function(key) {
+ var info = store.get(key)
+ if (!info) { return null }
+ if (new Date().getTime() - info.time > info.exp) { return null }
+ return info.val
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/app/components/doc-language.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,24 @@
+import Ember from 'ember';
+import * as constants from 'corpus-common-addon/utils/constants'
+
+export default Ember.Component.extend({
+ tagName: "span",
+
+ lexvoResolver: Ember.inject.service(),
+
+ _resolveLexvoIds: Ember.on('init', Ember.observer('language', function() {
+ this.get('lexvoResolver').getName(this.get('language')).then(function(str) {
+ this.set('resolvedName', str);
+ }.bind(this));
+ })),
+
+ code: Ember.computed('language', function() {
+ var rawLanguage = this.get('language');
+ if(rawLanguage && rawLanguage.startsWith(constants.LEXVO_BASE_URL) ) {
+ return rawLanguage.substr(constants.LEXVO_BASE_URL.length);
+ }
+ return rawLanguage;
+ }),
+ isLanguageLink: Ember.computed.match('language', /^http\:\/\//)
+
+});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/app/services/lexvo-resolver.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,60 @@
+import Ember from 'ember';
+import store from 'corpus-common-addon/utils/store';
+import * as constants from 'corpus-common-addon/utils/constants'
+
+export default Ember.Service.extend({
+ env: function() {
+ return Ember.getOwner(this).resolveRegistration('config:environment')
+ },
+ _getStoreKey: function(id) {
+ return 'lexvo:'+id;
+ },
+ getName: function(id) {
+
+ if(!id) {
+ return new Ember.RSVP.Promise(function(resolve/*, reject*/) {
+ resolve("");
+ });
+ }
+
+ var lexvoId = id;
+ if(id.startsWith(constants.LEXVO_BASE_URL)) {
+ lexvoId = id.slice(constants.LEXVO_BASE_URL.length);
+ }
+ var namePromise = null;
+
+ var storeKey = this._getStoreKey(id);
+ var name = store.get(storeKey);
+
+ if(!name) {
+ //TODO: handle error !!!
+ namePromise = this.queryName(lexvoId)
+ .then( function(response) {
+ return store.set(storeKey, response);
+ });
+ }
+ else {
+ namePromise = new Ember.RSVP.Promise(function(resolve/*, reject*/) {
+ resolve(name);
+ });
+ }
+ return namePromise;
+ },
+ // make the query for the name.
+ // return a Promise
+ queryName: function(id) {
+ return new Ember.RSVP.Promise(function(resolve, reject) {
+ Ember.$.ajax({
+ //TODO Configuration ?
+ url: this.env().baseURL.replace(/\/$/,"") + "/api/v1/lexvo/"+id,
+ success: function(lexvoDoc) {
+ var names = lexvoDoc.lexvoids;
+ resolve((id in names)?names[id]:null);
+ },
+ error: function(req, status, error) {
+ reject(status + ":" + error);
+ }
+ });
+ }.bind(this));
+ }
+});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/app/templates/components/doc-language.hbs Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,7 @@
+{{#if isLanguageLink}}
+<a href="{{language}}" target="_blank" title={{resolvedName}} class="bo-doc-ref-link">
+ {{#if resolvedName}}{{resolvedName}}{{else}}{{code}}{{/if}}
+</a>
+{{else}}
+{{#if resolvedName}}{{resolvedName}}{{else}}{{code}}{{/if}}
+{{/if}}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/blueprints/.jshintrc Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,6 @@
+{
+ "predef": [
+ "console"
+ ],
+ "strict": false
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/blueprints/corpus-common-addon/index.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,15 @@
+/*jshint node:true*/
+module.exports = {
+ description: '',
+
+ // locals: function(options) {
+ // // Return custom template variables here.
+ // return {
+ // foo: options.entity.options.foo
+ // };
+ // }
+ afterInstall: function(options) {
+ return this.addBowerPackageToProject("store", "https://github.com/marcuswestin/store.js.git#v1.3.20");
+ // Perform extra work here.
+ }
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/bower.json Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,12 @@
+{
+ "name": "corpus-common-addon",
+ "dependencies": {
+ "ember": "~2.3.1",
+ "ember-cli-shims": "0.1.0",
+ "ember-cli-test-loader": "0.2.2",
+ "ember-qunit-notifications": "0.1.0"
+ },
+ "devDependencies": {
+ "store": "https://github.com/marcuswestin/store.js.git#v1.3.20"
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/config/ember-try.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,44 @@
+/*jshint node:true*/
+module.exports = {
+ scenarios: [
+ {
+ name: 'default',
+ bower: {
+ dependencies: { }
+ }
+ },
+ {
+ name: 'ember-release',
+ bower: {
+ dependencies: {
+ 'ember': 'components/ember#release'
+ },
+ resolutions: {
+ 'ember': 'release'
+ }
+ }
+ },
+ {
+ name: 'ember-beta',
+ bower: {
+ dependencies: {
+ 'ember': 'components/ember#beta'
+ },
+ resolutions: {
+ 'ember': 'beta'
+ }
+ }
+ },
+ {
+ name: 'ember-canary',
+ bower: {
+ dependencies: {
+ 'ember': 'components/ember#canary'
+ },
+ resolutions: {
+ 'ember': 'canary'
+ }
+ }
+ }
+ ]
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/config/environment.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,6 @@
+/*jshint node:true*/
+'use strict';
+
+module.exports = function(/* environment, appConfig */) {
+ return { };
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/ember-cli-build.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,27 @@
+/*jshint node:true*/
+/* global require, module */
+var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
+
+module.exports = function(defaults) {
+ var app = new EmberAddon(defaults, {
+ // Add options here
+ });
+
+ /*
+ This build file specifies the options for the dummy test app of this
+ addon, located in `/tests/dummy`
+ This build file does *not* influence how the addon or the app using it
+ behave. You most likely want to be modifying `./index.js` or app's build file
+ */
+ app.import({
+ development: 'bower_components/store/store.js',
+ production: 'bower_components/store/store.min.js'
+ });
+ app.import('vendor/shims/store.js', {
+ exports: {
+ 'store': ['default']
+ }
+ });
+
+ return app.toTree();
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/index.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,20 @@
+/* jshint node: true */
+'use strict';
+
+module.exports = {
+ name: 'corpus-common-addon',
+
+ included: function(app) {
+ this._super.included(app);
+
+ app.import({
+ development: app.bowerDirectory + '/store/store.js',
+ production: app.bowerDirectory + '/store/store.min.js'
+ });
+ app.import('vendor/shims/store.js', {
+ exports: {
+ 'store': ['default']
+ }
+ });
+ }
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/package.json Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,52 @@
+{
+ "name": "corpus-common-addon",
+ "version": "0.0.2",
+ "description": "Common features between cms and bo.",
+ "directories": {
+ "doc": "doc",
+ "test": "tests"
+ },
+ "scripts": {
+ "build": "ember build",
+ "start": "ember server",
+ "test": "ember try:testall"
+ },
+ "repository": "",
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "author": "",
+ "license": "MIT",
+ "devDependencies": {
+ "bower": "^1.7.6",
+ "broccoli-asset-rev": "^2.2.0",
+ "ember-ajax": "0.7.1",
+ "ember-cli": "2.3.0",
+ "ember-cli-app-version": "^1.0.0",
+ "ember-cli-dependency-checker": "^1.2.0",
+ "ember-cli-htmlbars": "^1.0.1",
+ "ember-cli-htmlbars-inline-precompile": "^0.3.1",
+ "ember-cli-inject-live-reload": "^1.3.1",
+ "ember-cli-qunit": "^1.2.1",
+ "ember-cli-release": "0.2.8",
+ "ember-cli-sri": "^2.0.0",
+ "ember-cli-uglify": "^1.2.0",
+ "ember-data": "^2.3.0",
+ "ember-disable-prototype-extensions": "^1.1.0",
+ "ember-disable-proxy-controllers": "^1.0.1",
+ "ember-export-application-global": "^1.0.4",
+ "ember-load-initializers": "^0.5.0",
+ "ember-resolver": "^2.0.3",
+ "ember-try": "^0.1.2",
+ "loader.js": "^4.0.0"
+ },
+ "keywords": [
+ "ember-addon"
+ ],
+ "dependencies": {
+ "ember-cli-babel": "^5.1.5"
+ },
+ "ember-addon": {
+ "configPath": "tests/dummy/config"
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/testem.json Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,12 @@
+{
+ "framework": "qunit",
+ "test_page": "tests/index.html?hidepassed",
+ "disable_watching": true,
+ "launch_in_ci": [
+ "PhantomJS"
+ ],
+ "launch_in_dev": [
+ "PhantomJS",
+ "Chrome"
+ ]
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/.jshintrc Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,52 @@
+{
+ "predef": [
+ "document",
+ "window",
+ "location",
+ "setTimeout",
+ "$",
+ "-Promise",
+ "define",
+ "console",
+ "visit",
+ "exists",
+ "fillIn",
+ "click",
+ "keyEvent",
+ "triggerEvent",
+ "find",
+ "findWithAssert",
+ "wait",
+ "DS",
+ "andThen",
+ "currentURL",
+ "currentPath",
+ "currentRouteName"
+ ],
+ "node": false,
+ "browser": false,
+ "boss": true,
+ "curly": true,
+ "debug": false,
+ "devel": false,
+ "eqeqeq": true,
+ "evil": true,
+ "forin": false,
+ "immed": false,
+ "laxbreak": false,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": false,
+ "nomen": false,
+ "onevar": false,
+ "plusplus": false,
+ "regexp": false,
+ "undef": true,
+ "sub": true,
+ "strict": false,
+ "white": false,
+ "eqnull": true,
+ "esnext": true,
+ "unused": true
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/dummy/app/app.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,18 @@
+import Ember from 'ember';
+import Resolver from './resolver';
+import loadInitializers from 'ember-load-initializers';
+import config from './config/environment';
+
+let App;
+
+Ember.MODEL_FACTORY_INJECTIONS = true;
+
+App = Ember.Application.extend({
+ modulePrefix: config.modulePrefix,
+ podModulePrefix: config.podModulePrefix,
+ Resolver
+});
+
+loadInitializers(App, config.modulePrefix);
+
+export default App;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/dummy/app/index.html Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <title>Dummy</title>
+ <meta name="description" content="">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+
+ {{content-for "head"}}
+
+ <link rel="stylesheet" href="assets/vendor.css">
+ <link rel="stylesheet" href="assets/dummy.css">
+
+ {{content-for "head-footer"}}
+ </head>
+ <body>
+ {{content-for "body"}}
+
+ <script src="assets/vendor.js"></script>
+ <script src="assets/dummy.js"></script>
+
+ {{content-for "body-footer"}}
+ </body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/dummy/app/resolver.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,3 @@
+import Resolver from 'ember-resolver';
+
+export default Resolver;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/dummy/app/router.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,11 @@
+import Ember from 'ember';
+import config from './config/environment';
+
+const Router = Ember.Router.extend({
+ location: config.locationType
+});
+
+Router.map(function() {
+});
+
+export default Router;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/dummy/app/templates/application.hbs Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,3 @@
+<h2 id="title">Welcome to Ember</h2>
+
+{{outlet}}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/dummy/config/environment.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,47 @@
+/* jshint node: true */
+
+module.exports = function(environment) {
+ var ENV = {
+ modulePrefix: 'dummy',
+ environment: environment,
+ baseURL: '/',
+ locationType: 'auto',
+ EmberENV: {
+ FEATURES: {
+ // Here you can enable experimental features on an ember canary build
+ // e.g. 'with-controller': true
+ }
+ },
+
+ APP: {
+ // Here you can pass flags/options to your application instance
+ // when it is created
+ }
+ };
+
+ if (environment === 'development') {
+ // ENV.APP.LOG_RESOLVER = true;
+ // ENV.APP.LOG_ACTIVE_GENERATION = true;
+ // ENV.APP.LOG_TRANSITIONS = true;
+ // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
+ // ENV.APP.LOG_VIEW_LOOKUPS = true;
+ }
+
+ if (environment === 'test') {
+ // Testem prefers this...
+ ENV.baseURL = '/';
+ ENV.locationType = 'none';
+
+ // keep test console output quieter
+ ENV.APP.LOG_ACTIVE_GENERATION = false;
+ ENV.APP.LOG_VIEW_LOOKUPS = false;
+
+ ENV.APP.rootElement = '#ember-testing';
+ }
+
+ if (environment === 'production') {
+
+ }
+
+ return ENV;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/dummy/public/crossdomain.xml Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
+<cross-domain-policy>
+ <!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
+
+ <!-- Most restrictive policy: -->
+ <site-control permitted-cross-domain-policies="none"/>
+
+ <!-- Least restrictive policy: -->
+ <!--
+ <site-control permitted-cross-domain-policies="all"/>
+ <allow-access-from domain="*" to-ports="*" secure="false"/>
+ <allow-http-request-headers-from domain="*" headers="*" secure="false"/>
+ -->
+</cross-domain-policy>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/dummy/public/robots.txt Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,3 @@
+# http://www.robotstxt.org
+User-agent: *
+Disallow:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/helpers/destroy-app.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,5 @@
+import Ember from 'ember';
+
+export default function destroyApp(application) {
+ Ember.run(application, 'destroy');
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/helpers/module-for-acceptance.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,23 @@
+import { module } from 'qunit';
+import startApp from '../helpers/start-app';
+import destroyApp from '../helpers/destroy-app';
+
+export default function(name, options = {}) {
+ module(name, {
+ beforeEach() {
+ this.application = startApp();
+
+ if (options.beforeEach) {
+ options.beforeEach.apply(this, arguments);
+ }
+ },
+
+ afterEach() {
+ destroyApp(this.application);
+
+ if (options.afterEach) {
+ options.afterEach.apply(this, arguments);
+ }
+ }
+ });
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/helpers/resolver.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,11 @@
+import Resolver from '../../resolver';
+import config from '../../config/environment';
+
+const resolver = Resolver.create();
+
+resolver.namespace = {
+ modulePrefix: config.modulePrefix,
+ podModulePrefix: config.podModulePrefix
+};
+
+export default resolver;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/helpers/start-app.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,18 @@
+import Ember from 'ember';
+import Application from '../../app';
+import config from '../../config/environment';
+
+export default function startApp(attrs) {
+ let application;
+
+ let attributes = Ember.merge({}, config.APP);
+ attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
+
+ Ember.run(() => {
+ application = Application.create(attributes);
+ application.setupForTesting();
+ application.injectTestHelpers();
+ });
+
+ return application;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/index.html Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <title>Dummy Tests</title>
+ <meta name="description" content="">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+
+ {{content-for "head"}}
+ {{content-for "test-head"}}
+
+ <link rel="stylesheet" href="assets/vendor.css">
+ <link rel="stylesheet" href="assets/dummy.css">
+ <link rel="stylesheet" href="assets/test-support.css">
+
+ {{content-for "head-footer"}}
+ {{content-for "test-head-footer"}}
+ </head>
+ <body>
+ {{content-for "body"}}
+ {{content-for "test-body"}}
+
+ <script src="testem.js" integrity=""></script>
+ <script src="assets/vendor.js"></script>
+ <script src="assets/test-support.js"></script>
+ <script src="assets/dummy.js"></script>
+ <script src="assets/tests.js"></script>
+ <script src="assets/test-loader.js"></script>
+
+ {{content-for "body-footer"}}
+ {{content-for "test-body-footer"}}
+ </body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/tests/test-helper.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,6 @@
+import resolver from './helpers/resolver';
+import {
+ setResolver
+} from 'ember-qunit';
+
+setResolver(resolver);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/corpus-common-addon/vendor/shims/store.js Tue Feb 23 17:47:57 2016 +0100
@@ -0,0 +1,9 @@
+(function() {
+ function vendorModule() {
+ 'use strict';
+
+ return { 'default': self['store'] };
+ }
+
+ define('store', [], vendorModule);
+})();
--- a/server/bo_client/app/pods/components/bo-doc-language/component.js Mon Feb 22 18:06:39 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-import Ember from 'ember';
-
-export default Ember.Component.extend({
- tagName: "span",
-
- lexvoResolver: Ember.inject.service(),
-
- _resolveLexvoIds: Ember.on('init', Ember.observer('language', function() {
- this.get('lexvoResolver').getName(this.get('language')).then(function(str) {
- this.set('resolvedName', str);
- }.bind(this));
- })),
-
- code: Ember.computed('language', function() {
- var rawLanguage = this.get('language');
- if(rawLanguage && rawLanguage.startsWith(this.get('constants').LEXVO_BASE_URL) ) {
- return rawLanguage.substr(this.get('constants').LEXVO_BASE_URL.length);
- }
- return rawLanguage;
- }),
- isLanguageLink: Ember.computed.match('language', /^http\:\/\//)
-
-});
--- a/server/bo_client/app/pods/components/bo-doc-language/template.hbs Mon Feb 22 18:06:39 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-{{#if isLanguageLink}}
-<a href="{{language}}" target="_blank" title={{resolvedName}} class="bo-doc-ref-link">
- {{#if resolvedName}}{{resolvedName}}{{else}}{{code}}{{/if}}
-</a>
-{{else}}
-{{#if resolvedName}}{{resolvedName}}{{else}}{{code}}{{/if}}
-{{/if}}
--- a/server/bo_client/app/pods/components/bo-doc-viaf-autocomplete/template.hbs.old Mon Feb 22 18:06:39 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-{{aupac-typeahead action=(action 'setViafId')
- class=(if inputclass inputclass)
- source=viafSource
- placeholder=(if placeholder placeholder)
- display='value'
- async=true
- hint=false
- suggestionTemplate=suggestionTemplate
- selection=(readonly viafId.value)
- allowFreeInput=true
-}}
--- a/server/bo_client/app/services/lexvo-resolver.js Mon Feb 22 18:06:39 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-import Ember from 'ember';
-import store from 'store';
-
-import ENV from 'bo-client/config/environment';
-
-export default Ember.Service.extend({
- constants: Ember.inject.service(),
- _getStoreKey: function(id) {
- return 'lexvo:'+id;
- },
- getName: function(id) {
- var lexvoId = id;
- if(id.startsWith(this.get('constants').LEXVO_BASE_URL)) {
- lexvoId = id.slice(this.get('constants').LEXVO_BASE_URL.length);
- }
- var storeKey = this._getStoreKey(id);
- var namePromise = null;
-
- var name = store.get(storeKey);
- if(!name) {
- //TODO: handle error !!!
- namePromise = this.queryName(lexvoId)
- .then( function(response) {
- return store.set(storeKey, response);
- });
- }
- else {
- namePromise = new Ember.RSVP.Promise(function(resolve/*, reject*/) {
- resolve(name);
- });
- }
- return namePromise;
- },
- // make the query for the name.
- // return a Promise
- queryName: function(id) {
- return new Ember.RSVP.Promise(function(resolve, reject) {
- Ember.$.ajax({
- //TODO Configuration ?
- url: ENV.baseURL.replace(/\/$/,"") + "/api/v1/lexvo/"+id,
- success: function(lexvoDoc) {
- var names = lexvoDoc.lexvoids;
- resolve((id in names)?names[id]:null);
- },
- error: function(req, status, error) {
- reject(status + ":" + error);
- }
- });
- }.bind(this));
- }
-});
--- a/server/bo_client/app/templates/doc.hbs Mon Feb 22 18:06:39 2016 +0100
+++ b/server/bo_client/app/templates/doc.hbs Tue Feb 23 17:47:57 2016 +0100
@@ -22,7 +22,7 @@
</div>
<div class="col-md-11">
<div class="content-title">{{t 'bo.document_language'}}</div>
- <div class="content-value">{{bo-doc-language language=model.language}}</div>
+ <div class="content-value">{{doc-language language=model.language}}</div>
</div>
</div>
<div class="row">
--- a/server/bo_client/bower.json Mon Feb 22 18:06:39 2016 +0100
+++ b/server/bo_client/bower.json Tue Feb 23 17:47:57 2016 +0100
@@ -16,6 +16,6 @@
},
"resolutions": {
"ember": "2.3.1",
- "jquery": ">=1.7"
+ "jquery": ">=2.2"
}
}
--- a/server/bo_client/ember-cli-build.js Mon Feb 22 18:06:39 2016 +0100
+++ b/server/bo_client/ember-cli-build.js Tue Feb 23 17:47:57 2016 +0100
@@ -43,15 +43,6 @@
'urijs': [ 'default' ]
}
});
- app.import({
- development: 'bower_components/store/store.js',
- production: 'bower_components/store/store.min.js'
- });
- app.import('vendor/shims/store.js', {
- exports: {
- 'store': ['default']
- }
- });
// app.import('../src/vendor/bower_components/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff', {
// destDir: 'fonts'
--- a/server/bo_client/package.json Mon Feb 22 18:06:39 2016 +0100
+++ b/server/bo_client/package.json Tue Feb 23 17:47:57 2016 +0100
@@ -24,8 +24,9 @@
"broccoli-funnel": "^1.0.1",
"broccoli-merge-trees": "^1.1.0",
"broccoli-static-compiler": "^0.2.2",
+ "corpus-common-addon": "file:../../common/corpus-common-addon",
+ "ember-ajax": "0.7.1",
"ember-aupac-typeahead": "2.0.4",
- "ember-ajax": "0.7.1",
"ember-cli": "2.3.0",
"ember-cli-app-version": "^1.0.0",
"ember-cli-babel": "^5.1.6",
@@ -45,10 +46,10 @@
"ember-data": "^2.3.1",
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.5",
+ "ember-i18n": "4.2.0",
"ember-load-initializers": "^0.5.0",
+ "ember-lodash": "0.0.6",
"ember-resolver": "^2.0.3",
- "ember-i18n": "4.2.0",
- "ember-lodash": "0.0.6",
"ember-truth-helpers": "1.2.0",
"express": "^4.13.3",
"glob": "^6.0.1",
@@ -58,6 +59,5 @@
"npm-check-updates": "^2.5.1",
"walk-sync": "^0.2.6"
},
- "dependencies": {
- }
+ "dependencies": {}
}
--- a/server/bo_client/vendor/shims/store.js Mon Feb 22 18:06:39 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-(function() {
- function vendorModule() {
- 'use strict';
-
- return { 'default': self['store'] };
- }
-
- define('store', [], vendorModule);
-})();