Esempio n. 1
0
 public override void GetContentItemAspect(ContentItemAspectContext context, IdentityPart part)
 {
     context.For <ContentItemMetadata>(contentItemMetadata =>
     {
         contentItemMetadata.Identity.Add("Identifier", part.Identifier);
     });
 }
Esempio n. 2
0
 public override void GetContentItemAspect(ContentItemAspectContext context, TitlePart part)
 {
     context.For <ContentItemMetadata>(contentItemMetadata =>
     {
         contentItemMetadata.DisplayText = part.Title;
     });
 }
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context)
        {
            context.For <ContentItemMetadata>(metadata =>
            {
                if (metadata.EditorRouteValues == null && context.ContentItem.ContentType == "AdvancedForm")
                {
                    metadata.EditorRouteValues = new RouteValueDictionary {
                        { "Area", "AdvancedForms" },
                        { "Controller", "Admin" },
                        { "Action", "Edit" },
                        { "ContentItemId", context.ContentItem.ContentItemId }
                    };
                }

                if (metadata.EditorRouteValues == null && context.ContentItem.ContentType == "AdvancedFormSubmissions")
                {
                    try
                    {
                        string path = context.ContentItem.Content.AutoroutePart.Path.ToString().Split("/")[1];
                        metadata.EditorRouteValues = new RouteValueDictionary {
                            { "Area", "AdvancedForms" },
                            { "Controller", path },
                            { "Action", "Edit" },
                            { "id", context.ContentItem.ContentItemId }
                        };
                    }
                    catch
                    {
                    }
                }
            });

            return(Task.CompletedTask);
        }
Esempio n. 4
0
 public override void GetContentItemAspect(ContentItemAspectContext context, AutoroutePart part)
 {
     context.For <ContentItemMetadata>(contentItemMetadata =>
     {
         contentItemMetadata.Identity.Add("Alias", part.Path);
     });
 }
Esempio n. 5
0
 public override void GetContentItemAspect(ContentItemAspectContext context, ListPart part)
 {
     context.For <FeedMetadata>(feedMetadata =>
     {
         // If the value is not defined, it will be represented as null
         feedMetadata.FeedProxyUrl = part.Content.FeedProxyUrl;
     });
 }
Esempio n. 6
0
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context, TitlePart part)
        {
            context.For <ContentItemMetadata>(contentItemMetadata =>
            {
                contentItemMetadata.DisplayText = part.Title;
            });

            return(Task.CompletedTask);
        }
Esempio n. 7
0
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context)
        {
            context.For <ContentItemMetadata>(metadata =>
            {
                if (metadata.CreateRouteValues == null)
                {
                    metadata.CreateRouteValues = new RouteValueDictionary {
                        { "Area", "OrchardCore.Contents" },
                        { "Controller", "Admin" },
                        { "Action", "Create" },
                        { "Id", context.ContentItem.ContentType }
                    };
                }

                if (metadata.EditorRouteValues == null)
                {
                    metadata.EditorRouteValues = new RouteValueDictionary {
                        { "Area", "OrchardCore.Contents" },
                        { "Controller", "Admin" },
                        { "Action", "Edit" },
                        { "ContentItemId", context.ContentItem.ContentItemId }
                    };
                }

                if (metadata.AdminRouteValues == null)
                {
                    metadata.AdminRouteValues = new RouteValueDictionary {
                        { "Area", "OrchardCore.Contents" },
                        { "Controller", "Admin" },
                        { "Action", "Edit" },
                        { "ContentItemId", context.ContentItem.ContentItemId }
                    };
                }

                if (metadata.DisplayRouteValues == null)
                {
                    metadata.DisplayRouteValues = new RouteValueDictionary {
                        { "Area", "OrchardCore.Contents" },
                        { "Controller", "Item" },
                        { "Action", "Display" },
                        { "ContentItemId", context.ContentItem.ContentItemId }
                    };
                }

                if (metadata.RemoveRouteValues == null)
                {
                    metadata.RemoveRouteValues = new RouteValueDictionary {
                        { "Area", "OrchardCore.Contents" },
                        { "Controller", "Admin" },
                        { "Action", "Remove" },
                        { "ContentItemId", context.ContentItem.ContentItemId }
                    };
                }
            });

            return(Task.CompletedTask);
        }
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context, ListPart part)
        {
            context.For <FeedMetadata>(feedMetadata =>
            {
                // If the value is not defined, it will be represented as null
                feedMetadata.FeedProxyUrl = part.Content.FeedProxyUrl;
            });

            return(Task.CompletedTask);
        }
Esempio n. 9
0
        public override void GetContentItemAspect(ContentItemAspectContext context)
        {
            context.For <ContentItemMetadata>(metadata =>
            {
                var layerMetadata = context.ContentItem.As <LayerMetadata>();

                if (layerMetadata != null && !String.IsNullOrEmpty(layerMetadata.Title))
                {
                    metadata.DisplayText = layerMetadata.Title;
                }
            });
        }
Esempio n. 10
0
        public override void GetContentItemAspect(ContentItemAspectContext context, MarkdownPart part)
        {
            context.For <BodyAspect>(bodyAspect =>
            {
                var contentTypeDefinition     = _contentDefinitionManager.GetTypeDefinition(part.ContentItem.ContentType);
                var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(p => p.PartDefinition.Name == nameof(MarkdownPart));
                var settings = contentTypePartDefinition.GetSettings <MarkdownPartSettings>();

                var html = Markdig.Markdown.ToHtml(part.Markdown ?? "");

                bodyAspect.Body = new HtmlString(html);
            });
        }
Esempio n. 11
0
 public override void GetContentItemAspect(ContentItemAspectContext context, ListPart part)
 {
     context.For <ContentItemMetadata>(contentItemMetadata =>
     {
         contentItemMetadata.AdminRouteValues = new RouteValueDictionary
         {
             { "Area", "Orchard.Contents" },
             { "Controller", "Admin" },
             { "Action", "Display" },
             { "Id", context.ContentItem.ContentItemId }
         };
     });
 }
Esempio n. 12
0
        public override void GetContentItemAspect(ContentItemAspectContext context, BodyPart part)
        {
            context.For <BodyAspect>(bodyAspect =>
            {
                var contentTypeDefinition     = _contentDefinitionManager.GetTypeDefinition(part.ContentItem.ContentType);
                var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(p => p.PartDefinition.Name == nameof(BodyPart));
                var settings = contentTypePartDefinition.GetSettings <BodyPartSettings>();

                var body = part.Body;

                bodyAspect.Body = new HtmlString(body);
            });
        }
Esempio n. 13
0
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context, HtmlBodyPart part)
        {
            context.For <BodyAspect>(bodyAspect =>
            {
                var contentTypeDefinition     = _contentDefinitionManager.GetTypeDefinition(part.ContentItem.ContentType);
                var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(p => p.PartDefinition.Name == nameof(HtmlBodyPart));
                var settings = contentTypePartDefinition.GetSettings <HtmlBodyPartSettings>();
                var body     = part.Html;

                bodyAspect.Body = new HtmlString(body);
            });

            return(Task.CompletedTask);
        }
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context)
        {
            context.For <ContentItemMetadata>(metadata =>
            {
                var layerMetadata = context.ContentItem.As <LayerMetadata>();

                if (layerMetadata != null && !string.IsNullOrEmpty(layerMetadata.Title))
                {
                    metadata.DisplayText = layerMetadata.Title;
                }
            });

            return(Task.CompletedTask);
        }
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context, ListPart part)
        {
            context.For <ContentItemMetadata>(contentItemMetadata =>
            {
                contentItemMetadata.AdminRouteValues = new RouteValueDictionary
                {
                    { "Area", "OrchardCore.Contents" },
                    { "Controller", "Admin" },
                    { "Action", "Display" },
                    { "ContentItemId", context.ContentItem.ContentItemId }
                };
            });

            return(Task.CompletedTask);
        }
Esempio n. 16
0
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context, LiquidPart part)
        {
            context.For <BodyAspect>(bodyAspect =>
            {
                try
                {
                    var result      = _liquidTemplateManager.RenderAsync(part.Liquid, System.Text.Encodings.Web.HtmlEncoder.Default, new TemplateContext()).GetAwaiter().GetResult();
                    bodyAspect.Body = new HtmlString(result);
                }
                catch
                {
                    bodyAspect.Body = HtmlString.Empty;
                }
            });

            return(Task.CompletedTask);
        }
Esempio n. 17
0
        public override void GetContentItemAspect(ContentItemAspectContext context, LiquidPart part)
        {
            context.For <BodyAspect>(bodyAspect =>
            {
                var template = _liquidManager.GetTemplate(part.Liquid);

                if (template == null)
                {
                    bodyAspect.Body = HtmlString.Empty;
                }
                else
                {
                    var html        = template.Render();
                    bodyAspect.Body = new HtmlString(html);
                }
            });
        }
Esempio n. 18
0
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context, RedirectPart part)
        {
            context.For <ContentItemMetadata>(metadata =>
            {
                if (metadata.DisplayRouteValues == null)
                {
                    metadata.DisplayRouteValues = new RouteValueDictionary {
                        { "Area", "Etch.OrchardCore.SEO" },
                        { "Controller", "Redirect" },
                        { "Action", "Index" },
                        { "ContentItemId", context.ContentItem.ContentItemId }
                    };
                }
            });

            return(Task.CompletedTask);
        }
Esempio n. 19
0
        public override void GetContentItemAspect(ContentItemAspectContext context, BodyPart part)
        {
            context.For <BodyAspect>(bodyAspect =>
            {
                var contentTypeDefinition     = _contentDefinitionManager.GetTypeDefinition(part.ContentItem.ContentType);
                var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(p => p.PartDefinition.Name == nameof(BodyPart));
                var settings = contentTypePartDefinition.GetSettings <BodyPartSettings>();

                var body = part.Body;

                if (settings.RenderTokens)
                {
                    var tokenContext = _tokenizer.CreateViewModel().Content(part.ContentItem);
                    body             = _tokenizer.Tokenize(body, tokenContext);
                }

                bodyAspect.Body = new HtmlString(body);
            });
        }
Esempio n. 20
0
        public override void GetContentItemAspect(ContentItemAspectContext context, BodyPart part)
        {
            context.For <BodyAspect>(bodyAspect =>
            {
                var contentTypeDefinition     = _contentDefinitionManager.GetTypeDefinition(part.ContentItem.ContentType);
                var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(p => p.PartDefinition.Name == nameof(BodyPart));
                var settings = contentTypePartDefinition.GetSettings <BodyPartSettings>();

                var body = part.Body;

                if (settings.RenderTokens && !string.IsNullOrEmpty(body))
                {
                    body = _tokenizer.Tokenize(body, new Dictionary <string, object> {
                        ["Content"] = part.ContentItem
                    });
                }

                bodyAspect.Body = new HtmlString(body);
            });
        }
Esempio n. 21
0
        public override void GetContentItemAspect(ContentItemAspectContext context, MarkdownPart part)
        {
            context.For <BodyAspect>(bodyAspect =>
            {
                var contentTypeDefinition     = _contentDefinitionManager.GetTypeDefinition(part.ContentItem.ContentType);
                var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(p => p.PartDefinition.Name == nameof(MarkdownPart));
                var settings = contentTypePartDefinition.GetSettings <MarkdownPartSettings>();

                var html = Markdig.Markdown.ToHtml(part.Markdown);

                if (settings.RenderTokens)
                {
                    html = _tokenizer.Tokenize(html, new Dictionary <string, object> {
                        ["Content"] = part.ContentItem
                    });
                }

                bodyAspect.Body = new HtmlString(html);
            });
        }
Esempio n. 22
0
 public override void GetContentItemAspect(ContentItemAspectContext context, BodyPart part)
 {
     context.For<BodyAspect>(bodyAspect => bodyAspect.Body = new HtmlString(part.Body));
 }