Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Closes #81 - permite que :siteName seja usado nos posts
Browse files Browse the repository at this point in the history
  • Loading branch information
teles committed Nov 28, 2016
1 parent c660dc1 commit 6d8ee84
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/js/views/post/controllers/post-directive.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var module = angular.module("frontpress.views.post");

function PostDirectiveController(FullPostModel, $stateParams, PageHeadModel, SlugsMapModel, $FrontPress, CategoriesApi, ApiManager){
function PostDirectiveController(FullPostModel, $stateParams, PageHeadModel, SlugsMapModel, $FrontPress, CategoriesApi, ApiManager, BlogModel, $q){
var vc = this;
vc.vm = FullPostModel;
var postSlug = $stateParams.postSlug;
Expand All @@ -26,24 +26,33 @@ function PostDirectiveController(FullPostModel, $stateParams, PageHeadModel, Slu
}

var fullPostPromise = FullPostModel.loadFullPostById(postId);
var blogInformationPromise = BlogModel.getInformationPromise();

PageHeadModel.init();

fullPostPromise.then(function(result){

var postTitle = ApiManager.getPath(result, "postTitle");
var postDateInfo = ApiManager.getPath(result, "postDate").getDateInfo();
var promises = [fullPostPromise, blogInformationPromise];
$q.all(promises).then(function(result){

var fullPostResult = result[0];
var blogInformationResult = result[1];

var postTitle = ApiManager.getPath(fullPostResult, "postTitle");
var postDateInfo = ApiManager.getPath(fullPostResult, "postDate").getDateInfo();

var titleReplaceRules = {
":postTitle": postTitle,
":year": postDateInfo.year,
":month": postDateInfo.month,
":day": postDateInfo.day,
":siteName": blogInformationResult.name,
":siteDescription": blogInformationResult.description,
};

PageHeadModel.parsePageTitle("post", titleReplaceRules);
vc.disqusId = FullPostModel.slug;
});

})
}

module.controller("PostDirectiveController", PostDirectiveController);
1 change: 1 addition & 0 deletions src/js/views/post/post.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ angular.module("frontpress.views.post",
"frontpress.components.share",
"ui.router",
"frontpress.components.page-head",
"frontpress.components.blog",
"ngDisqus",
"frontpress.components.slugs-map",
"frontpress.components.api-manager",
Expand Down

0 comments on commit 6d8ee84

Please sign in to comment.