+ gallery page
This commit is contained in:
1 parent
241812c6cf
commit
c72f44ea8b
11 files changed
+195
-2
No files matched your search
@@ -0,0 +1,21 @@
|
||||
.gallery-block {
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.gallery-album {
|
||||
margin: 0 20px 30px;
|
||||
}
|
||||
|
||||
.gallery-album img {
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.album-block {
|
||||
width: 70%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
@@ -20,6 +20,24 @@ a:active {
|
||||
border-bottom: 1px solid rgb(63, 156, 234);
|
||||
}
|
||||
|
||||
h3 a{
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid #ddd;
|
||||
|
||||
&:hover {
|
||||
border-bottom: 1px solid #484848;
|
||||
}
|
||||
|
||||
&:active {
|
||||
border-bottom: 1px solid #000000;
|
||||
}
|
||||
}
|
||||
|
||||
a.invisible {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
ul.submenu {
|
||||
list-style: none;
|
||||
display: inline-block;
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
&.pink {
|
||||
border-top: 4px solid #f655a0;
|
||||
}
|
||||
|
||||
&.red {
|
||||
border-top: 4px solid #f61b14;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,18 @@ app.config(function ($locationProvider, $routeProvider) {
|
||||
controller: "TeamPageController",
|
||||
title:"Преподаватели"
|
||||
},
|
||||
{
|
||||
name: "/gallery",
|
||||
templateUrl: "/views/gallery.html",
|
||||
controller: "GalleryPageController",
|
||||
title:"Работы учащихся"
|
||||
},
|
||||
{
|
||||
name: "/gallery/:year/:course/:album",
|
||||
templateUrl: "/views/gallery-album.html",
|
||||
controller: "AlbumPageController",
|
||||
title:"Работы учащихся"
|
||||
},
|
||||
{
|
||||
name: "/docs",
|
||||
templateUrl: "/views/docs.html",
|
||||
@@ -76,6 +88,7 @@ require("./filters/uppercase-first")(app);
|
||||
require("./pages/home")(app);
|
||||
require("./pages/schedule")(app);
|
||||
require("./pages/team")(app);
|
||||
require("./pages/gallery")(app);
|
||||
require("./pages/docs")(app);
|
||||
|
||||
app.controller("SchedulePageController", function ($scope) {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
module.exports = function (app) {
|
||||
app.directive("gFotorama", function(){
|
||||
return {
|
||||
restrict: "A",
|
||||
link: function(scope, element, attrs){
|
||||
element.addClass('fotorama');
|
||||
var fotorama = $(element.fotorama()).data('fotorama');
|
||||
fotorama.setOptions({
|
||||
width: "100%",
|
||||
maxheight: 500,
|
||||
loop: true,
|
||||
nav: "thumbs"
|
||||
});
|
||||
|
||||
scope.$watch(attrs.gFotorama, function (value){
|
||||
console.log(value);
|
||||
fotorama.load(value);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.controller("GalleryPageController", function ($scope, $http) {
|
||||
$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) {
|
||||
var url = '/gallery/{year}/{course}/{album}'
|
||||
.replace('{year}', $routeParams.year)
|
||||
.replace('{course}', $routeParams.course)
|
||||
.replace('{album}', $routeParams.album);
|
||||
$http.get(url)
|
||||
.success(function (album) {
|
||||
var preview = album.content[0];
|
||||
album.preview_url = preview.content.medium.url;
|
||||
album.fotorama = album.content.map(productToFotorama);
|
||||
|
||||
$scope.album = album;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function productToFotorama(product) {
|
||||
return {
|
||||
img: product.content["big"].url,
|
||||
thumb: product.content["small"].url,
|
||||
full: product.content["original"].url
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -34,7 +34,7 @@ gulp.task("compile", function(){
|
||||
.pipe(browserify({
|
||||
transform: [annotate]
|
||||
}))
|
||||
.pipe(uglify())
|
||||
//.pipe(uglify())
|
||||
.pipe(gulp.dest("public"));
|
||||
|
||||
gulp.src("client/document.js")
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@
|
||||
},
|
||||
{
|
||||
"text": "Галерея",
|
||||
"color": ""
|
||||
"url": "/gallery",
|
||||
"color": "red"
|
||||
},
|
||||
{
|
||||
"text": "Документы",
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Created by tmshv on 22/11/14.
|
||||
*/
|
||||
|
||||
var co = require("co");
|
||||
var route = require("koa-route");
|
||||
var router = require("./");
|
||||
var db = require("../core/db");
|
||||
|
||||
module.exports = function (app) {
|
||||
app.use(route.get("/gallery", router.accepts({
|
||||
"text/html": router.index(),
|
||||
"text/plain": router.index(),
|
||||
"application/json": function *() {
|
||||
var query = {};
|
||||
var albums = yield db.c("albums")
|
||||
.find(query)
|
||||
.toArray();
|
||||
|
||||
albums = yield albums.map(processAlbum);
|
||||
this.body = albums;
|
||||
}
|
||||
})));
|
||||
|
||||
app.use(route.get("/gallery/:year/:course/:album", router.accepts({
|
||||
"text/html": router.index(),
|
||||
"text/plain": router.index(),
|
||||
"application/json": function *(year, course, album) {
|
||||
year = parseInt(year);
|
||||
course = '/' + course;
|
||||
album = '/' + album;
|
||||
var start = new Date(year, 0, 1);
|
||||
var end = new Date(year, 11, 31);
|
||||
var query = {
|
||||
date: {$gte: start, $lt: end},
|
||||
course_uri: course,
|
||||
uri: album
|
||||
};
|
||||
|
||||
var a = yield db.c("albums").findOne(query);
|
||||
a = yield processAlbum(a);
|
||||
this.body = a;
|
||||
}
|
||||
})));
|
||||
};
|
||||
|
||||
function processAlbum(album) {
|
||||
return co(function *() {
|
||||
album.url = '/gallery/{year}{course}{album}'
|
||||
.replace('{year}', album.date.getFullYear())
|
||||
.replace('{course}', album.course_uri)
|
||||
.replace('{album}', album.uri);
|
||||
|
||||
album.content = yield album.content.map(function (product_id) {
|
||||
return co(function *() {
|
||||
var product = yield db.c("products").findOne({_id: product_id});
|
||||
if (product) return product;
|
||||
else return null;
|
||||
});
|
||||
});
|
||||
|
||||
return album;
|
||||
});
|
||||
}
|
||||
@@ -54,6 +54,7 @@ app.use(route.get("/document/:doc", routes.index(
|
||||
|
||||
require("./routes/schedule")(app);
|
||||
require("./routes/news")(app);
|
||||
require("./routes/gallery")(app);
|
||||
|
||||
require("./routes/404")(app);
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<div class="album-block" ng-controller="AlbumPageController">
|
||||
<h3>{{album.title}}</h3>
|
||||
<div g-fotorama="album.fotorama"></div>
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
<div class="gallery-block" ng-controller="GalleryPageController">
|
||||
<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>
|
||||
<!--<div class="fotorama" g-fotorama content="album.content"></div>-->
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user