diff --git a/client/ui/timeline.js b/client/ui/timeline.js index e5f2cc74..6ff12ca3 100644 --- a/client/ui/timeline.js +++ b/client/ui/timeline.js @@ -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); + }); + } + + } + }; + }); }; \ No newline at end of file diff --git a/templates/views/timeline-gram.html b/templates/views/timeline-gram.html new file mode 100644 index 00000000..962143b2 --- /dev/null +++ b/templates/views/timeline-gram.html @@ -0,0 +1,15 @@ +
+
+ + {{post.username}} +
+

{{post.date | date : "dd.MM.yyyy"}}

+
+ +
+ +

{{post.text}}

+ + + +
\ No newline at end of file diff --git a/templates/views/timeline-post.html b/templates/views/timeline-post.html new file mode 100644 index 00000000..4d09752f --- /dev/null +++ b/templates/views/timeline-post.html @@ -0,0 +1,6 @@ +
+ +

{{post.date | date : "dd.MM.yyyy"}}

+
+ +
\ No newline at end of file diff --git a/templates/views/timeline.html b/templates/views/timeline.html index 87155362..2c8d73a8 100644 --- a/templates/views/timeline.html +++ b/templates/views/timeline.html @@ -1,22 +1,8 @@
-
+ -
-
- - {{post.username}} -
-

{{post.date | date : "dd.MM.yyyy"}}

-
- -
- -

{{post.text}}

- - - -
-
+
\ No newline at end of file