public PageService( IProjectService projectService, IProjectSecurityResolver security, IPageQueries pageQueries, IPageCommands pageCommands, PageEvents eventHandlers, IMediaProcessor mediaProcessor, IHtmlProcessor htmlProcessor, IUrlHelperFactory urlHelperFactory, IPageRoutes pageRoutes, IMemoryCache cache, IStringLocalizer <cloudscribe.SimpleContent.Web.SimpleContent> localizer, IPageNavigationCacheKeys cacheKeys, IActionContextAccessor actionContextAccesor, IHttpContextAccessor contextAccessor = null) { this.projectService = projectService; this.security = security; this.pageQueries = pageQueries; this.pageCommands = pageCommands; context = contextAccessor?.HttpContext; this.mediaProcessor = mediaProcessor; this.urlHelperFactory = urlHelperFactory; this.actionContextAccesor = actionContextAccesor; this.pageRoutes = pageRoutes; this.htmlProcessor = htmlProcessor; this.cache = cache; this.cacheKeys = cacheKeys; this.eventHandlers = eventHandlers; sr = localizer; }
public BlogController( IProjectService projectService, IBlogService blogService, IBlogRoutes blogRoutes, IHtmlProcessor htmlProcessor, IProjectEmailService emailService, IAuthorizationService authorizationService, IAuthorNameResolver authorNameResolver, ITimeZoneHelper timeZoneHelper, IStringLocalizer <SimpleContent> localizer, IOptions <SimpleContentConfig> configOptionsAccessor, ILogger <BlogController> logger ) { this.projectService = projectService; this.blogService = blogService; this.htmlProcessor = htmlProcessor; this.blogRoutes = blogRoutes; this.authorNameResolver = authorNameResolver; this.emailService = emailService; this.authorizationService = authorizationService; this.timeZoneHelper = timeZoneHelper; sr = localizer; log = logger; config = configOptionsAccessor.Value; }
public BlogService( IProjectService projectService, IProjectSecurityResolver security, IPostQueries postQueries, IPostCommands postCommands, IMediaProcessor mediaProcessor, IHtmlProcessor htmlProcessor, IBlogRoutes blogRoutes, PostEvents eventHandlers, IUrlHelperFactory urlHelperFactory, IActionContextAccessor actionContextAccesor, IHttpContextAccessor contextAccessor = null) { this.security = security; this.postQueries = postQueries; this.postCommands = postCommands; context = contextAccessor?.HttpContext; this.mediaProcessor = mediaProcessor; this.urlHelperFactory = urlHelperFactory; this.actionContextAccesor = actionContextAccesor; this.projectService = projectService; this.htmlProcessor = htmlProcessor; this.blogRoutes = blogRoutes; this.eventHandlers = eventHandlers; }
public ContentProcessor( IHtmlProcessor htmlProcessor, IMarkdownProcessor markdownProcessor ) { _htmlProcessor = htmlProcessor; _markdownProcessor = markdownProcessor; }
public BlogViewModel(IHtmlProcessor htmlProcessor) { ProjectSettings = new ProjectSettings(); Paging = new PaginationSettings(); Categories = new Dictionary <string, int>(); Archives = new Dictionary <string, int>(); filter = htmlProcessor; BlogRoutes = new DefaultBlogRoutes(); }
public Scraper(IHtmlWebService htmlWebService, ISetupManager setupManager, IHtmlProcessor htmlProcessor) { _htmlWebService = htmlWebService; _setupManager = setupManager; _htmlProcessor = htmlProcessor; _robots = new Robots(string.Empty); _processedList = new List <string>(); _toProcessList = new Stack <string>(); }
public Handler(BlogContext context, ImageContext imageContext, IMapper mapper, IDateProvider dateProvider, IHtmlProcessor htmlProcessor) { _context = context; _imageContext = imageContext; _mapper = mapper; _dateProvider = dateProvider; _htmlProcessor = htmlProcessor; }
public RssChannelProvider(IBlogService blogService, IActionContextAccessor actionContextAccesor, IHttpContextAccessor contextAccessor, IUrlHelperFactory urlHelperFactory, IHtmlProcessor htmlProcessor) { _blogService = blogService; _actionContextAccesor = actionContextAccesor; _urlHelperFactory = urlHelperFactory; _contextAccessor = contextAccessor; _htmlProcessor = htmlProcessor; }
public RssChannelProvider( IProjectService projectService, IBlogService blogService, IBlogRoutes blogRoutes, IHttpContextAccessor contextAccessor, IUrlHelperFactory urlHelperFactory, IActionContextAccessor actionContextAccesor, IHtmlProcessor htmlProcessor) { this.projectService = projectService; this.blogService = blogService; this.contextAccessor = contextAccessor; this.urlHelperFactory = urlHelperFactory; this.actionContextAccesor = actionContextAccesor; this.htmlProcessor = htmlProcessor; this.blogRoutes = blogRoutes; }
public PageController( IProjectService projectService, IPageService blogService, IHtmlProcessor htmlProcessor, IPageRoutes pageRoutes, IAuthorizationService authorizationService, ITimeZoneHelper timeZoneHelper, IStringLocalizer <SimpleContent> localizer, ILogger <PageController> logger) { this.projectService = projectService; this.pageService = blogService; this.htmlProcessor = htmlProcessor; this.authorizationService = authorizationService; this.timeZoneHelper = timeZoneHelper; this.pageRoutes = pageRoutes; sr = localizer; log = logger; }
public async Task <CommandResult> Publish(IDateProvider dateProvider, IHtmlProcessor processor) { var errors = new ErrorManager() .Required(Title, "Title") .Required(Tags, "Tags") .Required(Summary, "Summary") .Required(Content, "Content") .IfTrue(Language == Language.Farsi && string.IsNullOrEmpty(EnglishUrl), "EnglishUrl is required for Farsi posts") .Add(ValidateCodeBlocks()); if (errors.Dirty) { return(errors.ToResult()); } if (!_publishDate.HasValue) { _publishDate = dateProvider.Now; } try { Post = new Post(Id, Title, _publishDate.Value, Language, Summary, Tags, GetImageDirectoryName(), await processor.ProcessAsync(Content)); } catch (ServiceDependencyException exc) { errors.Add(exc.Message); } return(errors.ToResult()); }
/// <summary> /// /// </summary> public override string ExecuteToString() { // hanshake should be ran before and there should not be error if (_webData == null || LastStatus == LastStatus.Error) { return(String.Empty); } // process type DataTypeToProcess processType = DataTypeToProcess; // gets mime type of content type MimeContentType contentMimeType = _webData.ResponseInfo.ContentTypeMime; // detecting processing method by response content type if (processType == DataTypeToProcess.AutoDetect) { // gets its process type processType = Common.MimeTypeToToProcessType(contentMimeType); } if (processType == DataTypeToProcess.Html && Systems.LogSystem.ActivityLogEnabled) { Systems.LogSystem.Log(LogEntity.UrlRequested, ResponseInfo.ResponseUrl); } IDataProcessor dataProcessor = null; switch (processType) { case DataTypeToProcess.AutoDetect: break; case DataTypeToProcess.Html: dataProcessor = (IDataProcessor)Providers.GetProvider(ProviderType.IHtmlProcessor); break; case DataTypeToProcess.JavaScript: dataProcessor = (IDataProcessor)Providers.GetProvider(ProviderType.IJSProcessor); break; case DataTypeToProcess.Css: dataProcessor = (IDataProcessor)Providers.GetProvider(ProviderType.ICssProcessor); break; case DataTypeToProcess.AdobeFlash: // still nothing default: break; } if (dataProcessor != null) { // 3- executing the plugins if (_isPluginAvailable) { Plugins.CallPluginMethod(PluginHosts.IPluginEngine, PluginMethods.IPluginEngine.BeforeProcessor, this, dataProcessor); } // Web data instance dataProcessor.WebData = _webData; // executes the process string response = dataProcessor.Execute(); // If execution occurred if (dataProcessor.LastStatus == LastStatus.Error) { LastStatus = LastStatus.Error; LastErrorMessage = dataProcessor.LastErrorMessage; LastException = dataProcessor.LastException; return(response); } else if (dataProcessor.LastStatus == LastStatus.ContinueWithError) { LastStatus = LastStatus.ContinueWithError; LastErrorMessage = dataProcessor.LastErrorMessage; LastException = dataProcessor.LastException; } // processed content encoding ResponseInfo.ContentEncoding = dataProcessor.ContentEncoding; ResponseInfo.ContentLength = response.Length; // Html specifies if (processType == DataTypeToProcess.Html && dataProcessor is IHtmlProcessor) { IHtmlProcessor htmlProcessor = (IHtmlProcessor)dataProcessor; ResponseInfo.HtmlPageTitle = htmlProcessor.PageTitle; ResponseInfo.HtmlIsFrameSet = htmlProcessor.IsFrameSet; ResponseInfo.ExtraCodesForPage = htmlProcessor.ExtraCodesForPage; ResponseInfo.ExtraCodesForBody = htmlProcessor.ExtraCodesForBody; ResponseInfo.HtmlDocType = htmlProcessor.DocType; } // 4- executing the plugins if (_isPluginAvailable) { Plugins.CallPluginMethod(PluginHosts.IPluginEngine, PluginMethods.IPluginEngine.AfterProcessor, this); } // the processed content return(response); } else { Encoding contentEncoding; // Reads response stream to a string string response = StringStream.GetString( _webData.ResponseData, WebData.ResponseInfo.ContentType, UserOptions.ForceEncoding, false, out contentEncoding); ResponseInfo.ContentEncoding = contentEncoding; ResponseInfo.ContentLength = response.Length; return(response); } }
/// <summary> /// /// </summary> public override void ExecuteToStream(Stream stream) { // handshake should be ran before and there should not be error if (_webData == null || LastStatus == LastStatus.Error) { return; } // process type DataTypeToProcess processType = DataTypeToProcess; // gets mime type of content type MimeContentType contentMimeType = _webData.ResponseInfo.ContentTypeMime; // detecting processing method by response content type if (processType == DataTypeToProcess.AutoDetect) { // gets its process type processType = Common.MimeTypeToToProcessType(contentMimeType); } IDataProcessor dataProcessor = null; switch (processType) { case DataTypeToProcess.AutoDetect: break; case DataTypeToProcess.Html: dataProcessor = (IDataProcessor)Providers.GetProvider(ProviderType.IHtmlProcessor); break; case DataTypeToProcess.JavaScript: dataProcessor = (IDataProcessor)Providers.GetProvider(ProviderType.IJSProcessor); break; case DataTypeToProcess.Css: dataProcessor = (IDataProcessor)Providers.GetProvider(ProviderType.ICssProcessor); break; case DataTypeToProcess.AdobeFlash: // still nothing case DataTypeToProcess.None: break; default: break; } if (dataProcessor != null) { // 3- executing the plugins if (_isPluginAvailable) { Plugins.CallPluginMethod(PluginHosts.IPluginEngine, PluginMethods.IPluginEngine.BeforeProcessor, this, dataProcessor); } // Web data instance dataProcessor.WebData = _webData; // executes the process string response = dataProcessor.Execute(); // If execution occurred if (dataProcessor.LastStatus == LastStatus.Error) { LastStatus = LastStatus.Error; LastErrorMessage = dataProcessor.LastErrorMessage; LastException = dataProcessor.LastException; return; } else if (dataProcessor.LastStatus == LastStatus.ContinueWithError) { LastStatus = LastStatus.ContinueWithError; LastErrorMessage = dataProcessor.LastErrorMessage; LastException = dataProcessor.LastException; } // processed content encoding ResponseInfo.ContentEncoding = dataProcessor.ContentEncoding; ResponseInfo.ContentLength = response.Length; // Html specifies if (processType == DataTypeToProcess.Html && dataProcessor is IHtmlProcessor) { IHtmlProcessor htmlProcessor = (IHtmlProcessor)dataProcessor; ResponseInfo.HtmlPageTitle = htmlProcessor.PageTitle; ResponseInfo.HtmlIsFrameSet = htmlProcessor.IsFrameSet; ResponseInfo.ExtraCodesForPage = htmlProcessor.ExtraCodesForPage; ResponseInfo.ExtraCodesForBody = htmlProcessor.ExtraCodesForBody; ResponseInfo.HtmlDocType = htmlProcessor.DocType; } // 4- executing the plugins if (_isPluginAvailable) { Plugins.CallPluginMethod(PluginHosts.IPluginEngine, PluginMethods.IPluginEngine.AfterProcessor, this); } // the processed content byte[] streamBuff = ResponseInfo.ContentEncoding.GetBytes(response); stream.Write(streamBuff, 0, streamBuff.Length); } else { // used to resolvent mime processing conflict bool ContinueNonMime = true; // if response is a image if ((UserOptions.ImageCompressor) && (contentMimeType == MimeContentType.image_gif || contentMimeType == MimeContentType.image_jpeg)) { using (MemoryStream imgMem = ImageCompressor.CompressImage( _webData.ResponseData)) { // check if compression is decreased size of data if (imgMem.Length < _webData.ResponseData.Length) { ContinueNonMime = false; // write the image to result imgMem.WriteTo(stream); } else { // Oops! the original image is smaller ContinueNonMime = true; } } } // can process other types? if (ContinueNonMime) { if (processType == DataTypeToProcess.None && _webData.ResponseData is MemoryStream) { MemoryStream mem = (MemoryStream)_webData.ResponseData; if (mem.Length > 0) { mem.WriteTo(stream); } } else if (processType == DataTypeToProcess.None) { int readed = -1; const int blockSize = 1024 * 5; byte[] buffer = new byte[blockSize]; while ((int)(readed = _webData.ResponseData.Read(buffer, 0, blockSize)) > 0) { stream.Write(buffer, 0, readed); } } else { Encoding contentEncoding; // Reads response stream to a string string response = StringStream.GetString( _webData.ResponseData, WebData.ResponseInfo.ContentType, UserOptions.ForceEncoding, false, out contentEncoding); ResponseInfo.ContentEncoding = contentEncoding; ResponseInfo.ContentLength = response.Length; byte[] streamBuff = ResponseInfo.ContentEncoding.GetBytes(response); stream.Write(streamBuff, 0, streamBuff.Length); } } } }
static void InitlizeClasses() { _HtmlProcessor = (IHtmlProcessor)Providers.GetProvider(ProviderType.IHtmlProcessor); _CssProcessor = (ICssProcessor)Providers.GetProvider(ProviderType.ICssProcessor); _JSProcessor = (IJSProcessor)Providers.GetProvider(ProviderType.IJSProcessor); }
public PageViewModel(IHtmlProcessor htmlProcessor) { filter = htmlProcessor; }
public Handler(IDateProvider dateProvider, IHtmlProcessor htmlProcessor, IMapper mapper) { _dateProvider = dateProvider; _htmlProcessor = htmlProcessor; _mapper = mapper; }
public WhenProcessHtmlString() { _htmlProcessor = new HtmlProcessor(); }
public GetSearchPositionsQueryHandler(IGoogleSearchService searchService, IHtmlProcessor htmlProcessor, IOptions <SearchSetting> searchSetting) { _searchService = searchService; _htmlProcessor = htmlProcessor; _searchSetting = searchSetting; }