rename "sound" to "document"
authornowmad@nowmads-macbook-pro.local
Wed, 20 Jan 2016 23:05:52 +0100
changeset 91 acfeddc7821d
parent 90 f0609941aa98
child 92 3437f5191645
rename "sound" to "document"
cms/app-client/app/adapters/application.js
cms/app-client/app/components/player-component.js
cms/app-client/app/components/visu-carto.js
cms/app-client/app/controllers/application.js
cms/app-client/app/models/document.js
cms/app-client/app/router.js
cms/app-client/app/routes/application.js
cms/app-client/app/templates/application.hbs
cms/app-client/app/templates/components/player-component.hbs
cms/app-client/app/templates/player.hbs
cms/app-client/app/templates/results.hbs
cms/app-client/app/templates/tabs/carto.hbs
--- a/cms/app-client/app/adapters/application.js	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/adapters/application.js	Wed Jan 20 23:05:52 2016 +0100
@@ -1,17 +1,8 @@
 import DS from 'ember-data';
+
 export { default } from 'ember-data-fixture-adapter';
 
-// export default DS.FixtureAdapter.extend({
-//   host: 'http://127.0.0.1',
-//   namespace: 'api',
-//   queryFixtures: function(records, query) {
-//     return records.filter(function(record) {
-//         for(var key in query) {
-//             if (!query.hasOwnProperty(key)) { continue; }
-//             var value = query[key];
-//             if (record[key] !== value) { return false; }
-//         }
-//         return true;
-//     });
-//   }
+// export default DS.RESTAdapter.extend({
+//   host: 'http://int.corpusdelaparole.huma-num.fr/corpus',
+//   namespace: 'api/v1',
 // });
--- a/cms/app-client/app/components/player-component.js	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/components/player-component.js	Wed Jan 20 23:05:52 2016 +0100
@@ -5,11 +5,11 @@
   currentTime: "00:00",
   duration: "00:00",
 
-  _soundChanged: Ember.observer('sound', function() {
+  _documentChanged: Ember.observer('document', function() {
     this.pause();
     this.changeTime(0);
     this.updateProgress(0);
-    this.audio.src = this.get("sound").get("master");
+    this.audio.src = this.get("document").get("master");
     this.audio.load();
     this.set("currentTime", "00:00");
   }),
@@ -110,7 +110,7 @@
         this.play();
       }
     },
-    prevNextSong(change){
+    prevNextDocument(change){
       this.sendAction("action", change);
     }
   }
--- a/cms/app-client/app/components/visu-carto.js	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/components/visu-carto.js	Wed Jan 20 23:05:52 2016 +0100
@@ -114,7 +114,7 @@
     var areaList = [];
     var count = {};
     area.svg.g.path.map(function(elt, index){
-      var length = _this.get("sounds").filterBy("spatial", elt.title).toArray().length;
+      var length = _this.get("documents").filterBy("spatial", elt.title).toArray().length;
       if (length > 0)
         count[elt.id]= length;
     });
--- a/cms/app-client/app/controllers/application.js	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/controllers/application.js	Wed Jan 20 23:05:52 2016 +0100
@@ -10,37 +10,37 @@
   isShowingModal: false,
   currentDetails: null,
   currentItem: {title: "example", master: 'http://www.noiseaddicts.com/samples_1w72b820/3921.mp3'},
-  filteredSounds: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() {
+  filteredDocuments: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() {
     var location = this.get('location');
     var langue = this.get('langue');
     var discours = this.get('discours');
     var date = this.get('date');
     var thematique = this.get('thematique');
 
-    var sounds = this.get('model');
+    var documents = this.get('model');
 
     if (location) {
-      sounds = sounds.filterBy('spatial', location);
+      documents = documents.filterBy('spatial', location);
     }
     if (langue) {
-      sounds = sounds.filterBy('language', langue);
+      documents = documents.filterBy('language', langue);
     }
     if (discours) {
-      sounds = sounds.filterBy('type', discours);
+      documents = documents.filterBy('type', discours);
     }
     if (date.length > 0) {
-      var temp = sounds;
-      sounds.map(function(elt){
+      var temp = documents;
+      documents.map(function(elt){
         if (date.indexOf(elt.get('created')) === -1){
           temp = temp.without(elt);
         }
       });
-      sounds = temp;
+      documents = temp;
     }
     if (thematique) {
-      sounds = sounds.filterBy('thematique', thematique);
+      documents = documents.filterBy('thematique', thematique);
     }
-    return sounds;
+    return documents;
   }),
   currentItemChanged: Ember.observer('currentItem', function() {
     Ember.$(".result-item").toggleClass("playing", false);
@@ -61,15 +61,15 @@
 
       this.set(query, newParams);
     },
-    changeSong: function(songDirection){
-      var direction = (songDirection === "next") ? 1 : -1;
-      var index = this.get("filteredSounds").indexOf(this.get("currentItem"));
+    changeDocument: function(docDirection){
+      var direction = (docDirection === "next") ? 1 : -1;
+      var index = this.get("filteredDocuments").indexOf(this.get("currentItem"));
       if ( index !== -1){
-          if (typeof(this.get("filteredSounds").objectAt(index+direction)) !== 'undefined'){
-            return this.set('currentItem', this.get("filteredSounds").objectAt(index+direction));
+          if (typeof(this.get("filteredDocuments").objectAt(index+direction)) !== 'undefined'){
+            return this.set('currentItem', this.get("filteredDocuments").objectAt(index+direction));
           }
       }
-      return this.set('currentItem', this.get('filteredSounds').get('firstObject'));
+      return this.set('currentItem', this.get('filteredDocuments').get('firstObject'));
     },
     play: function(item){
       this.set("currentItem", item);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/models/document.js	Wed Jan 20 23:05:52 2016 +0100
@@ -0,0 +1,184 @@
+import DS from 'ember-data';
+import Ember from 'ember';
+
+var Document = DS.Model.extend({
+  // id: DS.attr('string'),
+  uri: DS.attr('string'),
+  title: DS.attr('string'),
+  language: DS.attr('string'),
+  publishers: DS.attr({defaultValue: []}),
+  contributors: DS.attr({defaultValue: []}),
+  mediaArray: DS.attr({defaultValue: []}),
+  mediaList: Ember.computed('mediaArray', function() {
+    var res = [];
+    var mp3 = null;
+    Ember.$.forEach(this.get('mediaArray'), function(m) {
+      if(m.format === 'audio/mpeg') {
+        mp3 = m;
+      } else if (m.format.startsWith('audio/')) {
+        res.push(m);
+      }
+    });
+    if(mp3) {
+      res.unshift(mp3);
+    }
+    return res;
+  })
+});
+
+Document.reopenClass({
+  FIXTURES: [
+    {
+      "id": "crdo-09-CAYCHAX_SOUND",
+      "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-CAYCHAX_SOUND",
+      "title": "ALLOc : Caychax : Parabole",
+      "language": "http://lexvo.org/id/iso639-3/oci",
+      "modified": "2010-10-25T18:16:38+02:00",
+      "publishers": [ ],
+      "contributors": [ ],
+      "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-DUN_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-DUN_SOUND",
+        "title": "ALLOc : Dun : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:18:23+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-LABASTIDE-DE-LORDAT_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-LABASTIDE-DE-LORDAT_SOUND",
+        "title": "ALLOc : La Bastide-de-Lordat : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:20:08+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-LOUBENS_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-LOUBENS_SOUND",
+        "title": "ALLOc : Loubens : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:21:23+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-MERENS-LES-VALS_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-MERENS-LES-VALS_SOUND",
+        "title": "ALLOc : Mérens-les-Vals : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:22:24+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-MONTSEGUR_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-MONTSEGUR_SOUND",
+        "title": "ALLOc : Montségur : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:23:14+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-PRAYOLS_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-PRAYOLS_SOUND",
+        "title": "ALLOc : Prayols : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:24:06+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-QUERIGUT_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-QUERIGUT_SOUND",
+        "title": "ALLOc : Quérigut : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:24:56+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-SIGUER_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-SIGUER_SOUND",
+        "title": "ALLOc : Siguer : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:25:51+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-ST-MARTIN-D-OYDES_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-ST-MARTIN-D-OYDES_SOUND",
+        "title": "ALLOc : Saint-Martin-d'Oydes : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:26:22+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-09-SURBA_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-09-SURBA_SOUND",
+        "title": "ALLOc : Surba : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:26:42+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-11-GRAMAZIE_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-11-GRAMAZIE_SOUND",
+        "title": "ALLOc : Gramazie : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:27:39+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-11-MOLLEVILLE_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-11-MOLLEVILLE_SOUND",
+        "title": "ALLOc : Molleville : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:28:06+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-11-PUIVERT_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-11-PUIVERT_SOUND",
+        "title": "ALLOc : Puivert : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:28:40+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    },
+    {
+        "id": "crdo-11-RIBOUISSE_SOUND",
+        "uri": "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-11-RIBOUISSE_SOUND",
+        "title": "ALLOc : Ribouisse : Parabole",
+        "language": "http://lexvo.org/id/iso639-3/oci",
+        "modified": "2010-10-25T18:29:32+02:00",
+        "publishers": [ ],
+        "contributors": [ ],
+        "mediaArray": [ ]
+    }
+  ]
+});
+
+export default Document;
--- a/cms/app-client/app/router.js	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/router.js	Wed Jan 20 23:05:52 2016 +0100
@@ -6,6 +6,7 @@
 });
 
 Router.map(function() {
+  // this.route('application', { path: '/detail/:document_id' });
   this.route('tabs/langues', { path: '/langues' });
   this.route('tabs/carto', { path: '/cartographie' });
   this.route('tabs/thematiques', { path: '/thematiques' });
--- a/cms/app-client/app/routes/application.js	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/routes/application.js	Wed Jan 20 23:05:52 2016 +0100
@@ -19,7 +19,7 @@
     return value;
   },
   model() {
-    return this.store.findAll('sound');
+    return this.store.findAll('document');
   },
   actions: {
     willTransition: function(transition) {
--- a/cms/app-client/app/templates/application.hbs	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/templates/application.hbs	Wed Jan 20 23:05:52 2016 +0100
@@ -10,3 +10,19 @@
   </div>
   {{partial "results"}}
 </div>
+
+{{#if isShowingModal}}
+  {{#ember-wormhole to='info-modal'}}
+    <div class="overlay" {{action 'toggleModal'}}></div>
+    <div class="dialog">
+      <h1>{{currentDetails.title}}</h1>
+      <p><b>Description: </b>{{currentDetails.description}}</p>
+      <p><b>Interviewer: </b>{{currentDetails.interviewer}}</p>
+      <p><b>Type de Discours: </b>{{currentDetails.type}}</p>
+      <p><b>Localisation: </b>{{currentDetails.spatial}}</p>
+      <p><b>Langue: </b>{{currentDetails.language}}</p>
+      <p><b>Date de Creation: </b>{{currentDetails.created}}</p>
+      <button class="pull-right" {{action 'toggleModal'}}>Close</button>
+    </div>
+  {{/ember-wormhole}}
+{{/if}}
--- a/cms/app-client/app/templates/components/player-component.hbs	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/templates/components/player-component.hbs	Wed Jan 20 23:05:52 2016 +0100
@@ -1,5 +1,5 @@
 <div class="audio-wrapper">
-	<span class="audio-controls fa fa-backward" {{action 'prevNextSong' 'previous'}}></span>
+	<span class="audio-controls fa fa-backward" {{action 'prevNextDocument' 'previous'}}></span>
 	<div id="audio_player">
 		<span id="action_play" class="btn btn_play" {{action 'tooglePlay'}}>Play</span>
 		<div class="background"></div>
@@ -9,7 +9,7 @@
 			</div>
 		</div>
 	</div>
-	<span class="audio-controls fa fa-forward fa-5" {{action 'prevNextSong' 'next'}}></span>
+	<span class="audio-controls fa fa-forward fa-5" {{action 'prevNextDocument' 'next'}}></span>
 </div>
 
 <p class="duration">
--- a/cms/app-client/app/templates/player.hbs	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/templates/player.hbs	Wed Jan 20 23:05:52 2016 +0100
@@ -1,6 +1,6 @@
 <div class="corpus-app-content">
 
-  {{player-component action="changeSong" sound=currentItem}}
+  {{player-component action="changeDocument" document=currentItem}}
 
   <p>
     Title: {{ currentItem.title }}
--- a/cms/app-client/app/templates/results.hbs	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/templates/results.hbs	Wed Jan 20 23:05:52 2016 +0100
@@ -22,7 +22,7 @@
   </p>
 </div>
 <div class='result-list'>
-  {{#each filteredSounds as |item| }}
+  {{#each filteredDocuments as |item| }}
     <div id="{{item.id}}" {{action "details" item}} class='result-item'>
       <span class="playing-indicator fa fa-play-circle fa-lg fa-fw pull-right" {{action 'play' item}}></span>
       <strong>{{ item.title }}</strong> - {{item.interviewer}}
@@ -32,19 +32,4 @@
       <button class="pull-right" {{action 'toggleModal' item}}>Details</button>
     </div>
   {{/each}}
-  {{#if isShowingModal}}
-    {{#ember-wormhole to='info-modal'}}
-      <div class="overlay" {{action 'toggleModal'}}></div>
-      <div class="dialog">
-        <h1>{{currentDetails.title}}</h1>
-        <p><b>Description: </b>{{currentDetails.description}}</p>
-        <p><b>Interviewer: </b>{{currentDetails.interviewer}}</p>
-        <p><b>Type de Discours: </b>{{currentDetails.type}}</p>
-        <p><b>Localisation: </b>{{currentDetails.spatial}}</p>
-        <p><b>Langue: </b>{{currentDetails.language}}</p>
-        <p><b>Date de Creation: </b>{{currentDetails.created}}</p>
-        <button class="pull-right" {{action 'toggleModal'}}>Close</button>
-      </div>
-    {{/ember-wormhole}}
-  {{/if}}
 </div>
--- a/cms/app-client/app/templates/tabs/carto.hbs	Wed Jan 20 15:53:27 2016 +0100
+++ b/cms/app-client/app/templates/tabs/carto.hbs	Wed Jan 20 23:05:52 2016 +0100
@@ -1,1 +1,1 @@
-{{visu-carto action="updateUrl" sounds=model}}
+{{visu-carto action="updateUrl" documents=model}}