timeline update;

This commit is contained in:
tmshv committed 2015-03-07 18:55:07 +03:00
1 parent 435c8aef7f
commit 0a3c530599
4 files changed
+77 -30

No files matched your search

+51 -11
View File
@@ -41,21 +41,61 @@ module.exports = function(app) {
controller: function($scope, api){
api.news.feed()
.success(function (list) {
$scope.feed = list.map(function (post) {
var author_id = personByInstagram(team.team, post.data.user.username);
var name = author_id ? team.short(author_id) : post.data.user.username;
var feed = list.map(function (post) {
if(post.type == "instagram"){
var author_id = personByInstagram(team.team, post.data.user.username);
var name = author_id ? team.short(author_id) : post.data.user.username;
return {
date: post.publishDate,
image: post.data.images.standard_resolution.url,
url: post.data.link,
username: name,
userpic: post.data.user.profile_picture,
text: postText(post)
};
return {
date: post.publishDate,
image: post.data.images.standard_resolution.url,
url: post.data.link,
username: name,
userpic: post.data.user.profile_picture,
text: postText(post),
type: post.type
};
}else{
return post;
}
});
$scope.feed = feed;
});
}
};
});
app.directive("timelineRecord", function ($compile, $http, $sce, team) {
var templates = {
"post": ["/views/timeline-post.html", linkPost],
"instagram": ["/views/timeline-gram.html", linkGram]
};
function linkPost(scope, element, attrs) {
scope.message = $sce.trustAsHtml(scope.post.body);
}
function linkGram(scope, element, attrs) {
scope.lal = "LAL";
}
return {
restrict: "E",
scope: {
post:"=content"
},
link: function(scope, element, attrs){
var type = scope.post.type;
if(type in templates) {
$http.get(templates[type][0])
.success(function (tpl) {
element.html(tpl).show();
$compile(element.contents())(scope);
templates[type][1](scope, element, attrs);
});
}
}
};
});
};
+15
View File
@@ -0,0 +1,15 @@
<div class="head">
<div class="user">
<img ng-src="{{post.userpic}}" alt=""/>
<span>{{post.username}}</span>
</div>
<p class="date">{{post.date | date : "dd.MM.yyyy"}}</p>
</div>
<div class="body">
<!--<h2>Рисунок</h2>-->
<p>{{post.text}}</p>
<a href="{{post.url}}" target="_blank">
<img ng-src="{{post.image}}" alt="">
</a>
</div>
+6
View File
@@ -0,0 +1,6 @@
<div class="head">
<a name="{{post.uri}}"></a>
<p class="date"><a href="#{{post.uri}}">{{post.date | date : "dd.MM.yyyy"}}</a></p>
</div>
<div class="body" ng-bind-html="message"></div>
+5 -19
View File
@@ -1,22 +1,8 @@
<div class="timeline">
<div class="post"
ng-repeat="post in feed"
ng-class="{left: isEven($index), right: !isEven($index)}">
<timeline-record class="post"
content="post"
ng-repeat="post in feed"
ng-class="{left: isEven($index), right: !isEven($index)}">
<div class="head">
<div class="user">
<img ng-src="{{post.userpic}}" alt=""/>
<span>{{post.username}}</span>
</div>
<p class="date">{{post.date | date : "dd.MM.yyyy"}}</p>
</div>
<div class="body">
<!--<h2>Рисунок</h2>-->
<p>{{post.text}}</p>
<a href="{{post.url}}" target="_blank">
<img ng-src="{{post.image}}" alt="">
</a>
</div>
</div>
</timeline-record>
</div>