Skip to content

Commit

Permalink
Аватар 12. В about подтягиваются актуальные аватары
Browse files Browse the repository at this point in the history
  • Loading branch information
klimashkin committed Aug 20, 2013
1 parent c8c2c84 commit 35a699e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
28 changes: 28 additions & 0 deletions controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,28 @@ function giveNewsPublic(data, cb) {
News.findOne({cid: data.cid}, {_id: 0, cid: 1, user: 1, pdate: 1, title: 1, txt: 1, ccount: 1, nocomments: 1}).populate({path: 'user', select: {_id: 0, login: 1, avatar: 1, disp: 1}}).exec(cb);
}

/**
* Аватары для About
*/
var giveAbout = (function () {
var select = {_id: 0, login: 1, avatar: 1},
options = {lean: true};

return Utils.memoizeAsync(function (handler) {
User.find({login: {$in: ['Ilya', 'Duche', 'klimashkin', 'dema501', 'abdulla_hasan']}}, select, options, function (err, users) {
if (err || !users) {
users = [];
}
var result = {}, i;
for (i = users.length; i--;) {
result[users[i].login] = users[i].avatar || '/img/caps/avatar.png';
}
handler(result);
});
}, ms('1m'));
}());


module.exports.loadController = function (app, db, io) {
var logger = log4js.getLogger("index.js");
appvar = app;
Expand Down Expand Up @@ -341,5 +363,11 @@ module.exports.loadController = function (app, db, io) {
socket.emit('takeStats', resultData);
});
});

socket.on('giveAbout', function () {
giveAbout(function (resultData) {
socket.emit('takeAbout', resultData);
});
});
});
};
18 changes: 12 additions & 6 deletions public/js/module/diff/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
/**
* Модель О проекте
*/
define(['underscore', 'Params', 'knockout', 'm/_moduleCliche', 'globalVM', 'text!tpl/diff/about.jade', 'css!style/diff/about'], function (_, P, ko, Cliche, globalVM, jade) {
define(['underscore', 'Params', 'socket!', 'knockout', 'm/_moduleCliche', 'globalVM', 'text!tpl/diff/about.jade', 'css!style/diff/about'], function (_, P, socket, ko, Cliche, globalVM, jade) {
'use strict';

return Cliche.extend({
jade: jade,
create: function () {
ko.applyBindings(globalVM, this.$dom[0]);
this.show();
},
show: function () {
globalVM.func.showContainer(this.$container);
this.showing = true;
ga('send', 'event', 'about', 'open');
//ga('send', 'pageview', {'page': '/about', 'title': 'О проекте'});
socket.once('takeAbout', function (result) {
this.avatars = result || {};

ko.applyBindings(globalVM, this.$dom[0]);
globalVM.func.showContainer(this.$container);
this.showing = true;

ga('send', 'event', 'about', 'open');
//ga('send', 'pageview', {'page': '/about', 'title': 'О проекте'});
}.bind(this));
socket.emit('giveAbout');
},
hide: function () {
globalVM.func.hideContainer(this.$container);
Expand Down
10 changes: 5 additions & 5 deletions views/module/diff/about.jade
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.flip-container
.flipper
div.front(style="background-image: url(/img/misc/Ilya.jpg)")
div.back(style="background-image: url(/_a/d/Ilya.png)")
div.back(data-bind="style: {backgroundImage: 'url(/_a/d/' + avatars['Ilya'] + ')'}")
| Ilya
.lineBody
.humanName Илья Варламов
Expand All @@ -18,7 +18,7 @@
.flip-container
.flipper
div.front(style="background-image: url(/img/misc/Duche.jpg)")
div.back(style="background-image: url(/_a/d/Duche.png)")
div.back(data-bind="style: {backgroundImage: 'url(/_a/d/' + avatars['Duche'] + ')'}")
| Duche
.lineBody
.humanName Алексей Дук
Expand All @@ -28,7 +28,7 @@
.flip-container
.flipper
div.front(style="background-image: url(/img/misc/klimashkin.jpg)")
div.back(style="background-image: url(/_a/d/klimashkin.png)")
div.back(data-bind="style: {backgroundImage: 'url(/_a/d/' + avatars['klimashkin'] + ')'}")
| klimashkin
.lineBody
.humanName Павел Климашкин
Expand All @@ -37,7 +37,7 @@
.flip-container
.flipper
div.front(style="background-image: url(/img/misc/dema501.png)")
div.back(style="background-image: url(/_a/d/dema501.png)")
div.back(data-bind="style: {backgroundImage: 'url(/_a/d/' + avatars['dema501'] + ')'}")
| dema501
.lineBody
.humanName Дмитрий Башлов
Expand All @@ -46,7 +46,7 @@
.flip-container
.flipper
div.front(style="background-image: url(/img/misc/abdulla_hasan.png)")
div.back(style="background-image: url(/_a/d/abdulla_hasan.png)")
div.back(data-bind="style: {backgroundImage: 'url(/_a/d/' + avatars['abdulla_hasan'] + ')'}")
| abdulla_hasan
.lineBody
.humanName Anvar Paganini
Expand Down

0 comments on commit 35a699e

Please sign in to comment.