gallery update: years, /gallery... -> /album...;

This commit is contained in:
tmshv committed 2015-07-05 20:42:24 +03:00
1 parent d16bb492aa
commit e8a65edde1
5 files changed
+87 -12

No files matched your search

+23
View File
@@ -1,11 +1,34 @@
//.gallery-block {
// margin: 2em 0 0;
// display: flex;
// justify-content: center;
// flex-wrap: wrap;
// align-items: flex-start;
//}
.gallery-block { .gallery-block {
margin: 2em 0 0; margin: 2em 0 0;
display: block;
}
.gallery-period{
margin-bottom: 2em;
& > div{
margin: 1.5em 0 0;
display: flex; display: flex;
justify-content: center; justify-content: center;
flex-wrap: wrap; flex-wrap: wrap;
align-items: flex-start; align-items: flex-start;
} }
p.period{
text-align: center;
font-size: 1.5em;
font-weight: bold;
}
}
.gallery-album { .gallery-album {
margin: 0 1em 2em; margin: 0 1em 2em;
+1 -1
View File
@@ -40,7 +40,7 @@ app.config(function ($locationProvider, $routeProvider) {
title:"Работы учащихся" title:"Работы учащихся"
}, },
{ {
name: "/gallery/:year/:course/:album", name: "/album/:year/:course/:album",
templateUrl: "/views/gallery-album.html", templateUrl: "/views/gallery-album.html",
controller: "AlbumPageController", controller: "AlbumPageController",
title:"Работы учащихся" title:"Работы учащихся"
+27 -6
View File
@@ -21,20 +21,40 @@ module.exports = function (app) {
}); });
app.controller("GalleryPageController", function ($scope, $http) { app.controller("GalleryPageController", function ($scope, $http) {
$http.get("/gallery") $scope.years = [];
var years = [2015, 2014, 2013, 2012, 2011, 2010];
years.forEach(function (year, year_index) {
$http.get("/gallery/" + year)
.success(function (albums) { .success(function (albums) {
$scope.albums = albums.map(function (album) { if(albums.length) {
$scope.years[year_index] = {
year: year,
albums: albums.map(function (album) {
var preview = album.content[0]; var preview = album.content[0];
album.preview_url = preview.content.medium.url; album.preview_url = preview.content.medium.url;
album.fotorama = album.content.map(productToFotorama); album.fotorama = album.content.map(productToFotorama);
return album; return album;
})
};
}
})
}); });
}); //$http.get("/gallery")
}); // .success(function (albums) {
// $scope.albums = albums.map(function (album) {
// var preview = album.content[0];
// album.preview_url = preview.content.medium.url;
// album.fotorama = album.content.map(productToFotorama);
//
// return album;
// });
// });
}
);
app.controller("AlbumPageController", function ($scope, $http, $routeParams) { app.controller("AlbumPageController", function ($scope, $http, $routeParams) {
var url = '/gallery/{year}/{course}/{album}' var url = '/album/{year}/{course}/{album}'
.replace('{year}', $routeParams.year) .replace('{year}', $routeParams.year)
.replace('{course}', $routeParams.course) .replace('{course}', $routeParams.course)
.replace('{album}', $routeParams.album); .replace('{album}', $routeParams.album);
@@ -47,7 +67,8 @@ module.exports = function (app) {
$scope.album = album; $scope.album = album;
}); });
}); });
}; }
;
function productToFotorama(product) { function productToFotorama(product) {
return { return {
+21 -2
View File
@@ -22,7 +22,26 @@ module.exports = function (app) {
} }
}))); })));
app.use(route.get("/gallery/:year/:course/:album", router.accepts({ app.use(route.get("/gallery/:year", router.accepts({
"text/html": router.index(),
"text/plain": router.index(),
"application/json": function *(year) {
year = parseInt(year);
var start = new Date(year, 0, 1);
var end = new Date(year, 11, 31);
var query = {
date: {$gte: start, $lt: end}
};
var albums = yield db.c("albums")
.find(query)
.toArray();
albums = yield albums.map(processAlbum);
this.body = albums;
}
})));
app.use(route.get("/album/:year/:course/:album", router.accepts({
"text/html": router.index(), "text/html": router.index(),
"text/plain": router.index(), "text/plain": router.index(),
"application/json": function *(year, course, album) { "application/json": function *(year, course, album) {
@@ -46,7 +65,7 @@ module.exports = function (app) {
function processAlbum(album) { function processAlbum(album) {
return co(function *() { return co(function *() {
album.url = '/gallery/{year}{course}{album}' album.url = '/album/{year}{course}{album}'
.replace('{year}', album.date.getFullYear()) .replace('{year}', album.date.getFullYear())
.replace('{course}', album.course_uri) .replace('{course}', album.course_uri)
.replace('{album}', album.uri); .replace('{album}', album.uri);
+15 -3
View File
@@ -1,10 +1,22 @@
<div class="gallery-block" ng-controller="GalleryPageController"> <div class="gallery-block" ng-controller="GalleryPageController">
<div class="gallery-album" ng-repeat="album in albums">
<div class="gallery-period" ng-repeat="period in years">
<p class="period">{{period.year}}</p>
<div><div class="gallery-album" ng-repeat="album in period.albums">
<h3><a href="{{album.url}}">{{album.title}}</a></h3> <h3><a href="{{album.url}}">{{album.title}}</a></h3>
<a href="{{album.url}}" class="invisible"> <a href="{{album.url}}" class="invisible">
<img ng-src="{{album.preview_url}}" alt=""/> <img ng-src="{{album.preview_url}}" alt=""/>
</a> </a>
<p>{{album.course}}</p>
</div></div>
</div>
<!--<div class="fotorama" g-fotorama content="album.content"></div>-->
</div> <!--<div class="gallery-album" ng-repeat="album in albums">-->
<!--<h3><a href="{{album.url}}">{{album.title}}</a></h3>-->
<!--<a href="{{album.url}}" class="invisible">-->
<!--<img ng-src="{{album.preview_url}}" alt=""/>-->
<!--</a>-->
<!--<p>{{album.course}}</p>-->
<!--</div>-->
</div> </div>