internal static PublishedContentSet<IPublishedContent> ConvertSearchResultToPublishedContent(this IEnumerable<SearchResult> results, ContextualPublishedCache cache) { //TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent, // however this is currently not the case: // http://examine.codeplex.com/workitem/10350 var list = new List<IPublishedContent>(); var set = new PublishedContentSet<IPublishedContent>(list); foreach (var result in results.OrderByDescending(x => x.Score)) { var content = cache.GetById(result.Id); if (content == null) continue; // skip if this doesn't exist in the cache // need to extend the content as we're going to add a property to it, // and we should not ever do it to the content we get from the cache, // precisely because it is cached and shared by all requests. // but we cannot wrap it because we need to respect the type that was // returned by the cache, in case the cache can create real types. // so we have to ask it to please extend itself. list.Add(content); var extend = set.MapContent(content); var property = new PropertyResult("examineScore", result.Score, Guid.Empty, PropertyResultType.CustomProperty); extend.AddProperty(property); } return set; }
public static void MapRoutes(RouteCollection routes, ContextualPublishedCache umbracoCache) { //find all articulate root nodes var articulateNodes = umbracoCache.GetByXPath("//Articulate").ToArray(); //NOTE: need to write lock because this might need to be remapped while the app is running if // any articulate nodes are updated with new values using (routes.GetWriteLock()) { //clear the existing articulate routes (if any) RemoveExisting(routes); // For each articulate root, we need to create some custom route, BUT routes can overlap // based on multi-tenency so we need to deal with that. // For example a root articulate node might yield a route like: // / // and another articulate root node that has a domain might have this url: // http://mydomain/ // but when that is processed through RoutePathFromNodeUrl, it becomes: // / // which already exists and is already assigned to a specific node ID. // So what we need to do in these cases is use a special route handler that takes // into account the domain assigned to the route. var groups = articulateNodes .GroupBy(x => RouteCollectionExtensions.RoutePathFromNodeUrl(x.Url)) //This is required to ensure that we create routes that are more specific first // before creating routes that are less specific .OrderByDescending(x => x.Key.Split('/').Length); foreach (var grouping in groups) { var nodesAsArray = grouping.ToArray(); MapRssRoute(routes, grouping.Key, nodesAsArray); MapSearchRoute(routes, grouping.Key, nodesAsArray); MapTagsAndCategoriesRoute(routes, grouping.Key, nodesAsArray); MapMarkdownEditorRoute(routes, grouping.Key, nodesAsArray); foreach (var content in grouping) { MapMetaWeblogRoute(routes, grouping.Key, content); MapManifestRoute(routes, grouping.Key, content); MapRsdRoute(routes, grouping.Key, content); } } } }
internal static IEnumerable<IPublishedContent> ConvertSearchResultToPublishedContent( this IEnumerable<SearchResult> results, ContextualPublishedCache cache) { //TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent, // however thsi is currently not the case: // http://examine.codeplex.com/workitem/10350 var list = new List<IPublishedContent>(); foreach (var result in results.OrderByDescending(x => x.Score)) { var doc = cache.GetById(result.Id); if (doc == null) continue; //skip if this doesn't exist in the cache doc.Properties.Add( new PropertyResult("examineScore", result.Score.ToString(), Guid.Empty, PropertyResultType.CustomProperty)); list.Add(doc); } return list; }
public static void MapRoutes(RouteCollection routes, ContextualPublishedCache umbracoCache) { //find all Dialogue forum root nodes - Testing adding new line var dialogueNodes = umbracoCache.GetByXPath(string.Concat("//", AppConstants.DocTypeForumRoot)).ToArray(); //NOTE: need to write lock because this might need to be remapped while the app is running if // any articulate nodes are updated with new values using (routes.GetWriteLock()) { //clear the existing articulate routes (if any) RemoveExisting(routes); // For each articulate root, we need to create some custom route, BUT routes can overlap // based on multi-tenency so we need to deal with that. // For example a root articulate node might yield a route like: // / // and another articulate root node that has a domain might have this url: // http://mydomain/ // but when that is processed through RoutePathFromNodeUrl, it becomes: // / // which already exists and is already assigned to a specific node ID. // So what we need to do in these cases is use a special route handler that takes // into account the domain assigned to the route. var groups = dialogueNodes.GroupBy(x => RouteCollectionExtensions.RoutePathFromNodeUrl(x.Url)); foreach (var grouping in groups) { var nodesAsArray = grouping.ToArray(); MapTopicRoute(routes, grouping.Key, nodesAsArray); MapDialoguePages(routes, grouping.Key, nodesAsArray); MapMemberRoute(routes, grouping.Key, nodesAsArray); } } }
private dynamic DocumentsAtRoot(ContextualPublishedCache cache) { return new DynamicPublishedContentList( cache.GetAtRoot() .Select(publishedContent => new DynamicPublishedContent(publishedContent)) ); }
private dynamic DocumentByIds(ContextualPublishedCache cache, IEnumerable<int> ids) { var dNull = DynamicNull.Null; var nodes = ids.Select(eachId => DocumentById(eachId, cache, dNull)) .Where(x => TypeHelper.IsTypeAssignableFrom<DynamicNull>(x) == false) .Cast<DynamicPublishedContent>(); return new DynamicPublishedContentList(nodes); }
private dynamic DocumentsByXPath(XPathExpression xpath, XPathVariable[] vars, ContextualPublishedCache cache) { return new DynamicPublishedContentList( cache.GetByXPath(xpath, vars) .Select(publishedContent => new DynamicPublishedContent(publishedContent)) ); }
private dynamic DocumentByXPath(XPathExpression xpath, XPathVariable[] vars, ContextualPublishedCache cache, object ifNotFound) { var doc = cache.GetSingleByXPath(xpath, vars); return doc == null ? ifNotFound : new DynamicPublishedContent(doc).AsDynamic(); }
private dynamic DocumentById(int id, ContextualPublishedCache cache, object ifNotFound) { var doc = cache.GetById(id); return doc == null ? ifNotFound : new DynamicPublishedContent(doc).AsDynamic(); }
private IEnumerable<IPublishedContent> TypedDocumentsAtRoot(ContextualPublishedCache cache) { return cache.GetAtRoot(); }
//NOTE: Not used? //private IPublishedContent TypedDocumentByXPath(XPathExpression xpath, XPathVariable[] vars, ContextualPublishedContentCache cache) //{ // var doc = cache.GetSingleByXPath(xpath, vars); // return doc; //} private IEnumerable<IPublishedContent> TypedDocumentsbyIds(ContextualPublishedCache cache, IEnumerable<int> ids) { return ids.Select(eachId => TypedDocumentById(eachId, cache)); }
private IPublishedContent TypedDocumentById(int id, ContextualPublishedCache cache) { var doc = cache.GetById(id); return doc; }