Ejemplo n.º 1
0
        public async Task ProduceHtml()
        {
            Assert.AreEqual(0, _pageModelWriterStorage.Count);
            Assert.AreEqual(0, _assetsWriterStorage.Count);

            var orchestrationService = new OrchestrationService();

            orchestrationService.LoggerService           = LoggerService;
            orchestrationService.AssetsReaderService     = AssetsReaderService;
            orchestrationService.AssetsWriterService     = AssetsWriterService;
            orchestrationService.PageModelReaderService  = PageModelReaderService;
            orchestrationService.PageModelWriterService  = PageModelWriterService;
            orchestrationService.TemplateReaderService   = TemplateReaderService;
            orchestrationService.TemplateService         = TemplateService;
            orchestrationService.DataService             = DataService;
            orchestrationService.MarkupService           = MarkupService;
            orchestrationService.HtmlMinificationService = HtmlMinificationService;

            await orchestrationService.RenderProjectAsync();


            Assert.AreEqual(2, _pageModelWriterStorage.Count);
            Assert.IsFalse(_pageModelWriterStorage.All(x => x.ContentRaw == null));

            Assert.AreEqual(2, _assetsWriterStorage.Count);
            Assert.IsFalse(_assetsWriterStorage.All(x => x.ContentRaw == null));

            var logoAsset = _assetsWriterStorage.SingleOrDefault(x => x.Id.Contains("img") && x.Id.Contains("logo.png"));

            Assert.IsNotNull(logoAsset);

            var page = _pageModelWriterStorage.Single(x => x.Id.Equals("index.html"));

            Assert.AreEqual("<html><head><link href=\"/assets/style.css\" rel=\"stylesheet\" type=\"text/css\"><title>Static Site Generator - Home</title></head><body><div><ul><li><a href=\"https://facebook.com\">Facebook</a></li><li><a href=\"https://twitter.com\">Twitter</a></li></ul></div><h1>Welcome to Static Site Generator!</h1><h4>Authors</h4><h5>Founders</h5><ul><li>Anton Boyko (Microsoft Azure MVP)</li></ul><h5>Contributors</h5><p><strong>Powered by .NET Core 2.0</strong></p><div><i>All rights reserved</i></div></body></html>", page.ContentRaw);
        }
Ejemplo n.º 2
0
        public async Task ProduceHtml()
        {
            Assert.AreEqual(0, _pageModelWriterStorage.Count);
            Assert.AreEqual(0, _assetsWriterStorage.Count);

            var orchestrationService = new OrchestrationService();

            orchestrationService.LoggerService           = LoggerService;
            orchestrationService.AssetsReaderService     = AssetsReaderService;
            orchestrationService.AssetsWriterService     = AssetsWriterService;
            orchestrationService.PageModelReaderService  = PageModelReaderService;
            orchestrationService.PageModelWriterService  = PageModelWriterService;
            orchestrationService.TemplateReaderService   = TemplateReaderService;
            orchestrationService.TemplateService         = TemplateService;
            orchestrationService.DataService             = DataService;
            orchestrationService.MarkupService           = MarkupService;
            orchestrationService.HtmlMinificationService = HtmlMinificationService;

            await orchestrationService.RenderProjectAsync();


            Assert.AreEqual(2, _pageModelWriterStorage.Count);
            Assert.IsFalse(_pageModelWriterStorage.All(x => x.ContentRaw == null));

            Assert.AreEqual(3, _assetsWriterStorage.Count);
            Assert.IsFalse(_assetsWriterStorage.All(x => x.ContentRaw == null));

            var logoAsset = _assetsWriterStorage.SingleOrDefault(x => x.Id.Contains("img") && x.Id.Contains("logo.png"));

            Assert.IsNotNull(logoAsset);

            var page = _pageModelWriterStorage.Single(x => x.Id.Equals("index.html"));

            Assert.AreEqual(PAGE_CONTENT, page.ContentRaw);
        }
Ejemplo n.º 3
0
        public static void RenderCommand(CommandLineApplication command)
        {
            command.Description = "Renders static website";

            command.HelpOption("-?|-h|--help");

//            var source = command.Option("-s|--source <SOURCE>", "Path to folder with source files", CommandOptionType.SingleValue);
//            var destination = command.Option("-d|--destination <DESTINATION>", "Path to folder where static website will be generated", CommandOptionType.SingleValue);

            command.OnExecute(() =>
            {
                LoggerService.WriteLogMessage("Rendering static website").Wait();

//                var sourcePath = source.HasValue() ? source.Value() : Directory.GetCurrentDirectory();
//                var destinationPath = destination.HasValue() ? destination.Value() : Path.Combine(Directory.GetCurrentDirectory(), "WWW");

                var configurationService = new ConfigurationService();
                var sourcePath           = configurationService.Configuration.Source.Path;
                var outputPath           = configurationService.Configuration.Output.Path;

                LoggerService.WriteLogMessage($"Source: {sourcePath}").Wait();
                LoggerService.WriteLogMessage($"Output: {outputPath}").Wait();

                var dataService         = new DataService(new FileSystemTextContentReaderService <CustomDataModel>(Path.Combine(sourcePath, "data")));
                dataService.OnLogEvent += async message => { await LoggerService.WriteLogMessage(message); };

                var orchestrationService = new OrchestrationService();

                orchestrationService.LoggerService           = LoggerService;
                orchestrationService.TemplateService         = new MustacheTemplateService(new FileSystemTextContentReaderService <TextContentModel>(Path.Combine(sourcePath, "layout", "partials")));
                orchestrationService.MarkupService           = new MarkdownMarkupService();
                orchestrationService.HtmlMinificationService = new GoogleHtmlMinificationService();

                orchestrationService.AssetsReaderService    = new FileSystemBinaryContentReaderService <BinaryContentModel>(Path.Combine(sourcePath, "assets"));
                orchestrationService.PageModelReaderService = new FileSystemTextContentReaderService <PageModel>(Path.Combine(sourcePath, "pages"));
                orchestrationService.TemplateReaderService  = new FileSystemTextContentReaderService <TemplateModel>(Path.Combine(sourcePath, "layout"));
                orchestrationService.DataService            = dataService;

                orchestrationService.PageModelWriterService = new FileSystemTextContentWriterService <TextContentModel>(Path.Combine(outputPath));
                orchestrationService.AssetsWriterService    = new FileSystemBinaryContentWriterService <BinaryContentModel>(Path.Combine(outputPath, "assets"));

                orchestrationService.RenderProjectAsync().Wait();

                LoggerService.WriteLogMessage("Rendering finished successfully").Wait();

                return(0);
            });
        }
Ejemplo n.º 4
0
        public JsonResult Create(Team team)
        {
            var activeUser = this.GetActiveUser(this.Request);

            if (activeUser == null)
            {
                throw new HttpException((int)HttpStatusCode.Unauthorized, "Invalid user");
            }

            var type        = team.Type;
            var prepopulate = team.Prepopulate;
            var makePublic  = team.MakePublic;

            if (prepopulate)
            {
                // User asked us to prepoplate the team with a sample schedule and roster
                team = new OrchestrationService().CreateSampleTeam(team.Name, activeUser);
            }
            else
            {
                // Normal, empty team
                team = _teamService.AddTeam(team, activeUser);
            }

            // Set settings
            var settings = new TeamSettingsViewModel
            {
                TeamId  = team.Id,
                Name    = team.Name,
                Privacy = new TeamPrivacyData {
                    HomePage = makePublic, Roster = true
                },
                Settings = new TeamSettingsData {
                    EmailColumn = true
                }                                                      // Defined below
            };

            switch (type)
            {
            case "online":
                settings.Settings.ArenaColumn    = false;
                settings.Settings.LastNameColumn = false;
                settings.Settings.PositionColumn = true;
                settings.Settings.PhoneColumn    = false;
                settings.Settings.ResultsView    = 1;
                break;

            case "club":
                settings.Settings.ArenaColumn    = false;
                settings.Settings.LastNameColumn = true;
                settings.Settings.PositionColumn = false;
                settings.Settings.PhoneColumn    = true;
                settings.Settings.ResultsView    = 3;
                break;

            default:     // & "sports"
                settings.Settings.ArenaColumn    = true;
                settings.Settings.LastNameColumn = true;
                settings.Settings.PositionColumn = true;
                settings.Settings.PhoneColumn    = true;
                settings.Settings.ResultsView    = 0;
                break;
            }
            _teamService.UpdateSettings(settings);

            return(Json(team));
        }