diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..227cea2 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.0.0 diff --git a/.rvmrc b/.rvmrc deleted file mode 100644 index 35845a2..0000000 --- a/.rvmrc +++ /dev/null @@ -1 +0,0 @@ -rvm use 1.9.2 diff --git a/Gemfile.lock b/Gemfile.lock index e5c7092..8c7eba1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,15 +1,15 @@ GIT remote: https://github.com/livingsocial/rake-pipeline.git - revision: ee992cbcda5172075062be035bcbef2cf1b0ff5d + revision: a75d96fbadcc659a35a0ae59212e0bc60b58cc54 specs: rake-pipeline (0.8.0) json - rake (~> 10.0.0) + rake (~> 10.1.0) thor GIT remote: https://github.com/wycats/rake-pipeline-web-filters.git - revision: d83f54cc0d4e53f9833c31851964e3d8ba00f66a + revision: de71c66b5a92e304c244ab35d351d9b8eea002df specs: rake-pipeline-web-filters (0.6.0) rack @@ -36,7 +36,7 @@ GEM fssm (0.2.10) highline (1.6.19) jslint_on_rails (1.1.1) - json (1.7.7) + json (1.8.1) libv8 (3.11.8.13) multi_json (1.5.1) net-scp (1.1.2) @@ -47,13 +47,13 @@ GEM net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) rack (1.5.2) - rake (10.0.3) + rake (10.1.1) ref (1.0.2) sass (3.2.5) therubyracer (0.11.3) libv8 (~> 3.11.8.12) ref - thor (0.17.0) + thor (0.18.1) uglifier (1.3.0) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) diff --git a/app/javascripts/adapters/sapi_adapter.js b/app/javascripts/adapters/sapi_adapter.js index 6cf5646..f103318 100644 --- a/app/javascripts/adapters/sapi_adapter.js +++ b/app/javascripts/adapters/sapi_adapter.js @@ -56,7 +56,7 @@ Checklist.DownloadAdapter = { var store = Checklist.LocalStorageAdapter; var ids = store.getAll(Checklist.Download).map( function(item, index) { - return item["id"]; + return item.id; }); var content = Checklist.store.findQuery(Checklist.Download, {ids: ids}); diff --git a/app/javascripts/app.js b/app/javascripts/app.js index c9e83f7..7b308fa 100644 --- a/app/javascripts/app.js +++ b/app/javascripts/app.js @@ -6,8 +6,19 @@ require('checklist/vendor/spin.min'); require('checklist/vendor/ember'); require('checklist/vendor/ember-data'); -require('checklist/vendor/plurals'); -require('checklist/vendor/ember-i18n'); +// rather than include CLDR here, just a simple plural form implementation +// EN, ES, FR only ever have 'one' or 'other' +// 'zero' is for convenience + +CLDR = { + pluralForm: function myCustomInflector(n) { + return n === 0 ? 'zero' : n === 1 ? 'one' : 'other'; + } +}; + +require('checklist/vendor/i18n'); + +Em.I18n.locales = {}; minispade.requireAll(/locales/); minispade.requireAll(/templates/); @@ -58,6 +69,7 @@ Checklist.download_store = DS.Store.create({ }) }); +require('checklist/static_page'); require('checklist/routers/router'); Checklist.initialize(); diff --git a/app/javascripts/config.js b/app/javascripts/config.js index 9b1fdba..91f4b11 100644 --- a/app/javascripts/config.js +++ b/app/javascripts/config.js @@ -40,4 +40,3 @@ Checklist.CONFIG = { Em.I18n.translations = Em.I18n.locales[Checklist.CONFIG.default_locale]; Em.I18n.currentLocale = Checklist.CONFIG.default_locale; -CLDR.defaultLanguage = Checklist.CONFIG.default_locale; diff --git a/app/javascripts/controllers/download_controller.js b/app/javascripts/controllers/download_controller.js index 300f503..28da57d 100644 --- a/app/javascripts/controllers/download_controller.js +++ b/app/javascripts/controllers/download_controller.js @@ -31,7 +31,7 @@ Checklist.DownloadController = Ember.ArrayController.extend({ content: Checklist.store.findQuery(Checklist.Download, {ids: (function() { var store = Checklist.LocalStorageAdapter; return store.getAll(Checklist.Download).map(function(item, index) { - return item["id"]; + return item.id; }); })()}), @@ -52,7 +52,7 @@ Checklist.DownloadController = Ember.ArrayController.extend({ var store = Checklist.LocalStorageAdapter; var ids = store.getAll(Checklist.Download).map( function(item, index) { - return item["id"]; + return item.id; }); // Query the server to return the current state of the objects for @@ -102,7 +102,7 @@ Checklist.DownloadController = Ember.ArrayController.extend({ _interval: null, startPolling: function() { - if (this.get('_interval') == null) { + if (this.get('_interval') === null) { var that = this; var id = setInterval(function() { that.refresh(); @@ -112,7 +112,7 @@ Checklist.DownloadController = Ember.ArrayController.extend({ } }, stopPolling: function() { - if (this.get('_interval') != null) { + if (this.get('_interval') !== null) { clearInterval(this.get('_interval')); } } diff --git a/app/javascripts/controllers/filters_controller.js b/app/javascripts/controllers/filters_controller.js index d65c4d9..e5217cf 100644 --- a/app/javascripts/controllers/filters_controller.js +++ b/app/javascripts/controllers/filters_controller.js @@ -1,18 +1,15 @@ Checklist.FiltersController = Ember.Object.extend({ - /* - * In the current version of Ember (0.9.8.1) findAll does not fire - * loading events properly, so we use findQuery with an empty query - * string. - */ - countriesContent : Checklist.store.findQuery(Checklist.Country, {}), countries : [], countriesIds : [], - regionsContent : Checklist.store.findQuery(Checklist.Region, {}), regions : [], regionsIds: [], - appendicesContent : Checklist.store.findQuery(Checklist.Appendix, {}), appendices : [], appendicesIds : [], + appendicesContent: [ + Ember.Object.create({abbreviation: 'I'}), + Ember.Object.create({abbreviation: 'II'}), + Ember.Object.create({abbreviation: 'III'}) + ], taxonomicLayout : false, levelOfListing : false, showSynonyms : true, @@ -22,7 +19,6 @@ Checklist.FiltersController = Ember.Object.extend({ showFrench : true, scientificName : "", geoEntityName : "", - locale: Em.I18n.currentLocale, autoCompleteCountriesContent : [], autoCompleteRegionsContent : [], searches : [], @@ -72,19 +68,10 @@ Checklist.FiltersController = Ember.Object.extend({ return that.get('appendicesIds').contains(item.get('abbreviation')); } ) - ); + ); } }.observes('appendicesContent.isLoaded','appendicesIds'), - localeDidChange: function() { - var locale = this.get('locale'); - - if (Em.I18n.locales[locale]) { - Em.I18n.currentLocale = locale; - CLDR.defaultLanguage = locale; - } - }.observes('locale'), - resetParams: function() { this.set('countries',[]); this.set('countriesIds',[]); @@ -109,8 +96,7 @@ Checklist.FiltersController = Ember.Object.extend({ show_french : this.get('showFrench') === true ? 1 : 0, scientific_name : this.get('scientificName'), page : this.get('page'), - per_page : this.get('per_page'), - locale : Em.I18n.currentLocale + per_page : this.get('per_page') }; }, @@ -121,7 +107,7 @@ Checklist.FiltersController = Ember.Object.extend({ show_english : 1, show_spanish : 1, show_french : 1, - locale : Em.I18n.currentLocale + intro : 1 }; }, @@ -161,7 +147,5 @@ Checklist.FiltersController = Ember.Object.extend({ this.set('scientificName', params.scientific_name || ""); this.set('page', parseInt(params.page, 10) || 1); this.set('perPage', parseInt(params.perPage, 10) || 20); - - this.set('locale', params.locale); } }); diff --git a/app/javascripts/controllers/taxon_concept_controller.js b/app/javascripts/controllers/taxon_concept_controller.js index 50b9d37..41ae560 100644 --- a/app/javascripts/controllers/taxon_concept_controller.js +++ b/app/javascripts/controllers/taxon_concept_controller.js @@ -1,25 +1,28 @@ Checklist.TaxonConceptController = Ember.ArrayController.extend({ - content: [], - - taxaCount: 0, - - contentIds: function(){ - return this.get('content').objectAt(0).get('contentIds'); - }.property('content'), - contentHistory: null, - contentDidChange: function(){ - if (this.get('content.isLoaded')){ - this.set('taxaCount', this.get('content').objectAt(0).get('total_cnt')); - this.set('contentHistory', - Checklist.store.findMany(Checklist.TimelinesForTaxonConcept, this.get('contentIds')) - ); - } - }.observes('content.isLoaded','contentIds'), - - refresh: function(params) { - this.set('content', Checklist.store.find( + refresh: function(params){ + var that = this; + var promise = new RSVP.Promise(); + var res = Checklist.store.find( Checklist.Index, - params - )); + $.extend({locale: Em.I18n.currentLocale}, params) + ); + res.addObserver( + '@each.didLoad', + function(){ + Ember.run.once( + this, + function() { promise.resolve(res); } + ); + } + ); + promise.then(function(taxon_concepts_index_ary){ + that.set('content', taxon_concepts_index_ary); + var contentIds = taxon_concepts_index_ary.objectAt(0).get('contentIds'); + Checklist.store.find( + Checklist.TimelinesForTaxonConcept, { + taxon_concept_ids: contentIds, locale: Em.I18n.currentLocale + } + ); + }); } }); diff --git a/app/javascripts/locales/en.js b/app/javascripts/locales/en.js index 89de974..ee613d0 100644 --- a/app/javascripts/locales/en.js +++ b/app/javascripts/locales/en.js @@ -1,35 +1,113 @@ -Em.I18n.locales = {}; - Em.I18n.locales.en = { 'title': 'Checklist of CITES Species', + 'about.title': 'About the CITES Checklist', + 'terms.title': 'Terms of Use', + 'toplink.about': 'About', + 'toplink.terms': 'Terms of Use', + 'powered.by': 'Powered By', + + 'search.by_taxon.button': 'SEARCH', + 'search.by_taxon.placeholder': 'Species, higher taxon, synonym or common name...', + 'search.by_appendix.all': 'All', + 'search.by_appendix.appxs': 'Appxs.', + + 'search.by_location.placeholder': 'Type to filter countries or regions', + 'search.by_location.selected': 'Selected Locations', + 'search.by_location.regions': 'Regions', + 'search.by_location.countries': 'Countries and territories', + 'search.by_location.no_matches': 'No matches', + + 'search.clear': 'Clear Search', + 'search.no_results': 'Your search did not match any taxa.', + 'search.results.page': 'Page', + + 'search.result.show_history': 'Show History', + 'search.result.hide_history': 'Hide History', + 'distribution.more': 'and {{count}} more.', + 'distribution.see_all': 'See all...', 'timeline.party': 'See reservations to CITES listings', + 'timeline.split': 'NB: this taxon is split-listed. See also timeline(s) ' + + 'for lower taxa.', + 'timeline.nohistory': 'No history information is available for this taxon.', + 'timeline.reservations': 'Appendix-{{appendix}} reservations:', + 'timeline.event.appendix': 'CITES Appendix {{appendix}}', + 'timeline.event.symbol.amendment': 'A', + 'timeline.event.symbol.reservation': 'R', + 'timeline.event.symbol.reservation_withdrawal': 'W', + 'timeline.event.description.addition': 'APPENDIX', + 'timeline.event.description.reservation': 'RESERVATION', + 'timeline.event.description.reservation_withdrawal': 'RESERVATION WITHDRAWAL', + 'advanced.title': 'Advanced Options', + 'advanced.common_names': 'COMMON NAMES', + 'advanced.common_names.en': 'EN', + 'advanced.common_names.es': 'ES', + 'advanced.common_names.fr': 'FR', + 'advanced.online_view': 'Online view', + 'advanced.online_view.alphabetical': 'Alphabetical', + 'advanced.online_view.taxonomic': 'Taxonomic', + 'advanced.online_view.appendix': 'Appendix', + 'advanced.display': 'DISPLAY', + 'advanced.display.synonyms': 'Synonyms', + 'advanced.display.author_name': 'Author\'s name', + 'advanced.display.unfold_history': 'History of listing', + 'advanced.downloads': 'Downloads', + 'advanced.downloads.include_intro': 'Include introduction in PDF', + 'advanced.downloads.separator': 'CSV separator', + 'advanced.downloads.separator.comma': 'comma', + 'advanced.downloads.separator.semicolon': 'semicolon', + + 'downloads.button': 'Download', + 'downloads.popup.title': 'Download Taxa', + 'downloads.popup.info': 'Please select the format of your choice', + + 'download.button': 'Download', + 'download.failed': 'Failed.', + 'download.remove': 'Remove?', + 'download.spinner': 'Downloading...', + + 'saved_search.button': 'SAVE THIS', 'saved_search.count.zero': '', 'saved_search.count.one': '1 saved search', 'saved_search.count.other': '{{count}} saved searches', + 'featured.title': 'Featured', + 'featured.index': 'Full species list', + 'featured.history': 'History of listings', + 'featured.format': 'Format', + 'locations.count.zero': 'All Locations', 'locations.count.one': '1 Location', 'locations.count.other': '{{count}} Locations', + 'reports.count.zero': '', 'reports.count.one': 'Generating 1 report', 'reports.count.other': 'Generating {{count}} reports', + 'reports.ready.count.zero': '', 'reports.ready.count.one': '1 report ready', 'reports.ready.count.other': '{{count}} reports ready', + 'reports.failed.count.zero': '', 'reports.failed.count.one': '1 report failed', 'reports.failed.count.other': '{{count}} reports failed', - 'reports.failed.description': 'You can restart a download, or remove it from the list.', - 'reports.generating.description': 'It can take some time, but you can close this window and continue working in other CITES Checklist reports.', + 'reports.failed.description': 'You can restart a download, or remove it ' + + 'from the list.', + 'reports.generating.description': 'It can take some time, but you can ' + + 'close this window and continue working in other CITES Checklist reports.', 'reports.ready.title': 'Your Reports', 'reports.generating.title': 'Currently Generating Reportings', 'reports.latest.title': 'Your report is being generated', - 'results.count.zero': 'taxa', - 'results.count.one': 'taxon', - 'results.count.other': 'taxa' + 'splash.p1': 'CITES (the Convention on International Trade in Endangered ' + + 'Species of Wild Fauna and Flora) is an international agreement between ' + + 'governments that aims to ensure that international trade in specimens ' + + 'of wild animals and plants does not threaten their survival.', + 'splash.p2': 'The Checklist of CITES Species allows the exploration of ' + + 'more than 35,000 species of animals and plants and their degree of ' + + 'protection.', + 'splash.button': 'Start Exploring' }; diff --git a/app/javascripts/locales/es.js b/app/javascripts/locales/es.js new file mode 100644 index 0000000..ce3be77 --- /dev/null +++ b/app/javascripts/locales/es.js @@ -0,0 +1,114 @@ +Em.I18n.locales.es = { + 'title': 'Lista de especies CITES', + 'about.title': 'Acerca de la Lista de especies CITES', + 'terms.title': 'Términos de uso', + 'toplink.about': 'Acerca de', + 'toplink.terms': 'Términos de uso', + 'powered.by': 'Proporcionada por', + + 'search.by_taxon.button': 'BUSCAR', + 'search.by_taxon.placeholder': 'Especie, taxón superior, sinónimo o nombre común...', + 'search.by_appendix.all': 'Todos los', + 'search.by_appendix.appxs': 'apénd.', + + 'search.by_location.placeholder': 'Escriba para filtrar países o regiones', + 'search.by_location.selected': 'Ubicaciones seleccionadas', + 'search.by_location.regions': 'Regiones', + 'search.by_location.countries': 'Países y territorios', + 'search.by_location.no_matches': 'No resultados', + + 'search.clear': 'Borrar el resultado de la búsqueda', + 'search.no_results': 'Su búsqueda no encontró ningún taxón.', + 'search.results.page': 'Página', + + 'search.result.show_history': 'Mostrar historial', + 'search.result.hide_history': 'Ocultar historial', + 'distribution.more': 'y {{count}} más.', + 'distribution.see_all': 'Ver todos...', + + 'timeline.party': 'Ver reservas a inclusiones en los Apéndices de la CITES', + 'timeline.split': 'NB: inclusión dividida para este taxón. Vea también ' + + 'la(s) línea(s) de tiempo para los taxones inferiores.', + 'timeline.nohistory': 'No hay información de historial para este taxón.', + 'timeline.reservations': 'Reservas al Apéndice {{appendix}}:', + 'timeline.event.appendix': 'Apéndice {{appendix}} de la CITES', + 'timeline.event.symbol.amendment': 'A', + 'timeline.event.symbol.reservation': 'R', + 'timeline.event.symbol.reservation_withdrawal': 'RR', + 'timeline.event.description.addition': 'APÉNDICE', + 'timeline.event.description.reservation': 'RESERVA', + 'timeline.event.description.reservation_withdrawal': 'RETIRO DE RESERVA', + + 'advanced.title': 'Opciones avanzadas', + 'advanced.common_names': 'NOMBRES COMUNES', + 'advanced.common_names.en': 'EN', + 'advanced.common_names.es': 'ES', + 'advanced.common_names.fr': 'FR', + 'advanced.online_view': 'Vista en línea', + 'advanced.online_view.alphabetical': 'Alfabética', + 'advanced.online_view.taxonomic': 'Taxonómica', + 'advanced.online_view.appendix': 'Apéndice', + 'advanced.display': 'MOSTRAR', + 'advanced.display.synonyms': 'Sinónimos', + 'advanced.display.author_name': 'Nombre del autor', + 'advanced.display.unfold_history': 'Historial de inclusión', + 'advanced.downloads': 'Descargar', + 'advanced.downloads.include_intro': 'Incluir introducción en PDF', + 'advanced.downloads.separator': 'Separador de CSV', + 'advanced.downloads.separator.comma': 'coma', + 'advanced.downloads.separator.semicolon': 'punto y coma', + + 'downloads.button': 'Descargar', + 'downloads.popup.title': 'Descargar taxones', + 'downloads.popup.info': 'Seleccione el formato preferido', + + 'download.button': 'Descargar', + 'download.failed': 'Se produjo un error.', + 'download.remove': '¿Quitar?', + 'download.spinner': 'Descargando...', + + 'saved_search.button': 'GUARDAR ESTO', + 'saved_search.count.zero': '', + 'saved_search.count.one': '1 búsqueda guardada', + 'saved_search.count.other': '{{count}} búsquedas guardadas', + + 'featured.title': 'Destacados', + 'featured.index': 'Lista completa de especies', + 'featured.history': 'Historial de inclusiones', + 'featured.format': 'Formato', + + 'locations.count.zero': 'Todas las ubicaciones', + 'locations.count.one': '1 ubicación', + 'locations.count.other': '{{count}} ubicaciones', + + 'reports.count.zero': '', + 'reports.count.one': 'Generando 1 informe', + 'reports.count.other': 'Generando {{count}} informes', + + 'reports.ready.count.zero': '', + 'reports.ready.count.one': '1 informe listo', + 'reports.ready.count.other': '{{count}} informes listos', + + 'reports.failed.count.zero': '', + 'reports.failed.count.one': 'Se produjo un error en 1 informe', + 'reports.failed.count.other': 'Se produjo un error en {{count}} informes', + + 'reports.failed.description': 'Puede reiniciar una descarga, o bien ' + + 'quitarla de la lista.', + 'reports.generating.description': 'Puede demorar cierto tiempo, pero ' + + 'usted puede cerrar esta ventana y continuar trabajando con otros ' + + 'informes de la Lista de especies CITES.', + + 'reports.ready.title': 'Sus informes', + 'reports.generating.title': 'Generando informes actualmente', + 'reports.latest.title': 'Se ha generado su informe', + + 'splash.p1': 'La CITES (la Convención sobre el Comercio Internacional de ' + + 'Especies Amenazadas de Fauna y Flora Silvestres) es un acuerdo ' + + 'internacional concertado entre los gobiernos. Tiene por finalidad ' + + 'velar por que el comercio internacional de especímenes de animales y ' + + 'plantas silvestres no constituya una amenaza para su supervivencia.', + 'splash.p2': 'La Lista de especies CITES le permite explorar más de ' + + '35.000 especies de animales y plantas y su grado de protección.', + 'splash.button': 'Comenzar a explorar' +}; diff --git a/app/javascripts/locales/fr.js b/app/javascripts/locales/fr.js new file mode 100644 index 0000000..e92678f --- /dev/null +++ b/app/javascripts/locales/fr.js @@ -0,0 +1,114 @@ +Em.I18n.locales.fr = { + 'title': 'Liste des espèces CITES', + 'about.title': 'A propos de la Liste des espèces CITES', + 'terms.title': 'Conditions d\'utilisation', + 'toplink.about': 'A propos de', + 'toplink.terms': 'Conditions d\'utilisation', + 'powered.by': 'Moteur de recherche', + + 'search.by_taxon.button': 'RECHERCHE', + 'search.by_taxon.placeholder': 'Espèce, taxon supérieur, synonyme ou nom commun', + 'search.by_appendix.all': 'Tout', + 'search.by_appendix.appxs': 'Annexes', + + 'search.by_location.placeholder': 'Taper pour filtrer par pays ou par région', + 'search.by_location.selected': 'Localisations sélectionnées', + 'search.by_location.regions': 'Régions', + 'search.by_location.countries': 'Pays et territoires', + 'search.by_location.no_matches': 'Aucun résultat', + + 'search.clear': 'Effacer la recherche', + 'search.no_results': 'Aucun taxon ne correspond à votre recherche', + 'search.results.page': 'Page', + + 'search.result.show_history': 'Afficher l\'historique', + 'search.result.hide_history': 'Masquer l\'historique', + 'distribution.more': 'et {{count}} supplémentaire(s)', + 'distribution.see_all': 'Voir tous les...', + + 'timeline.party': 'Voir les réserves à l\'encontre des inscriptions CITES', + 'timeline.split': 'NB: ce taxon fait l\'objet d\'une inscription scindée; ' + + 'voir également le(s) calendrier(s) pour les taxons inférieurs', + 'timeline.nohistory': 'Aucun historique n\'est disponible pour ce taxon', + 'timeline.reservations': 'Annexe-{{appendix}}, réserves', + 'timeline.event.appendix': 'Annexe CITES-{{appendix}} ', + 'timeline.event.symbol.amendment': 'A', + 'timeline.event.symbol.reservation': 'R', + 'timeline.event.symbol.reservation_withdrawal': 'RT', + 'timeline.event.description.addition': 'ANNEXE', + 'timeline.event.description.reservation': 'RESERVE', + 'timeline.event.description.reservation_withdrawal': 'RETRAIT D\'UNE RESERVE', + + 'advanced.title': 'Options avancées', + 'advanced.common_names': 'NOMS COMMUNS', + 'advanced.common_names.en': 'EN', + 'advanced.common_names.es': 'ES', + 'advanced.common_names.fr': 'FR', + 'advanced.online_view': 'Affichage en ligne', + 'advanced.online_view.alphabetical': 'Alphabétique', + 'advanced.online_view.taxonomic': 'Taxonomique', + 'advanced.online_view.appendix': 'Annexe', + 'advanced.display': 'AFFICHER', + 'advanced.display.synonyms': 'Synonymes', + 'advanced.display.author_name': 'Nom de l\'auteur', + 'advanced.display.unfold_history': 'Historique des inscriptions', + 'advanced.downloads': 'Télécharger', + 'advanced.downloads.include_intro': 'Comprend une introduction en PDF', + 'advanced.downloads.separator': 'séparateur de fichiers CSV', + 'advanced.downloads.separator.comma': 'virgule', + 'advanced.downloads.separator.semicolon': 'point-virgule', + + 'downloads.button': 'Télécharger', + 'downloads.popup.title': 'Télécharger les taxa', + 'downloads.popup.info': 'Sélectionnez le format au choix', + + 'download.button': 'Télécharger', + 'download.failed': 'Echec', + 'download.remove': 'Supprimer?', + 'download.spinner': 'En cours de téléchargement...', + + 'saved_search.button': 'ENREGISTRER', + 'saved_search.count.zero': '', + 'saved_search.count.one': '1 recherche enregistrée', + 'saved_search.count.other': '{{count}} recherches enregistrées', + + 'featured.title': 'Mentionné', + 'featured.index': 'Liste complète des espèces', + 'featured.history': 'Historique des inscriptions', + 'featured.format': 'Format', + + 'locations.count.zero': 'Toutes les localisations', + 'locations.count.one': '1 localisation', + 'locations.count.other': '{{count}} localisations', + + 'reports.count.zero': '', + 'reports.count.one': '1 rappport en cours de production', + 'reports.count.other': '{{count}} rapports en cours de production', + + 'reports.ready.count.zero': '', + 'reports.ready.count.one': '1 rapport prêt', + 'reports.ready.count.other': '{{count}} rapports prêts', + + 'reports.failed.count.zero': '', + 'reports.failed.count.one': 'Echec du rapport', + 'reports.failed.count.other': 'Echec de {{count}} rapports', + + 'reports.failed.description': 'Vous pouvez relancer un téléchargement, ou ' + + 'le supprimer de la liste', + 'reports.generating.description': 'Cela peut prendre du temps, mais vous ' + + 'pouvez fermer cette fenêtre et continuer de travailler à d\'autres ' + + 'rapports sur les Listes des espèces CITES', + + 'reports.ready.title': 'Vos rapports', + 'reports.generating.title': 'Rapports en cours de production', + 'reports.latest.title': 'Votre rapport est en cours de production', + + 'splash.p1': 'La CITES (Convention sur le commerce international des ' + + 'espèces de faune et de flore sauvages menacées d\'extinction) est un ' + + 'accord international entre Etats qui vise à s\'assurer que le commerce ' + + 'international de spécimens d\'animaux ou de plantes sauvages ne menace ' + + 'pas la survie de ces derniers', + 'splash.p2': 'La Liste des espèces CITES permet d\'explorer plus de 35 000' + + ' espèces animales ou végétales et de vérifier leur degré de protection', + 'splash.button': 'Commencer l\'exploration' +}; diff --git a/app/javascripts/models/appendix.js b/app/javascripts/models/appendix.js deleted file mode 100644 index 0e5139b..0000000 --- a/app/javascripts/models/appendix.js +++ /dev/null @@ -1,9 +0,0 @@ -Checklist.Appendix = DS.Model.extend({ - id: DS.attr('number'), - abbreviation: DS.attr('string'), - name: DS.attr('string') -}); - -Checklist.Appendix.reopenClass({ - collectionUrl: 'species_listings?designation=cites' -}); diff --git a/app/javascripts/models/country.js b/app/javascripts/models/country.js index 8056b1a..f2cc620 100644 --- a/app/javascripts/models/country.js +++ b/app/javascripts/models/country.js @@ -5,9 +5,5 @@ Checklist.Country = DS.Model.extend({ }); Checklist.Country.reopenClass({ - // IE10 for some reason aappends a questionmark to this url - // consequently, territories would not get fetched for location dropdown - // this is an ugly workaround to a problem that seems to be too ember-data - // specific - collectionUrl: 'geo_entities?geo_entity_types_set=2&1' + collectionUrl: 'geo_entities' }); diff --git a/app/javascripts/models/listing_change.js b/app/javascripts/models/listing_change.js index bdaf42b..40ecaa7 100644 --- a/app/javascripts/models/listing_change.js +++ b/app/javascripts/models/listing_change.js @@ -6,17 +6,17 @@ Checklist.ListingChange = DS.Model.extend({ change_type_name: DS.attr('string'), effective_at: DS.attr('string', { key: 'effective_at_formatted' }), auto_note: DS.attr('string'), - short_note_en: DS.attr('string'), - full_note_en: DS.attr('string'), - hash_full_note_en: DS.attr('string'), + short_note: DS.attr('string'), + full_note: DS.attr('string'), + hash_full_note: DS.attr('string'), hash_ann_symbol:DS.attr('string'), hash_ann_parent_symbol: DS.attr('string'), - inherited_short_note_en: DS.attr('string'), - inherited_full_note_en: DS.attr('string'), + inherited_short_note: DS.attr('string'), + inherited_full_note: DS.attr('string'), hasParty: function(){ return (this.get('party') !== null); }.property(), hasInheritedNote: function(){ - return (this.get('inherited_full_note_en') !== null || this.get('inherited_short_note_en') !== null); + return (this.get('inherited_full_note') !== null || this.get('inherited_short_note') !== null); }.property() }); diff --git a/app/javascripts/models/locations_loader.js b/app/javascripts/models/locations_loader.js new file mode 100644 index 0000000..9cf839f --- /dev/null +++ b/app/javascripts/models/locations_loader.js @@ -0,0 +1,14 @@ +Checklist.LocationsLoader = { + load: function(){ + var promise = new RSVP.Promise(); + promise.resolve({ + countries: Checklist.store.findQuery( + Checklist.Country, {geo_entity_types_set: 2, locale: Em.I18n.currentLocale} + ), + regions: Checklist.store.findQuery( + Checklist.Country, {geo_entity_types_set: 1, locale: Em.I18n.currentLocale} + ) + }); + return promise; + } +}; diff --git a/app/javascripts/models/region.js b/app/javascripts/models/region.js index 46a76c4..21128d5 100644 --- a/app/javascripts/models/region.js +++ b/app/javascripts/models/region.js @@ -4,5 +4,5 @@ Checklist.Region = DS.Model.extend({ }); Checklist.Region.reopenClass({ - collectionUrl: 'geo_entities?geo_entity_types_set=1&1' + collectionUrl: 'geo_entities' }); diff --git a/app/javascripts/models/timeline.js b/app/javascripts/models/timeline.js index 4f4f546..89406aa 100644 --- a/app/javascripts/models/timeline.js +++ b/app/javascripts/models/timeline.js @@ -18,7 +18,6 @@ Checklist.Timeline = DS.Model.extend({ timeline_intervals: DS.hasMany('Checklist.TimelineInterval', { embedded: true }), timelines: DS.hasMany('Checklist.Timeline', { embedded: true }), parties: DS.attr('array', { defaultValue: [] }), - hasNestedTimelines: function(){ - return this.get('timelines.length') > 0; - }.property() + continuesInPresent: DS.attr('boolean'), + hasNestedTimelines: DS.attr('boolean') }); diff --git a/app/javascripts/models/timelines_for_taxon_concept.js b/app/javascripts/models/timelines_for_taxon_concept.js index 7b31516..965b317 100644 --- a/app/javascripts/models/timelines_for_taxon_concept.js +++ b/app/javascripts/models/timelines_for_taxon_concept.js @@ -3,10 +3,11 @@ Checklist.TimelinesForTaxonConcept = DS.Model.extend({ taxon_concept_id: DS.attr('number'), timelines: DS.hasMany('Checklist.Timeline', { embedded: true }), timeline_years: DS.hasMany('Checklist.TimelineYear', { embedded: true }), - has_descendant_timelines: DS.attr('boolean'), - has_events: DS.attr('boolean') + hasDescendantTimelines: DS.attr('boolean'), + hasEvents: DS.attr('boolean'), + hasReservations: DS.attr('boolean') }); Checklist.TimelinesForTaxonConcept.reopenClass({ - url: 'timelines?taxon_concept_ids=%@' + collectionUrl: 'timelines' }); diff --git a/app/javascripts/routers/router.js b/app/javascripts/routers/router.js index 1c5cfca..9f22e38 100644 --- a/app/javascripts/routers/router.js +++ b/app/javascripts/routers/router.js @@ -1,54 +1,164 @@ Checklist.Router = Ember.Router.extend({ location: Checklist.CONFIG.url_type, + //enableLogging: true, root: Ember.Route.extend({ - home: Ember.Route.extend({ + + index: Ember.Route.extend({ route: '/', connectOutlets: function(router, event) { - var params = router.get('filtersController').toParams(); - router.get('taxonConceptController').refresh(params); - - router.get('applicationController').connectOutlet({outletName: 'header', viewClass: Checklist.MainHeaderView}); - router.get('applicationController').connectOutlet({outletName: 'main', viewClass: Checklist.MainView}); + router.transitionTo('home.index', {locale: Em.I18n.currentLocale}); } }), - search: Ember.Route.extend({ - route: '/search/:params', + home: Ember.Route.extend({ + route: '/:locale', connectOutlets: function(router, event) { - var params = Checklist.Helpers.deparam(event.params); + var locale = event.locale; + if (locale !== 'en' && locale !== 'es' && locale !== 'fr'){ + locale = 'en'; + } + Em.I18n.translations = Em.I18n.locales[locale]; + Ember.set('Em.I18n.currentLocale', locale); + window.console && console.log('CURRENT LOCALE IS:', Em.I18n.currentLocale); + }, + + index: Ember.Route.extend({ + route: '/', + connectOutlets: function(router, event) { + Checklist.LocationsLoader.load().then( + function(locations){ + router.get('filtersController').set( + 'countriesContent', locations.countries + ); + router.get('filtersController').set( + 'regionsContent', locations.regions + ); + var params = router.get('filtersController').toParams(); + router.get('taxonConceptController').refresh(params); + + router.get('applicationController').connectOutlet({ + outletName: 'header', viewClass: Checklist.MainHeaderView + }); + router.get('applicationController').connectOutlet({ + outletName: 'main', viewClass: Checklist.MainView + }); + }, function(error){ + window.console && console.log(error); + } + ); + } + }), + + search: Ember.Route.extend({ + route: '/search/:params', + connectOutlets: function(router, event) { + Checklist.LocationsLoader.load().then( + function(locations){ + router.get('filtersController').set( + 'countriesContent', locations.countries + ); + router.get('filtersController').set( + 'regionsContent', locations.regions + ); + var params = Checklist.Helpers.deparam(event.params); + + router.get('filtersController').fromParams(params); + router.get('taxonConceptController').refresh(params); + + if (event.redraw === undefined || event.redraw) { + router.get('applicationController').connectOutlet({ + outletName: 'header', viewClass: Checklist.MainHeaderView + }); + } + router.get('applicationController').connectOutlet({ + outletName: 'main', viewClass: Checklist.MainView + }); + }, function(error){ + window.console && console.log(error); + } + ); + } + }), + + about: Ember.Route.extend({ + route: '/about', + connectOutlets: function(router, event) { + Checklist.StaticPage.getCompiledTemplate('about_page').then(function(template) { + router.get('applicationController').connectOutlet({ + outletName: 'header', viewClass: Checklist.AboutHeaderView + }); + router.get('applicationController').connectOutlet({ + outletName: 'main', viewClass: Checklist.AboutView + }); + }, function(error) { + window.console && console.log(error); + router.transitionTo('index'); + }); + } + }), + + termsOfUse: Ember.Route.extend({ + route: '/terms-of-use', + connectOutlets: function(router, event) { + Checklist.StaticPage.getCompiledTemplate('terms_of_use_page').then(function(template) { + router.get('applicationController').connectOutlet({ + outletName: 'header', viewClass: Checklist.TermsOfUseHeaderView + }); + router.get('applicationController').connectOutlet({ + outletName: 'main', viewClass: Checklist.TermsOfUseView + }); + }, function(error) { + window.console && console.log(error); + router.transitionTo('index'); + }); + } + }), - router.get('filtersController').fromParams(params); - router.get('taxonConceptController').refresh(params); + doLocaleEN: function(router, event) { + var newLocale = 'en'; + var newState; + if (router.get('currentState.name') == 'search'){ + newState = 'index'; + } else { + newState = router.get('currentState.name'); + } + router.transitionTo(newState, {locale: newLocale}); + }, - if (event.redraw === undefined || event.redraw) { - router.get('applicationController').connectOutlet({outletName: 'header', viewClass: Checklist.MainHeaderView}); + doLocaleES: function(router, event) { + var newLocale = 'es'; + var newState; + if (router.get('currentState.name') == 'search'){ + newState = 'index'; + } else { + newState = router.get('currentState.name'); } + router.transitionTo(newState, {locale: newLocale}); + }, - router.get('applicationController').connectOutlet({outletName: 'main', viewClass: Checklist.MainView}); + doLocaleFR: function(router, event) { + var newLocale = 'fr'; + var newState; + if (router.get('currentState.name') == 'search'){ + newState = 'index'; + } else { + newState = router.get('currentState.name'); + } + router.transitionTo(newState, {locale: newLocale}); } }), + doHome: function(router, event) { + router.transitionTo('index'); + }, + doAbout: function(router, event) { router.transitionTo('about'); }, - about: Ember.Route.extend({ - route: '/about', - connectOutlets: function(router, event) { - router.get('applicationController').connectOutlet({outletName: 'header', viewClass: Checklist.AboutHeaderView}); - router.get('applicationController').connectOutlet({outletName: 'main', viewClass: Checklist.AboutView}); - } - }), doTermsOfUse: function(router, event) { router.transitionTo('termsOfUse'); - }, - termsOfUse: Ember.Route.extend({ - route: '/terms-of-use', - connectOutlets: function(router, event) { - router.get('applicationController').connectOutlet({outletName: 'header', viewClass: Checklist.TermsOfUseHeaderView}); - router.get('applicationController').connectOutlet({outletName: 'main', viewClass: Checklist.TermsOfUseView}); - } - }) + } }) }); diff --git a/app/javascripts/static_page.js b/app/javascripts/static_page.js new file mode 100644 index 0000000..35b2c8f --- /dev/null +++ b/app/javascripts/static_page.js @@ -0,0 +1,22 @@ +Checklist.StaticPage = { + getCompiledTemplate: function(templateName){ + var promise = new RSVP.Promise(); + var template = templateName + '_' + Em.I18n.currentLocale; + var compiledTemplate = Ember.TEMPLATES[template]; + if (compiledTemplate === undefined){ + $.ajax({ + url: '/' + template + '.html', + dataType: 'html', + success: function(data){ + compiledTemplate = Ember.Handlebars.compile(data); + Ember.TEMPLATES[templateName] = compiledTemplate; + promise.resolve(template); + }, + error: function(xhr, msg){ + promise.reject(msg); + } + }); + } + return promise; + } +}; diff --git a/app/javascripts/templates/about_header_view.handlebars b/app/javascripts/templates/about_header_view.handlebars index 052b445..fa49804 100644 --- a/app/javascripts/templates/about_header_view.handlebars +++ b/app/javascripts/templates/about_header_view.handlebars @@ -3,13 +3,18 @@