Ejemplo n.º 1
0
        public async Task<IActionResult> Publish(PostFormViewModel model)
        {
            if (model == null)
            {
                return new HttpStatusCodeResult((int)HttpStatusCode.BadRequest);
            }

            var vm = new PostPublishViewModel
                         {
                             Theme = this._settings.Theme,
                             HeadPartialViewPath = this._themeService.GetHeadPartialViewPath(this._settings.Theme),
                             HeaderPartialViewPath = this._themeService.GetHeaderPartialViewPath(this._settings.Theme),
                             PostPartialViewPath = this._themeService.GetPostPartialViewPath(this._settings.Theme),
                             FooterPartialViewPath = this._themeService.GetFooterPartialViewPath(this._settings.Theme),
                         };

            var env = this.Resolver.GetService(typeof(IApplicationEnvironment)) as IApplicationEnvironment;

            var publishedpath = await this._publishService.PublishPostAsync(model.Body, env, this.Request).ConfigureAwait(false);
            vm.MarkdownPath = publishedpath.Markdown;
            vm.HtmlPath = publishedpath.Html;

            return this.View(vm);
        }
Ejemplo n.º 2
0
 public IActionResult Write()
 {
     var vm = new PostFormViewModel();
     return this.View(vm);
 }
Ejemplo n.º 3
0
        public async Task<IActionResult> Preview(PostFormViewModel model)
        {
            if (model == null)
            {
                return new HttpStatusCodeResult((int)HttpStatusCode.BadRequest);
            }

            var vm = new PostPreviewViewModel()
                         {
                             Theme = this._settings.Theme,
                             HeadPartialViewPath = this._themeService.GetHeadPartialViewPath(this._settings.Theme),
                             HeaderPartialViewPath = this._themeService.GetHeaderPartialViewPath(this._settings.Theme),
                             PostPartialViewPath = this._themeService.GetPostPartialViewPath(this._settings.Theme),
                             FooterPartialViewPath = this._themeService.GetFooterPartialViewPath(this._settings.Theme),
                         };

            var page = new PageSettings();
            page.Title = "Hello World";
            page.Description = "This is description";
            page.Author = new Author() { Name = "joebloggs" };
            page.Date = DateTime.Today;
            page.BaseUrl = this._settings.BaseUrl;
            page.Url = "/posts/post.html";
            page.Pages = new List<PageSettings>();

            vm.Page = page;

            var env = this.Resolver.GetService(typeof(IApplicationEnvironment)) as IApplicationEnvironment;

            var loader = new ThemeLoader(this._settings, new FileHelper(this._settings));
            var site = await loader.LoadAsync(env).ConfigureAwait(false);
            vm.Site = site;

            var parsedHtml = this._markdownHelper.Parse(model.Body);
            vm.Html = parsedHtml;

            return this.View(vm);
        }