/// <summary> /// Returns a value from the ancestor specified by ancestorAlias. /// </summary> /// <param name="node"></param> /// <param name="ancestorAlias"></param> /// <param name="propertyAlias"></param> /// <returns></returns> public string GetValueFromAncestor(IPublishedContent node, string ancestorAlias, string propertyAlias) { string cacheKey = "uBlogsy_GetValueFromAncestor_" + ancestorAlias; var root = CacheHelper.GetFromRequestCache(cacheKey) as IPublishedContent; if (root == null) { root = node.AncestorOrSelf(ancestorAlias); CacheHelper.AddToRequestCache(cacheKey, root); } return(root.GetProperty(propertyAlias).Value.ToString()); }
/// <summary> /// Gets landing node, caches result. /// </summary> /// <param name="node">A node which is a descendant of landing.</param> /// <returns></returns> public IPublishedContent GetLanding(IPublishedContent node) { string cacheKey = "GetLanding_uBlogsyLanding"; var cached = CacheHelper.GetFromRequestCache(cacheKey) as IPublishedContent; if (cached != null) { return(cached); } var landing = node.AncestorOrSelf("uBlogsyLanding"); // cache the result CacheHelper.AddToRequestCache(cacheKey, landing); return(landing); }
/// <summary> /// Returns all the posts. /// </summary> /// <param name="nodeId"></param> /// <returns></returns> public IEnumerable <IPublishedContent> GetPosts(int nodeId) { string cacheKey = "NoLuceneFallBack_GetPosts_uBlogsyPosts"; var cached = CacheHelper.GetFromRequestCache(cacheKey) as IEnumerable <IPublishedContent>; if (cached != null) { return(cached); } var landing = DataService.Instance.GetLanding(IPublishedContentHelper.GetNode(nodeId)); IEnumerable <IPublishedContent> nodes = landing.DescendentsOrSelf("uBlogsyPost", new[] { "uBlogsyContainerPage", "uBlogsyPage", "uBlogsyContainerComment", "uBlogsyComment" }).OrderByDescending(x => x.GetProperty("uBlogsyPostDate").Value); // cache the result CacheHelper.AddToRequestCache(cacheKey, nodes); return(nodes); }
/// <summary> /// Gets landing node, caches result. /// </summary> /// <param name="node"></param> /// <returns></returns> public IPublishedContent GetSiteRoot(IPublishedContent node, string rootNodeTypeAlias) { string cacheKey = "GetSiteRoot_uBlogsySiteRoot"; string noBlogsySiteRootcacheKey = "GetSiteRoot_No_uBlogsySiteRoot"; // this is all a little bit hacky... // try to get the "no site root result" from cache var cachedNoSiteRoot = CacheHelper.GetFromRequestCache(noBlogsySiteRootcacheKey) as string; if (!string.IsNullOrEmpty(cachedNoSiteRoot) && cachedNoSiteRoot == noBlogsySiteRootcacheKey) { // we've already cached the fact that there is no root. return(null); } // try to get the siteRoot from cache var cached = CacheHelper.GetFromRequestCache(cacheKey) as IPublishedContent; if (cached != null) { return(cached); } // try to get the site root var root = node.AncestorOrSelf(rootNodeTypeAlias); // uBlogsySiteRoot was not found, so just return null if (root == null) { // cache the fact that there is no site root CacheHelper.AddToRequestCache(noBlogsySiteRootcacheKey, noBlogsySiteRootcacheKey); return(null); } // cache the result CacheHelper.AddToRequestCache(cacheKey, root); return(root); }