public void ReplaceTheSiteDescriptionPlaceHolderWithTheSiteSettingValue()
        {
            String pageTemplateContent = "-----{SiteDescription}-----";
            var    pageTemplate        = new Entities.Template()
            {
                Content = pageTemplateContent, TemplateType = Enumerations.TemplateType.ContactPage
            };
            var templates = new List <Entities.Template>()
            {
                pageTemplate
            };

            String sidebarContent = string.Empty.GetRandom();
            String navContent     = string.Empty.GetRandom();
            String pageTitle      = string.Empty.GetRandom();
            String content        = string.Empty.GetRandom();
            String pathToRoot     = string.Empty.GetRandom();

            var container    = (null as IServiceCollection).Create();
            var siteSettings = container.BuildServiceProvider().GetService <IContentRepository>().GetSiteSettings();

            var target = (null as ITemplateProcessor).Create(container);
            var actual = target.ProcessNonContentItemTemplate(pageTemplate, sidebarContent, navContent, content, pageTitle, pathToRoot);

            Assert.Contains(siteSettings.Description, actual);
        }
        public void ReplaceTheTitlePlaceHolderWithTheTitle()
        {
            String pageTemplateContent = "-----{Title}-----";
            var    pageTemplate        = new Entities.Template()
            {
                Content = pageTemplateContent, TemplateType = Enumerations.TemplateType.ContactPage
            };
            var templates = new List <Entities.Template>()
            {
                pageTemplate
            };

            String sidebarContent = string.Empty.GetRandom();
            String navContent     = string.Empty.GetRandom();
            String pageTitle      = string.Empty.GetRandom();
            String content        = string.Empty.GetRandom();
            String pathToRoot     = string.Empty.GetRandom();

            var container = (null as IServiceCollection).Create();

            container.ReplaceDependency <IEnumerable <Entities.Template> >(templates);

            var target = (null as ITemplateProcessor).Create(container);
            var actual = target.ProcessNonContentItemTemplate(pageTemplate, sidebarContent, navContent, content, pageTitle, pathToRoot);

            Assert.Contains(pageTitle, actual);
        }
        public void ReplaceThePathToSiteRootPlaceHolderWithTheProperPathEvenIfEncoded()
        {
            var container = (null as IServiceCollection).Create();
            var encoder   = new PPTail.Generator.Encoder.ContentEncoder(container.BuildServiceProvider());

            String pageTemplateContentRaw = "-----{PathToSiteRoot}-----";
            String pageTemplateContent    = encoder.HTMLEncode(pageTemplateContentRaw);
            var    pageTemplate           = new Entities.Template()
            {
                Content = pageTemplateContent, TemplateType = Enumerations.TemplateType.ContactPage
            };
            var templates = new List <Entities.Template>()
            {
                pageTemplate
            };

            String sidebarContent = string.Empty.GetRandom();
            String navContent     = string.Empty.GetRandom();
            String pageTitle      = string.Empty.GetRandom();
            String content        = string.Empty.GetRandom();
            String pathToRoot     = string.Empty.GetRandom();

            container.ReplaceDependency <IEnumerable <Entities.Template> >(templates);

            var target = (null as ITemplateProcessor).Create(container);
            var actual = target.ProcessNonContentItemTemplate(pageTemplate, sidebarContent, navContent, content, pageTitle, pathToRoot);

            Assert.Contains(pathToRoot, actual);
        }
        public void ThrowADependencyNotFoundExceptionIfTheContentRepositoryIsNotProvided()
        {
            String pageTemplateContent = "-----{Title}-----";
            var    pageTemplate        = new Entities.Template()
            {
                Content = pageTemplateContent, TemplateType = Enumerations.TemplateType.ContactPage
            };
            var templates = new List <Entities.Template>()
            {
                pageTemplate
            };

            String sidebarContent = string.Empty.GetRandom();
            String navContent     = string.Empty.GetRandom();
            String pageTitle      = string.Empty.GetRandom();
            String content        = string.Empty.GetRandom();
            String pathToRoot     = string.Empty.GetRandom();

            var container = (null as IServiceCollection).Create();

            container.RemoveDependency <IContentRepository>();

            var target = (null as ITemplateProcessor).Create(container);

            Assert.Throws <DependencyNotFoundException>(() => target.ProcessNonContentItemTemplate(pageTemplate, sidebarContent, navContent, content, pageTitle, pathToRoot));
        }
Beispiel #5
0
 public static Entities.Template Create(this Entities.Template ignore, Enumerations.TemplateType templateType)
 {
     return(new Entities.Template()
     {
         Content = string.Empty.GetRandom(),
         TemplateType = templateType
     });
 }
Beispiel #6
0
 internal static Entities.Template ToHtmlContent(this Entities.Template yamlTemplate)
 {
     return(new Entities.Template()
     {
         TemplateType = yamlTemplate.TemplateType,
         Content = yamlTemplate.Content.ParseContent()
     });
 }
Beispiel #7
0
 public async Task Update(string templateId, string currentId, string templateName, string templateText, string userId, DateTimeOffset updateAt)
 {
     var data = new Entities.Template
     {
         Name           = templateName,
         Text           = templateText,
         LastModifiedBy = userId,
         LastModifiedAt = updateAt
     };
     var json = JsonConvert.SerializeObject(data);
     await _data.UpdateDataAsync(templateId, json, currentId, userId, updateAt);
 }
Beispiel #8
0
 public async Task AddAsync(string templateName, string templateText, string userId, DateTimeOffset createAt)
 {
     var data = new Entities.Template
     {
         Name           = templateName,
         Text           = templateText,
         LastModifiedBy = userId,
         LastModifiedAt = createAt
     };
     var json = JsonConvert.SerializeObject(data);
     await _data.AddAsync(COLLECTION_NAME, json, userId, DateTimeOffset.Now);
 }
Beispiel #9
0
        public void OnPostCreateTest()
        {
            using (var ctx = Kipon.Xrm.Fake.Repository.PluginExecutionFakeContext.ForType <Kipon.Solid.Plugin.Plugins.Template.TemplatePlugin>())
            {
                var template = new Entities.Template {
                    TemplateId = Guid.NewGuid(), Title = "Test Template"
                };

                ctx.OnPost = delegate
                {
                };

                ctx.Create(template);
            }
        }
        public void ReturnTheProperTypeNameIfTheContentRepositoryIsNotProvided()
        {
            String pageTemplateContent = "-----{Title}-----";
            var    pageTemplate        = new Entities.Template()
            {
                Content = pageTemplateContent, TemplateType = Enumerations.TemplateType.ContactPage
            };
            var templates = new List <Entities.Template>()
            {
                pageTemplate
            };

            String sidebarContent = string.Empty.GetRandom();
            String navContent     = string.Empty.GetRandom();
            String pageTitle      = string.Empty.GetRandom();
            String content        = string.Empty.GetRandom();
            String pathToRoot     = string.Empty.GetRandom();

            var container = (null as IServiceCollection).Create();

            container.RemoveDependency <IContentRepository>();

            var target = (null as ITemplateProcessor).Create(container);

            String actual   = string.Empty;
            String expected = nameof(IContentRepository);

            try
            {
                target.ProcessNonContentItemTemplate(pageTemplate, sidebarContent, navContent, content, pageTitle, pathToRoot);
            }
            catch (DependencyNotFoundException ex)
            {
                actual = ex.InterfaceTypeName;
            }

            Assert.Equal(expected, actual);
        }
Beispiel #11
0
        public string Process(Entities.Template pageTemplate, Entities.Template itemTemplate, string sidebarContent, string navContent, IEnumerable <ContentItem> posts, string pageTitle, string pathToRoot, string itemSeparator, bool xmlEncodeContent, int maxPostCount)
        {
            // MaxPosts is not pulled from the SiteSettings because
            // there are 2 possible values that might be used to
            // define the value, they are PostsPerPage & PostsPerFeed

            var recentPosts = posts.OrderByDescending(p => p.PublicationDate).Where(pub => pub.IsPublished);

            if (maxPostCount > 0)
            {
                recentPosts = recentPosts.Take(maxPostCount);
            }

            var contentItems = new List <string>();

            foreach (var post in recentPosts)
            {
                contentItems.Add(ProcessContentItemTemplate(itemTemplate, post, sidebarContent, navContent, pathToRoot, xmlEncodeContent));
            }

            var pageContent = string.Join(itemSeparator, contentItems);

            return(ProcessNonContentItemTemplate(pageTemplate, sidebarContent, navContent, pageContent, pageTitle, pathToRoot));
        }
Beispiel #12
0
 public static Entities.Template Create(this Entities.Template ignore)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
 public string ProcessNonContentItemTemplate(Entities.Template template, string sidebarContent, string navContent, string content, string pageTitle, string pathToRoot)
 {
     return(template.Content
            .Replace("{Title}", pageTitle)
            .ReplaceNonContentItemSpecificVariables(_serviceProvider, sidebarContent, navContent, content, pathToRoot));
 }
Beispiel #14
0
 public string ProcessContentItemTemplate(Entities.Template template, ContentItem item, string sidebarContent, string navContent, string pathToRoot, bool xmlEncodeContent)
 {
     return(template.Content
            .ReplaceContentItemVariables(_serviceProvider, item, pathToRoot, xmlEncodeContent)
            .ReplaceNonContentItemSpecificVariables(_serviceProvider, sidebarContent, navContent, string.Empty, pathToRoot));
 }
 public TemplateCollectionBuilder AddTemplate(Entities.Template template)
 {
     _templates.Add(template);
     return(this);
 }