예제 #1
0
        public override void Updated(UpdateContentContext context, AutoroutePart part)
        {
            // Compute the Path only if it's empty
            if (!String.IsNullOrWhiteSpace(part.Path))
            {
                return;
            }

            var pattern = GetPattern(part);

            if (!String.IsNullOrEmpty(pattern))
            {
                var ctx = _tokenizer
                          .CreateViewModel()
                          .Content(part.ContentItem);

                part.Path = _tokenizer.Tokenize(pattern, ctx);
                if (!IsPathUnique(part.Path, part))
                {
                    part.Path = GenerateUniquePath(part.Path, part);
                }

                part.Apply();
            }
        }
예제 #2
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);
            });
        }
예제 #3
0
        public override void Updated(UpdateContentContext context, AliasPart part)
        {
            // Compute the Path only if it's empty
            if (!String.IsNullOrEmpty(part.Alias))
            {
                return;
            }

            var pattern = GetPattern(part);

            if (!String.IsNullOrEmpty(pattern))
            {
                var ctx = _tokenizer
                          .CreateViewModel()
                          .Content(part.ContentItem);

                part.Alias = _tokenizer.Tokenize(pattern, ctx);
            }
        }