Пример #1
0
        public void Process(SnowyData snowyData, SnowSettings settings)
        {
            ParseDirectories(snowyData);
            TestModule.StaticFile = SourceFile;

            Impl(snowyData, settings);
        }
Пример #2
0
        public void Process(SnowyData snowyData, SnowSettings settings)
        {
            ParseDirectories(snowyData);
            TestModule.StaticFile = SourceFile;

            Impl(snowyData, settings);
        }
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            foreach (var tempCategory in TestModule.Categories)
            {
                var category = tempCategory;

                var posts = snowyData.Files.Where(x => x.Categories.Contains(category.Name));

                TestModule.Category        = category;
                TestModule.PostsInCategory = posts.ToList();

                var result = snowyData.Browser.Post("/static");

                result.ThrowIfNotSuccessful(SourceFile);

                var outputFolder = Path.Combine(snowyData.Settings.Output, "category", category.Url);

                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }

                File.WriteAllText(Path.Combine(outputFolder, "index.html"), result.Body.AsString());
            }
        }
Пример #4
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            foreach (var tempCategory in TestModule.Categories)
            {
                var category = tempCategory;

                var posts = GetPosts(snowyData.Files, category);

                TestModule.Category = category;
                TestModule.GeneratedUrl = settings.SiteUrl + "/category/" + category.Url + "/";
                TestModule.PostsInCategory = posts.ToList();

                var result = snowyData.Browser.Post("/static");

                result.ThrowIfNotSuccessful(SourceFile);

                var outputFolder = Path.Combine(snowyData.Settings.Output, "category", category.Url);

                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }

                File.WriteAllText(Path.Combine(outputFolder, "index.html"), result.Body.AsString());
            }
        }
        public override void Process(SnowyData snowyData, SnowSettings settings)
        {
            foreach (var tempCategory in TestModule.Categories)
            {
                var category = tempCategory;

                var posts = snowyData.Files.Where(x => x.Categories.Contains(category.Name));

                TestModule.Category = category;
                TestModule.PostsInCategory = posts.ToList();
                
                var result = snowyData.Browser.Post("/static");

                result.ThrowIfNotSuccessful(snowyData.File.File);

                var outputFolder = Path.Combine(snowyData.Settings.Output, "category", category.Url);

                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }

                File.WriteAllText(Path.Combine(outputFolder, "index.html"), result.Body.AsString());
            }
        }
Пример #6
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            var result = snowyData.Browser.Post("/sitemap");

            var outputFolder = snowyData.Settings.Output;

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            File.WriteAllText(Path.Combine(outputFolder, SourceFile), result.Body.AsString());
        }
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            var result = snowyData.Browser.Post("/static");

            result.ThrowIfNotSuccessful(SourceFile);

            if (!Directory.Exists(Destination))
            {
                Directory.CreateDirectory(Destination);
            }

            File.WriteAllText(Path.Combine(Destination, "index.html"), result.Body.AsString());
        }
Пример #8
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            var result = snowyData.Browser.Post("/sitemap");

            var outputFolder = snowyData.Settings.Output;

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            File.WriteAllText(Path.Combine(outputFolder, SourceFile), result.Body.AsString());
        }
Пример #9
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            TestModule.GeneratedUrl = settings.SiteUrl + "/" + DestinationName.Trim(new[] { '/' }) + "/";

            var result = snowyData.Browser.Post("/static");

            result.ThrowIfNotSuccessful(SourceFile);

            if (!Directory.Exists(Destination))
            {
                Directory.CreateDirectory(Destination);
            }

            File.WriteAllText(Path.Combine(Destination, "index.html"), result.Body.AsString());
        }
Пример #10
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            TestModule.GeneratedUrl = settings.SiteUrl + "/" + DestinationName.Trim(new[] { '/' }) + "/";

            var result = snowyData.Browser.Post("/static");

            result.ThrowIfNotSuccessful(SourceFile);

            if (!Directory.Exists(Destination))
            {
                Directory.CreateDirectory(Destination);
            }

            File.WriteAllText(Path.Combine(Destination, "index.html"), result.Body.AsString());
        }
        public override void Process(SnowyData snowyData, SnowSettings settings)
        {
            var result = snowyData.Browser.Post("/static");

            result.ThrowIfNotSuccessful(snowyData.File.File);

            var outputFolder = Path.Combine(snowyData.Settings.Output, snowyData.File.File.Substring(0, snowyData.File.File.IndexOf('.')));

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            File.WriteAllText(Path.Combine(outputFolder, "index.html"), result.Body.AsString());
        }
Пример #12
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            var postsForRss = GetPostsForRss(snowyData.Files);

            TestModule.PostsPaged = postsForRss;

            var result = snowyData.Browser.Post("/rss");

            var outputFolder = snowyData.Settings.Output;

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            File.WriteAllText(Path.Combine(outputFolder, SourceFile), result.Body.AsString());
        }
Пример #13
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            var postsForAtom = GetPostsForAtom(snowyData.Files);

            TestModule.PostsPaged = postsForAtom;

            var result = snowyData.Browser.Post("/atom");

            var outputFolder = snowyData.Settings.PostsOutput;

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }

            File.WriteAllText(Path.Combine(outputFolder, SourceFile), result.Body.AsString());
        }
Пример #14
0
        public override void Process(SnowyData snowyData, SnowSettings settings)
        {
            var postsForRss = snowyData.Files.Take(10).ToList();
            TestModule.PostsPaged = postsForRss;
            TestModule.StaticFile = snowyData.File;

            var result = snowyData.Browser.Post("/rss");
            
            var outputFolder = snowyData.Settings.Output;

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }
            
            File.WriteAllText(Path.Combine(outputFolder, snowyData.File.File), result.Body.AsString());
        }
Пример #15
0
        protected void ParseDirectories(SnowyData snowyData)
        {
            var source = snowyData.File.File;

            var sourceFile           = source;
            var destinationDirectory = Path.Combine(snowyData.Settings.Output, source.Substring(0, snowyData.File.File.IndexOf('.')));

            if (source.Contains(" => "))
            {
                var directorySplit = source.Split(new[] { " => " }, StringSplitOptions.RemoveEmptyEntries);

                sourceFile           = directorySplit[0];
                destinationDirectory = Path.Combine(snowyData.Settings.Output, directorySplit[1]);
            }

            SourceFile  = sourceFile;
            Destination = destinationDirectory;
        }
Пример #16
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {

            var filteredPosts = snowyData.Files.Where(ShouldProcess).ToList();

            const int pageSize = 10;
            var skip = 0;
            var iteration = 1;
            var currentIteration = filteredPosts.Skip(skip).Take(pageSize).ToList();
            var totalPages = (int)Math.Ceiling((double)filteredPosts.Count / pageSize);

            TestModule.TotalPages = totalPages;

            while (currentIteration.Any())
            {
                var folder = skip <= 1 ? "" : "page" + iteration;

                TestModule.PostsPaged = currentIteration.ToList();
                TestModule.PageNumber = iteration;
                TestModule.HasNextPage = iteration < totalPages;
                TestModule.HasPreviousPage = iteration > 1 && totalPages > 1;
                TestModule.GeneratedUrl = (settings.SiteUrl + "/" + folder).TrimEnd('/') + "/";

                var result = snowyData.Browser.Post("/static");

                result.ThrowIfNotSuccessful(snowyData.File.File);

                var outputFolder = Path.Combine(snowyData.Settings.Output, folder);

                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }

                File.WriteAllText(Path.Combine(outputFolder, "index.html"), result.Body.AsString());

                skip += pageSize;
                iteration++;
                currentIteration = filteredPosts.Skip(skip).Take(pageSize).ToList();
            }
        }
Пример #17
0
        protected void ParseDirectories(SnowyData snowyData)
        {
            var source = snowyData.File.File;

            var sourceFile = source;
            var destinationDirectory = Path.Combine(snowyData.Settings.Output, source.Substring(0, snowyData.File.File.IndexOf('.')));
            var destinationName = source.Substring(0, snowyData.File.File.IndexOf('.'));

            if (source.Contains(" => "))
            {
                var directorySplit = source.Split(new[] { " => " }, StringSplitOptions.RemoveEmptyEntries);

                sourceFile = directorySplit[0];
                destinationDirectory = Path.Combine(snowyData.Settings.Output, directorySplit[1]);
                destinationName = directorySplit[1];
            }

            SourceFile = sourceFile;
            Destination = destinationDirectory;
            DestinationName = destinationName;
        }
Пример #18
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            var filteredPosts = snowyData.Files.Where(ShouldProcess).ToList();

            var pageSize         = settings.PageSize;
            var skip             = 0;
            var iteration        = 1;
            var currentIteration = filteredPosts.Skip(skip).Take(pageSize).ToList();
            var totalPages       = (int)Math.Ceiling((double)filteredPosts.Count / pageSize);

            TestModule.TotalPages = totalPages;

            while (currentIteration.Any())
            {
                var folder = skip <= 1 ? "" : "page" + iteration;

                TestModule.PostsPaged      = currentIteration.ToList();
                TestModule.PageNumber      = iteration;
                TestModule.HasNextPage     = iteration < totalPages;
                TestModule.HasPreviousPage = iteration > 1 && totalPages > 1;
                TestModule.GeneratedUrl    = (settings.SiteUrl + "/" + folder).TrimEnd('/') + "/";

                var result = snowyData.Browser.Post("/static");

                result.ThrowIfNotSuccessful(snowyData.File.File);

                var outputFolder = Path.Combine(snowyData.Settings.Output, folder);

                if (!Directory.Exists(outputFolder))
                {
                    Directory.CreateDirectory(outputFolder);
                }

                File.WriteAllText(Path.Combine(outputFolder, "index.html"), result.Body.AsString());

                skip += pageSize;
                iteration++;
                currentIteration = filteredPosts.Skip(skip).Take(pageSize).ToList();
            }
        }
Пример #19
0
 protected override void Impl(SnowyData snowyData, SnowSettings settings)
 {
     TestModule.Published = Published.Draft;
     
     base.Impl(snowyData, settings);
 }
Пример #20
0
        protected override void Impl(SnowyData snowyData, SnowSettings settings)
        {
            TestModule.Published = Published.Draft;

            base.Impl(snowyData, settings);
        }
Пример #21
0
 protected abstract void Impl(SnowyData snowyData, SnowSettings settings);
Пример #22
0
 protected abstract void Impl(SnowyData snowyData, SnowSettings settings);