/// <summary> /// Any setting that is derived from the homepage html needs to be in this function. This function is turned /// on and off when detecting blog settings through the IncludeHomePageSettings. None of these checks will be run /// if the internet is not active. As each check is made, it does not need to be applied back the _content until the end /// at which time it will write the settings back to the registry. /// </summary> private void DetectHomePageSettings() { if (_homepageAccessor.HtmlDocument == null) { return; } IDictionary homepageSettings = new Hashtable(); Debug.Assert(!UseManifestCache, "This code will not run correctly under the manifest cache, due to option overrides not being set"); LightWeightHTMLMetaData metaData = new LightWeightHTMLMetaData(_homepageAccessor.HtmlDocument); if (metaData.Charset != null) { try { homepageSettings.Add(BlogClientOptions.CHARACTER_SET, metaData.Charset); } catch (NotSupportedException) { //not an actual encoding } } string docType = new LightWeightHTMLMetaData(_homepageAccessor.HtmlDocument).DocType; if (docType != null) { bool xhtml = docType.IndexOf("xhtml", StringComparison.OrdinalIgnoreCase) >= 0; if (xhtml) { homepageSettings.Add(BlogClientOptions.REQUIRES_XHTML, true.ToString(CultureInfo.InvariantCulture)); } } //checking whether blog is rtl HtmlExtractor extractor = new HtmlExtractor(_homepageAccessor.HtmlDocument.RawHtml); if (extractor.Seek(new OrPredicate( new SmartPredicate("<html dir>"), new SmartPredicate("<body dir>"))).Success) { BeginTag tag = (BeginTag)extractor.Element; string dir = tag.GetAttributeValue("dir"); if (String.Compare(dir, "rtl", StringComparison.OrdinalIgnoreCase) == 0) { homepageSettings.Add(BlogClientOptions.TEMPLATE_IS_RTL, true.ToString(CultureInfo.InvariantCulture)); } } if (_homepageAccessor.HtmlDocument != null) { string html = _homepageAccessor.OriginalHtml; ImageViewer viewer = DhtmlImageViewers.DetectImageViewer(html, _context.HomepageUrl); if (viewer != null) { homepageSettings.Add(BlogClientOptions.DHTML_IMAGE_VIEWER, viewer.Name); } } _context.HomePageOverrides = homepageSettings; }