private dynamic DocumentsByXPath(string xpath, XPathVariable[] vars, ContextualPublishedCache cache) { return(new DynamicPublishedContentList( cache.GetByXPath(xpath, vars) .Select(publishedContent => new DynamicPublishedContent(publishedContent)) )); }
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()) { //for each one of them we need to create some virtual routes/nodes foreach (var node in articulateNodes) { RemoveExisting(routes, "articulate_rss_" + node.Id, "articulate_rss_xslt_" + node.Id, "articulate_tags_" + node.Id, "articulate_tags_rss_" + node.Id, "articulate_search_" + node.Id, "articulate_metaweblog_" + node.Id, "articulate_rsd_" + node.Id, "articulate_wlwmanifest_" + node.Id, "articulate_markdown_" + node.Id); MapRssRoute(routes, node); MapSearchRoute(routes, node); MapManifestRoute(routes, node); MapRsdRoute(routes, node); MapMetaWeblogRoute(routes, node); MapTagsAndCategoriesRoute(routes, node); MapMarkdownEditorRoute(routes, node); } } }
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 DocumentById(Guid id, ContextualPublishedCache cache, object ifNotFound) { var doc = TypedDocumentById(id, cache); return(doc == null ? ifNotFound : new DynamicPublishedContent(doc).AsDynamic()); }
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 IPublishedContent TypedDocumentById(Guid id, ContextualPublishedCache cache) { // todo: in v8, implement in a more efficient way var legacyXml = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema; var xpath = legacyXml ? "//node [@key=$guid]" : "//* [@isDoc and @key=$guid]"; var doc = cache.GetSingleByXPath(xpath, new XPathVariable("guid", id.ToString())); return(doc); }
private dynamic DocumentByIds(ContextualPublishedCache cache, IEnumerable <Guid> 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)); }
public static void MapRoutes(RouteCollection routes, ContextualPublishedCache umbracoCache, UrlProvider umbracoUrlProvider) { //find all articulate root nodes var articulateNodes = umbracoCache.GetByXPath("//Articulate").ToArray(); LogHelper.Info(typeof(ArticulateRoutes), () => $"Mapping routes for {articulateNodes.Length} Articulate root nodes"); //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 articulateNodesGroupedByUriPath = 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 nodeByPathGroup in articulateNodesGroupedByUriPath) { var nodesAsArray = nodeByPathGroup.ToArray(); var uriPath = nodeByPathGroup.Key; MapRssRoute(routes, umbracoUrlProvider, uriPath, nodesAsArray); MapSearchRoute(routes, umbracoUrlProvider, uriPath, nodesAsArray); MapTagsAndCategoriesRoute(routes, umbracoUrlProvider, uriPath, nodesAsArray); MapMarkdownEditorRoute(routes, umbracoUrlProvider, uriPath, nodesAsArray); MapAuthorsRssRoute(routes, umbracoUrlProvider, uriPath, nodesAsArray); foreach (var articulateRootNode in nodeByPathGroup) { MapMetaWeblogRoute(routes, uriPath, articulateRootNode); MapManifestRoute(routes, uriPath, articulateRootNode); MapRsdRoute(routes, uriPath, articulateRootNode); MapOpenSearchRoute(routes, uriPath, articulateRootNode); } } } }
public static void MapRoutes(RouteCollection routes, ContextualPublishedCache umbracoCache, UrlProvider umbracoUrlProvider) { //find all dialogue root nodes var dialogueNodes = umbracoCache.GetByXPath(string.Concat("//", DialogueConfiguration.Instance.DocTypeForumRoot)).ToArray(); LogHelper.Info(typeof(DialogueRoutes), () => $"Mapping routes for {dialogueNodes.Length} Dialogue root nodes"); //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)) //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(); MapTopicRoute(routes, umbracoUrlProvider, grouping.Key, nodesAsArray); MapDialoguePages(routes, umbracoUrlProvider, grouping.Key, nodesAsArray); MapMemberRoute(routes, umbracoUrlProvider, grouping.Key, nodesAsArray); } } }
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); }
private IPublishedContent TypedDocumentById(int id, ContextualPublishedCache cache) { var doc = cache.GetById(id); return(doc); }
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); }
private IEnumerable <IPublishedContent> TypedDocumentsByIds(ContextualPublishedCache cache, IEnumerable <Guid> ids) { // todo: in v8, implement in a more efficient way return(ids.Select(eachId => TypedDocumentById(eachId, cache)).WhereNotNull()); }
private IEnumerable <IPublishedContent> TypedDocumentsAtRoot(ContextualPublishedCache cache) { return(cache.GetAtRoot()); }
private IEnumerable <IPublishedContent> TypedDocumentsByIds(ContextualPublishedCache cache, IEnumerable <Guid> ids) { return(ids.Select(eachId => TypedDocumentById(eachId, cache)).WhereNotNull()); }
private IPublishedContent TypedDocumentById(Guid key, ContextualPublishedCache cache) { return(cache.GetById(key)); }