/// <summary> /// Adds an appropriate FieldFilter to the given PageAssemblyInstruction object, based on the Tag's /// current settings. /// </summary> /// <param name="pai">The IPageAssemblyInstruction object to receive the new FieldFilter.</param> private void RegisterSocialMetaTagFieldFilter(IPageAssemblyInstruction pai, SocialMetaTagData socialMetaTag) { // add a field filter for each tag pai.AddFieldFilter(socialMetaTag.Id, (name, data) => { string content = String.Empty; switch (socialMetaTag.Source) { case SocialMetaTagSources.field: content = pai.GetField(socialMetaTag.Content); break; case SocialMetaTagSources.url: content = pai.GetUrl(socialMetaTag.Content).ToString(); break; // both literal types just use the content directly default: content = socialMetaTag.Content; break; } data.Value = content; }); }
/// <summary> /// Creates field filters for the given SocialMetadata object. /// </summary> /// <param name="pai">An available PageAssemblyInstruction object to receive the field filters.</param> /// <param name="socialMetadata">The SocialMetadata object to provide the fields.</param> protected virtual void RegisterSocialMetadataFieldFilters(IPageAssemblyInstruction pai, SocialMetadata socialMetadata) { try { // check provided PageAssemblyInstruction if (pai == null) { log.Warn("RegisterSocialMetadataFieldFilters(): null PageAssemblyInstruction provided."); return; } // add commenting available field filter pai.AddFieldFilter("is_commenting_available", (name, data) => { data.Value = socialMetadata.IsCommentingAvailable.ToString(); }); // add field filters for any tags if (socialMetadata.Tags != null) { foreach (SocialMetaTagData tag in socialMetadata.Tags) { RegisterSocialMetaTagFieldFilter(pai, tag); } } } catch (Exception e) { log.Error("InitializeFieldFilters(): Exception encountered while initializing field filters.", e); } }
/// <summary> /// Returns the metadata value for different types of metadata name. /// </summary> /// <param name="metaDataType"></param> /// <returns></returns> private String getMetaData(HtmlMetaDataType metaDataType) { IPageAssemblyInstruction asmInstr = PageAssemblyInstruction; string path = asmInstr.SectionPath; string metaData = String.Empty; if (asmInstr != null) { switch (metaDataType) { case HtmlMetaDataType.Description: metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaDescription); break; case HtmlMetaDataType.KeyWords: metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaKeywords); break; case HtmlMetaDataType.Robots: metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaRobots); break; case HtmlMetaDataType.ContentLanguage: metaData = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; break; case HtmlMetaDataType.Coverage: // Suite(s) metaData = SectionDetailFactory.GetSectionDetail(path).GetWASuites(); break; case HtmlMetaDataType.Subject: // Channel(s) metaData = SectionDetailFactory.GetSectionDetail(path).GetWAChannels(); break; case HtmlMetaDataType.IsPartOf: // Content group(s) metaData = SectionDetailFactory.GetSectionDetail(path).GetWAContentGroups(); break; case HtmlMetaDataType.DatePublished: metaData = String.Format("{0:MM/dd/yyyy}", ((BasePageAssemblyInstruction)PageAssemblyInstruction).ContentDates.FirstPublished); break; case HtmlMetaDataType.EnglishLinkingPolicy: metaData = ContentDeliveryEngineConfig.PathInformation.EnglishLinkingPolicyPath.Path; break; case HtmlMetaDataType.EspanolLinkingPolicy: metaData = ContentDeliveryEngineConfig.PathInformation.EspanolLinkingPolicyPath.Path; break; case HtmlMetaDataType.ContentType: metaData = ((BasePageAssemblyInstruction)PageAssemblyInstruction).ContentItemInfo.ContentItemType; metaData = metaData.Replace("rx:", ""); break; } } metaData = string.IsNullOrEmpty(metaData) ? "" : metaData.Trim(); return(metaData); }
protected void Page_Load(object sender, EventArgs e) { IPageAssemblyInstruction pageInstruction = PageAssemblyContext.Current.PageAssemblyInstruction; BasePageAssemblyInstruction basePage = pageInstruction as BasePageAssemblyInstruction; string blogName = ""; string blogContentType = "rx:cgvBlogPost"; if (basePage.ContentItemInfo.ContentItemType == blogContentType) { blogName = SectionDetailFactory.GetSectionDetail(pageInstruction.SectionPath).GetWAContentGroups(); if (!String.IsNullOrWhiteSpace(blogName)) { basePage.SetWebAnalytics(WebAnalyticsOptions.eVars.evar48.ToString(), ffD => { ffD.Value = blogName + " Viewer"; }); basePage.SetWebAnalytics(WebAnalyticsOptions.Events.event53.ToString(), ffD => { ffD.Value = String.Empty; // only fires off event number; no value needed }); } } this.Visible = false; }
/// <summary> /// Generate the content string to place in the meta tag. Can return null if no content exists. /// </summary> public string ResolveContent(IPageAssemblyInstruction IPageAssemblyInstruction) { string content = IPageAssemblyInstruction.GetField(Key); // for url or file types, append the latest field into the hostname. if (SocialMetaTagData.PrependHost && (SocialMetaTagData.Source == SocialMetaTagSources.url || SocialMetaTagData.Source == SocialMetaTagSources.literalUrl)) { content = ContentDeliveryEngineConfig.CanonicalHostName.CanonicalUrlHostName.CanonicalHostName + content; } // if the content is null at this point... if (String.IsNullOrEmpty(content)) { if (SocialMetaTagData.AllowEmptyContent) { // ensure is a string if empty content is allowed content = ""; } else { // else, provide null content content = null; } } return(content); }
//[DeploymentItem("XmlFiles\\cancertopics.xml")] //[DeploymentItem("XmlFiles\\PageTemplateConfiguration.xml")] public void InitializePageAssemblyInfo_Test() { PageAssemblyContext_Accessor target = new PageAssemblyContext_Accessor(); // TODO: Initialize to an appropriate value string xmlFilePath = TestContext.TestDeploymentDir + "\\PublishedContent\\PageInstructions\\cancertopics.xml"; IPageAssemblyInstruction pageAssemblyInfo = null; using (HttpSimulator httpSimulator = GetStandardSimulatedRequest()) { using (XmlReader xmlReader = XmlReader.Create(xmlFilePath)) { xmlReader.MoveToContent(); string pageAssemblyInfoTypeName = xmlReader.LocalName; //XmlSerializer serializer = _serializers[pageAssemblyInfoTypeName]; XmlSerializer serializer = new XmlSerializer(typeof(SinglePageAssemblyInstruction)); // Deserialize the XML into an object. pageAssemblyInfo = (IPageAssemblyInstruction)serializer.Deserialize(xmlReader); } IPageAssemblyInstruction info = pageAssemblyInfo; DisplayVersions dispayVersion = DisplayVersions.Web; //Load the page template info for the current request PageTemplateInfo pageTemplateInfo = new PageTemplateInfo(); pageTemplateInfo.PageTemplatePath = "FOO.ASPX"; target.InitializePageAssemblyInfo(info, dispayVersion, pageTemplateInfo, "url"); Assert.Inconclusive("A method that does not return a value cannot be verified."); } }
public void GetField_HTML_Title_Field_Test() { using (HttpSimulator httpSimulator = GetStandardSimulatedRequest()) { string HTML_Title = "Cancer Topics Home Page--About This Booklet"; IPageAssemblyInstruction actual = PageAssemblyInstructionFactory.GetPageAssemblyInfo("/multicancertopics"); Assert.AreEqual(HTML_Title, actual.GetField("HTML_Title")); } }
public void GetPageAssemblyInfo_SinglePageAssemblyInstruction_XMLFileNotExixts_Test() { using (HttpSimulator httpSimulator = GetStandardSimulatedRequest()) { IPageAssemblyInstruction actual = PageAssemblyInstructionFactory.GetPageAssemblyInfo("/cancertopics2"); SinglePageAssemblyInstruction expected = GetCancerTopicsSinglePageAssemblyInstuction(); Assert.AreNotEqual(expected, actual); } }
public void GetField_HTML_MetaKeywords_Test() { string MetaKeywords = "cancer,information"; IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); Assert.AreEqual(MetaKeywords, pageAssemblyInfo.GetField("HTML_MetaKeywords")); }
public void GetField_HTML_MetaDescription_Test() { string MetaDescription = "Information from the National Cancer Institute about cancer treatment, prevention, screening, genetics, causes, and how to cope with cancer."; IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); Assert.AreEqual(MetaDescription, pageAssemblyInfo.GetField("HTML_MetaDescription")); }
public void GetField_HTML_Title_Field_Test() { string HTML_Title = "Cancer Topics Home Page"; IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); Assert.AreEqual(HTML_Title, pageAssemblyInfo.GetField("HTML_Title")); }
public void GetField_HTML_MetaKeywords_Test() { using (HttpSimulator httpSimulator = GetStandardSimulatedRequest()) { string MetaKeywords = "cancer,information,About This Booklet"; IPageAssemblyInstruction actual = PageAssemblyInstructionFactory.GetPageAssemblyInfo("/multicancertopics"); Assert.AreEqual(MetaKeywords, actual.GetField("HTML_MetaKeywords")); } }
public void GetAlternateContentVersion() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); string[] alternateContentVersion = null; alternateContentVersion = pageAssemblyInfo.AlternateContentVersionsKeys; Assert.IsNotNull(alternateContentVersion); Assert.IsTrue(alternateContentVersion.Length > 0); }
public void GetField_HTML_MetaDescription_Test() { using (HttpSimulator httpSimulator = GetStandardSimulatedRequest()) { string MetaDescription = "sdfds --About This Booklet"; IPageAssemblyInstruction actual = PageAssemblyInstructionFactory.GetPageAssemblyInfo("/multicancertopics"); Assert.AreEqual(MetaDescription, actual.GetField("HTML_MetaDescription")); } }
/// <summary> /// Register all site wide field filters for Web Analytics. /// </summary> protected virtual void RegisterWebAnalyticsFieldFilters() { IPageAssemblyInstruction pgInst = ((IPageAssemblyInstruction)this); // Add root pretty URL SetWebAnalytics(WebAnalyticsOptions.Props.prop3.ToString(), wbField => { wbField.Value = pgInst.GetUrl("RootPrettyURL").ToString(); }); }
public void MultiPageAssemblyInstruction_XMLSerializer_Test() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); Assert.IsNotNull(pageAssemblyInfo); Assert.IsNotNull(pageAssemblyInfo.PageTemplateName); Assert.IsNotNull(pageAssemblyInfo.SectionPath); }
/// <summary> /// This method intialize the state of the base object or peform tasks that are /// applicable to all derived class object. /// </summary> public virtual void Initialize() { IPageAssemblyInstruction pgInst = ((IPageAssemblyInstruction)this); // field filters pgInst.AddFieldFilter("invokedFrom", (name, field) => { field.Value = String.Empty; }); pgInst.AddFieldFilter("language", (name, field) => { string languageValue = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; field.Value = languageValue; }); // URL filters pgInst.AddUrlFilter("RootPrettyURL", (name, url) => { url.SetUrl(pgInst.GetUrl("CurrentURL").ToString()); // This is hack to fix the RootPrettyURL. If this content type is // rx:pdqCancerInfoSummary then remove the 'patient' or 'healthprofessional' from // the pretty url string prettyUrl = pgInst.GetUrl("PrettyURL").ToString().ToLower(); if (ContentItemInfo != null && ContentItemInfo.ContentItemType == "rx:pdqCancerInfoSummary") { int verIndex = prettyUrl.LastIndexOf("/patient"); if (verIndex == -1) { verIndex = prettyUrl.LastIndexOf("/healthprofessional"); } if (verIndex != -1) { prettyUrl = prettyUrl.Substring(0, verIndex); } } url.SetUrl(prettyUrl); }); pgInst.AddUrlFilter("BookMarkShareUrl", (name, url) => { url.SetUrl(pgInst.GetUrl("CurrentURL").ToString()); }); pgInst.AddUrlFilter("EmailUrl", (name, url) => { url.SetUrl(pgInst.GetUrl("CurrentURL").ToString()); }); pgInst.AddUrlFilter("PostBackURL", (name, url) => { url.SetUrl(pgInst.GetUrl("CurrentURL") + "?" + HttpContext.Current.Request.QueryString); }); }
public void AddField_EmptyFieldName_Test() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); pageAssemblyInfo.AddFieldFilter(string.Empty, (name, data) => { data.Value = "Dictionary of cancer terms"; }); }
public void GetBlockedSlots_Test() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); string[] expectedBlockSlots = { "cgvContentHeader" }; string[] actualblockedSlots; actualblockedSlots = pageAssemblyInfo.BlockedSlotNames; Assert.AreEqual(expectedBlockSlots[0], actualblockedSlots[0]); }
public void GetWebAnalytics() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); WebAnalyticsSettings webAnalyticsSettings = null; webAnalyticsSettings = pageAssemblyInfo.GetWebAnalytics(); Assert.IsNotNull(webAnalyticsSettings); Assert.IsTrue(webAnalyticsSettings.Props.Count > 0); Assert.IsTrue(webAnalyticsSettings.Evars.Count > 0); }
public void AddUrl_EmptyUrlType_Test() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); pageAssemblyInfo.AddUrlFilter(string.Empty, (name, url) => { url.Clear(); url.UriStem = "/foo"; }); }
public void ContainsURL_Test() { using (HttpSimulator httpSimulator = GetStandardSimulatedRequest()) { IPageAssemblyInstruction actual = PageAssemblyInstructionFactory.GetPageAssemblyInfo("/multicancertopics"); Object[] args = new Object[] { "multicancertopics/page100" }; Boolean boolContainsUrl = (Boolean)actual.GetType().InvokeMember("ContainsURL", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, actual, args); Assert.IsFalse(boolContainsUrl); } }
public void GetField_Test() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); pageAssemblyInfo.AddFieldFilter("Foo12345", (name, data) => { data.Value = "Foo12345"; }); Assert.AreEqual("Foo12345", pageAssemblyInfo.GetField("Foo12345")); }
public void GetUrl_PrettyURL_Test() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); NciUrl PrettyUrl = new NciUrl(); PrettyUrl = pageAssemblyInfo.GetUrl(PageAssemblyInstructionUrls.PrettyUrl); Assert.AreEqual <string>("/multicancertopics", PrettyUrl.UriStem); }
/// <summary> /// Stores the current page assembly instruction object in the context so it can be made /// available in one central location. /// </summary> /// <param name="info"></param> public void InitializePageAssemblyInfo(IPageAssemblyInstruction info, DisplayVersions displayVersion, PageTemplateInfo pageTemplateInfo, string requestedPath) { if (PageAssemblyInstruction != null) { throw new Exception("You cannot initialize the page assembly context with more than one IPageAssemblyInfo instance."); } else { PageAssemblyInstruction = info; PageAssemblyContext.Current.DisplayVersion = displayVersion; PageAssemblyContext.Current.PageTemplateInfo = pageTemplateInfo; PageAssemblyContext.Current.requestedUrl = requestedPath; } }
public void GetUrl_Cannonical_Test() { IPageAssemblyInstruction pageAssemblyInfo = null; pageAssemblyInfo = InitializeTestPageAssemblyInfo(); NciUrl CanonicalUrl = new NciUrl(); CanonicalUrl = pageAssemblyInfo.GetUrl(PageAssemblyInstructionUrls.CanonicalUrl); Assert.AreEqual <string>("/multicancertopics", CanonicalUrl.UriStem); }
/// <summary> /// Process the syndication XML field - determines if the syndication notice /// should display or not /// </summary> private bool displaySyndicationNotice() { IPageAssemblyInstruction pgInstruction = PageAssemblyContext.Current.PageAssemblyInstruction; // If AlternateContentVersions information is not in the instructions then do not create // the PageOptions box. string[] acvKeys = pgInstruction.AlternateContentVersionsKeys; bool isSyndicated = false; if (acvKeys != null && acvKeys.Contains("syndicated")) { isSyndicated = true; } return(isSyndicated); }
public void RegisterFieldFilters_Test() { using (HttpSimulator httpSimulator = GetStandardSimulatedRequest()) { PageAssemblyInstructionLoader_Accessor target = new PageAssemblyInstructionLoader_Accessor(); HttpContext context = HttpContext.Current; string url = "/multicancertopics/page2"; target.RewriteUrl(context, url); Object[] args = new Object[] { 2 }; IPageAssemblyInstruction actual = PageAssemblyInstructionFactory.GetPageAssemblyInfo("/multicancertopics"); actual.GetType().InvokeMember("RegisterFieldFilters", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, actual, args); } }
private void SetupTranslationFilters(IPageAssemblyInstruction pai, string lang) { // check provided PageAssemblyInstruction if (pai == null) { log.Warn("SetupTranslationFilter(): null PageAssemblyInstruction provided."); return; } CultureInfo info = new CultureInfo(lang); string translationLang = info.TwoLetterISOLanguageName; PageAssemblyContext.Current.PageAssemblyInstruction.AddTranslationFilter(lang, (name, url) => { url.SetUrl(url.ToString() + "/def/" + GetCDRIDForLanguageToggle(translationLang)); }); }
public void GetPageSnippets_Test() { using (HttpSimulator httpSimulator = GetStandardSimulatedRequest()) { PageAssemblyInstructionLoader_Accessor target = new PageAssemblyInstructionLoader_Accessor(); HttpContext context = HttpContext.Current; string url = "/multicancertopics/page2"; int snippetCount = 2; target.RewriteUrl(context, url); IPageAssemblyInstruction actual = PageAssemblyInstructionFactory.GetPageAssemblyInfo("/multicancertopics"); List <SnippetInfo> boolContainsUrl = (List <SnippetInfo>)actual.GetType().InvokeMember("GetPageSnippets", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, actual, null); Assert.AreEqual(snippetCount, boolContainsUrl.Count); } }