public async Task Update( string projectId, string userName, string password, IPost post, bool publish) { var permission = await security.ValidatePermissions( projectId, userName, password, CancellationToken ).ConfigureAwait(false); if (!permission.CanEditPosts) { return; } var settings = await projectService.GetProjectSettings(projectId).ConfigureAwait(false); var urlHelper = urlHelperFactory.GetUrlHelper(actionContextAccesor.ActionContext); var imageAbsoluteBaseUrl = urlHelper.Content("~" + settings.LocalMediaVirtualPath); if (context != null) { imageAbsoluteBaseUrl = context.Request.AppBaseUrl() + settings.LocalMediaVirtualPath; } // open live writer passes in posts with absolute urls // we want to change them to relative to keep the files portable // to a different root url post.Content = await htmlProcessor.ConvertMediaUrlsToRelative( settings.LocalMediaVirtualPath, imageAbsoluteBaseUrl, //this shold be resolved from virtual using urlhelper post.Content); // olw also adds hard coded style to images post.Content = htmlProcessor.RemoveImageStyleAttribute(post.Content); var nonPublishedDate = new DateTime(1, 1, 1); if (post.PubDate == nonPublishedDate) { post.PubDate = DateTime.UtcNow; } await eventHandlers.HandlePreUpdate(settings.Id, post.Id).ConfigureAwait(false); await postCommands.Update(settings.Id, post).ConfigureAwait(false); await eventHandlers.HandleUpdated(settings.Id, post).ConfigureAwait(false); }
public async Task Update(IPost post) { await EnsureBlogSettings().ConfigureAwait(false); await _eventHandlers.HandlePreUpdate(_settings.Id, post.Id).ConfigureAwait(false); //if (convertToRelativeUrls) //{ // await _blogUrlResolver.ConvertToRelativeUrls(post, _settings).ConfigureAwait(false); //} await _postCommands.Update(_settings.Id, post).ConfigureAwait(false); await _eventHandlers.HandleUpdated(_settings.Id, post).ConfigureAwait(false); }