Example #1
0
 internal Menu(SquashFeatureDirectory root, string outputDirectory, string menuHeader)
 {
     _outputDirectory = outputDirectory;
     SetHeader(menuHeader, root);
     _content = GetMenuFor(root);
     SquashLogger.Info("Generating page menu");
 }
Example #2
0
        public void Squash(SquashConfiguration configuration)
        {
            var squashFeatureDirectory = new SquashFeatureDirectory(configuration.InputDirectory);

            var template      = new PageTemplate(squashFeatureDirectory, configuration.OutputDirectory, configuration.Title);
            var htmlGenerator = new HtmlGenerator(template, configuration.OutputDirectory, squashFeatureDirectory);

            htmlGenerator.ClearOutputDirectory();
            htmlGenerator.GenerateFiles();
            SquashLogger.Info("Done!");
        }
Example #3
0
        private void GenerateFeatureFilesFor(SquashFeatureDirectory squashFeatureDirectory)
        {
            foreach (var feature in squashFeatureDirectory.FeatureFiles)
            {
                var content  = FeatureToHtml(feature);
                var page     = _pageTemplate.GetPage(content);
                var location = squashFeatureDirectory.DirectoryExtension.Replace(SquashConfiguration.Separator, '-');
                File.WriteAllText(_outputDirectory + location + feature.Name + ".html", page);
            }

            foreach (var dir in squashFeatureDirectory.Directories)
            {
                GenerateFeatureFilesFor(dir);
            }
        }
Example #4
0
        private void GetDirectories()
        {
            var directories = Directory.GetDirectories(DirectoryName);

            SquashLogger.Info($"Got {directories.Length} directories for {DirectoryName}");
            foreach (var dir in directories)
            {
                var e   = dir.Split('\\');
                var ext = e[e.Length - 1] + "\\";
                var f   = new SquashFeatureDirectory(dir, DirectoryExtension + ext);
                if (f.Directories.Count > 0 || f.FeatureFiles.Count > 0)
                {
                    Directories.Add(f);
                }
            }
        }
Example #5
0
        internal PageTemplate(SquashFeatureDirectory squashFeatureDirectory, string outputDirectory, string menuHeader = "")
        {
            var menu = new Menu(squashFeatureDirectory, outputDirectory, menuHeader);

            // string style = File.ReadAllText("style.css");
            //string script = File.ReadAllText("script.js");

            var template = new Template(Templates.Template);

            template.Replace("menu", menu);
            template.Replace("templateStyle", minifiedCss);
            template.Replace("templateScript", minifiedJs);

            _template = template;
            SquashLogger.Info("Got page template");
        }
Example #6
0
        private string GetMenuFor(SquashFeatureDirectory directory)
        {
            var menu = "<ul>";

            var location = directory.DirectoryExtension.Split(SquashConfiguration.Separator)
                           .LastOrDefault(e => !string.IsNullOrWhiteSpace(e));

            menu += "<h4>" + location + "</h4>";

            foreach (var dir in directory.Directories)
            {
                menu += GetMenuFor(dir);
            }

            foreach (var feature in directory.FeatureFiles)
            {
                menu += $"<li loc='{_outputDirectory + directory.DirectoryExtension.Replace(SquashConfiguration.Separator,'-') + feature.Name + ".html"}'>{feature.Name}</li>";
            }

            menu += "</ul>";
            return(menu);
        }
Example #7
0
        private void SetHeader(string header, SquashFeatureDirectory rootFeatureDirectory)
        {
            var h = string.IsNullOrWhiteSpace(header) ? rootFeatureDirectory.DirectoryName : header;

            _header = $"<h3>{h}</h3>";
        }
Example #8
0
 internal HtmlGenerator(PageTemplate pageTemplate, string outputDirectory, SquashFeatureDirectory root)
 {
     _pageTemplate    = pageTemplate;
     _outputDirectory = outputDirectory;
     _root            = root;
 }