Example #1
0
        public PageAnalysis CreatePageAnalysis(IPublishedContent node, string focusKeyword = null)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            var pageAnalysis = new PageAnalysis();

            try
            {
                var htmlString = _templateHelper.GetNodeHtml(node);

                pageAnalysis.AbsoluteUrl  = node.UrlAbsolute();
                pageAnalysis.FocusKeyword = focusKeyword;
                pageAnalysis.Size         = _byteSizeHelper.GetByteSize(htmlString);

                SetAnalyzerResults(pageAnalysis, htmlString);
            }
            catch (WebException ex)
            {
                pageAnalysis.Status = ((HttpWebResponse)ex.Response).StatusCode;
            }

            pageAnalysis.Score = _scoreService.GetScore(pageAnalysis);

            return(pageAnalysis);
        }
Example #2
0
        public override void Analyse(IPageData pageData)
        {
            if (pageData == null)
            {
                throw new ArgumentNullException(nameof(pageData));
            }

            var byteCount          = _byteSizeHelper.GetByteSize(pageData.Document.InnerHtml);
            var htmlSizeResultRule = new ResultRule();

            if (byteCount < MaximumSizeInBytes)
            {
                htmlSizeResultRule.Alias = "html_size_small";
                htmlSizeResultRule.Type  = ResultType.Success;
            }
            else
            {
                htmlSizeResultRule.Alias = "html_size_too_large";
                htmlSizeResultRule.Type  = ResultType.Warning;
            }
            htmlSizeResultRule.Tokens.Add(_byteSizeHelper.GetSizeSuffix(byteCount));
            htmlSizeResultRule.Tokens.Add(_byteSizeHelper.GetSizeSuffix(MaximumSizeInBytes));
            AddResultRule(htmlSizeResultRule);
        }