views, path, search...
--- a/.hgignore Wed Jun 11 01:26:59 2014 +0200
+++ b/.hgignore Thu Oct 02 13:24:57 2014 +0200
@@ -4,3 +4,4 @@
^client/node_modules/
^client/bower_components/
^client/build/
+\.project$
--- a/client/app/app.js Wed Jun 11 01:26:59 2014 +0200
+++ b/client/app/app.js Thu Oct 02 13:24:57 2014 +0200
@@ -1,7 +1,7 @@
(function(){
'use strict';
- angular.module('ammico', [ 'ngRoute','ammicoHome', 'ammicoGallery', 'ammicoSlideshow', 'templates' ])
+ angular.module('ammico', [ 'ngRoute','ammicoHome', 'ammicoGallery', 'ammicoSlideshow', 'ammicoSearch', 'templates' ])
.config(function($routeProvider) {
$routeProvider.
when('/', {
@@ -12,12 +12,24 @@
controller: 'galleryCtrl',
templateUrl: 'gallery/gallery.html'
}).
- when('/slideshow', {
+ when('/slideshow/', {
+ controller: 'slideshowCtrl',
+ templateUrl: 'slideshow/slideshow.html'
+ }).
+ when('/slideshow/:iSlide', {
controller: 'slideshowCtrl',
templateUrl: 'slideshow/slideshow.html'
}).
+ when('/search/', {
+ controller: 'searchCtrl',
+ templateUrl: 'search/search.html'
+ }).
+ when('/search/:q', {
+ controller: 'searchCtrl',
+ templateUrl: 'search/search.html'
+ }).
otherwise({
- redirectTo: '/gallery'
+ redirectTo: '/'
});
})
// .config(function ($routeProvider) {
--- a/client/app/gallery/gallery_controller.js Wed Jun 11 01:26:59 2014 +0200
+++ b/client/app/gallery/gallery_controller.js Thu Oct 02 13:24:57 2014 +0200
@@ -10,13 +10,7 @@
});
})
.service('galleryApi', function($resource, context) {
- this.gallery = $resource(context.urls.galleryUrl,
- {
- get: {
- method: 'GET',
- isArray: false
- }
- });
+ this.gallery = $resource(context.urls.galleryUrl);
})
.service('galleryModel', function(galleryApi, context) {
console.log('4', context.gallery);
--- a/client/app/home/home_controller.js Wed Jun 11 01:26:59 2014 +0200
+++ b/client/app/home/home_controller.js Thu Oct 02 13:24:57 2014 +0200
@@ -12,6 +12,9 @@
})
.controller('homeCtrl', function($scope, $location){
console.log('5-0',$scope, $location);
+ $scope.searchSubmit = function(){
+ $location.path('/search/' + $scope.q);
+ };
});
})();
--- a/client/app/index.html Wed Jun 11 01:26:59 2014 +0200
+++ b/client/app/index.html Thu Oct 02 13:24:57 2014 +0200
@@ -24,6 +24,12 @@
<li ng-class="{active:isActive('/gallery')}"><a href="#/gallery">Galerie</a></li>
<li ng-class="{active:isActive('/slideshow')}"><a href="#/slideshow">Diaporama</a></li>
</ul>
+ <form class="navbar-form navbar-right" role="search" ng-submit="searchSubmit()">
+ <div class="form-group">
+ <input class="form-control" type="text" ng-model="q" placeholder="Chercher" />
+ <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
+ </div>
+ </form>
</div>
</div>
</div>
@@ -52,7 +58,8 @@
urls: {
base_static: "./",
galleryUrl: "data/gallery.json",
- slideshowUrl: "data/slideshow.json"
+ slideshowUrl: "data/slideshow.json",
+ searchUrl: "http://ammico.labs.exalead.com/search-api"
}
});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/app/search/search.css Thu Oct 02 13:24:57 2014 +0200
@@ -0,0 +1,19 @@
+.item {
+ min-height: 250px;
+ border-bottom: 1px solid #000;
+ padding-top: 10px;
+}
+.item img {
+ max-height: 230px;
+}
+.item p {
+ margin: 0 0 5px;
+}
+
+
+.subtitle {
+ border-top: 1px solid #000;
+ border-bottom: 1px dotted #000;
+ margin-top: 20px;
+ padding: 6px 0 10px;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/app/search/search.html Thu Oct 02 13:24:57 2014 +0200
@@ -0,0 +1,17 @@
+<h1>Recherche <span ng-if="q !='' "> : {{ q }}</span></h1>
+<h4 class="subtitle" ng-if="results.nhits>0">{{ results.nhits }} résultat(s)</h4>
+<div ng-if="results.nhits>0">
+ <div class="row item" ng-repeat="h in results.hits">
+ <img class="col-md-3" src="{{ h.url }}"/>
+ <div class="col-md-8">
+ <p><strong>Nom :</strong> {{ h.metas|meta:"name" }}</p>
+ <p><strong>Description :</strong> {{ h.metas|meta:"description" }}</p>
+ <p><small><strong>Classification :</strong> {{ h.metas|meta:"classification" }}</small></p>
+ <p><small><strong>Current Custody :</strong> {{ h.metas|meta:"currentcustody" }}</small></p>
+ <p><small><strong>Former Custody :</strong> {{ h.metas|meta:"formercustody" }}</small></p>
+ <p><small><strong>Mesures :</strong> {{ h.metas|meta:"measures" }}</small></p>
+ <p><small><strong>Acteurs :</strong> {{ h.metas|meta:"actors" }}</small></p>
+ <p><small><strong>Lieux :</strong> {{ h.metas|meta:"places" }}</small></p>
+ </div>
+ </div>
+</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/app/search/search_controller.js Thu Oct 02 13:24:57 2014 +0200
@@ -0,0 +1,70 @@
+(function(){
+ 'use strict';
+
+ angular.module('ammicoSearch',['ngResource', 'ngRoute'])
+ .config(function ($routeProvider) {
+ $routeProvider
+ .when('/', {
+ templateUrl: 'search/search.html',
+ controller: 'searchCtrl'
+ });
+ })
+ .service('searchApi', function($resource, context) {
+ console.log('search 4',$resource, context);
+ this.searchResource = function(params){
+ return $resource(context.urls.searchUrl,
+ {
+ callback: 'JSON_CALLBACK'
+ },
+ {
+ getJsonp: {
+ method: 'JSONP',
+ params: params,
+ isArray: false
+ }
+ });
+ };
+
+ })
+ .service('searchModel', function(searchApi) {
+ console.log('search 5');
+ this.searchResults = function(params){
+ return searchApi.searchResource(params).getJsonp();
+ };
+ })
+ .controller('searchCtrl', function($scope, $location, $routeParams, searchModel){
+ console.log('search 6',$scope, $location, $routeParams);
+ $scope.q = $routeParams.q || '';
+ searchModel.searchResults({q:$scope.q, of: 'json', synthesis: 'false', callback: 'JSON_CALLBACK'}).$promise.then(
+ //success
+ function( data ){
+ console.log('SUCCESS !', data);
+ $scope.results = data;
+ },
+ //error
+ function( error ){
+ console.log('ERROR !', error);
+ }
+ );
+ //window.myres = res;
+ //$scope.results = res;
+ //console.log('search 6-blabla', res);
+ console.log('search 7', $scope.q);
+
+ //$scope.search = searchModel.search;
+ // query = ?q=violon&of=json&synthesis=false
+ })
+ .filter('meta', function() {
+ return function(input, metaName) {
+ var nb = input.length, i = 0, found = false;
+ while(found===false && i<nb){
+ if(input[i].name===metaName){
+ found = true;
+ return input[i].value;
+ }
+ i++;
+ }
+ };
+ });
+
+})();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/app/search/search_controller_test.js Thu Oct 02 13:24:57 2014 +0200
@@ -0,0 +1,7 @@
+'use strict';
+
+describe("search_controller_test", function(){
+ it("should assert something",function(){
+ expect(true).toBe(true);
+ })
+})
--- a/client/app/slideshow/slideshow.html Wed Jun 11 01:26:59 2014 +0200
+++ b/client/app/slideshow/slideshow.html Thu Oct 02 13:24:57 2014 +0200
@@ -1,8 +1,8 @@
<h1>{{ slideshow.title }}</h1>
<p>{{ slideshow.description }}</p>
<div class="carousel-holder row">
- <carousel >
- <slide ng-repeat="slide in slideshow.images" active="slide.active">
+ <carousel>
+ <slide ng-repeat="slide in slideshow.images" active="slide.active" ng-init="slide.active = (iSlide==$index)">
<div class="row">
<div class="col-md-7 col-md-offset-1">
<img ng-src="{{slide.url}}" style="margin:auto;">
--- a/client/app/slideshow/slideshow_controller.js Wed Jun 11 01:26:59 2014 +0200
+++ b/client/app/slideshow/slideshow_controller.js Thu Oct 02 13:24:57 2014 +0200
@@ -10,17 +10,8 @@
});
})
.service('slideshowApi', function($resource, context) {
- this.slideshow = $resource(context.urls.slideshowUrl,
- {
- get: {
- method: 'GET',
- isArray: false
- },
- save:{
- method:'PUT',
- isArray:false//, headers:{'X-CSRFToken':context.csrf_token}
- }
- });
+ console.log('5',this);
+ this.slideshow = $resource(context.urls.slideshowUrl);
})
.service('slideshowModel', function(slideshowApi, context) {
console.log('6',this);
@@ -33,12 +24,14 @@
this.slideshow = new slideshowApi.slideshow(context.slideshow);
}
})
- .controller('slideshowCtrl', function($scope, $location, slideshowModel){
- console.log('6',$scope, $location, slideshowModel);
+ .controller('slideshowCtrl', function($scope, $location, $routeParams, slideshowModel){
+ console.log('7',$scope, $location, slideshowModel);
$scope.slideshow = slideshowModel.slideshow;
+ $scope.iSlide = parseInt($routeParams.iSlide) || 0;
$scope.save = function(){
- $scope.slideshow
+ console.log('8 call save POST',$scope.slideshow);
+ $scope.slideshow
.$save()
.then(
function(response) {