/// <summary> /// 输出link tags. /// </summary> /// <param name="settings">站点设置</param> /// <param name="writer">The writer.</param> protected virtual void RenderLinkTags(SiteSettings settings, HtmlTextWriter writer) { NameValueCollection linkTags = Context.Items[linkKey] as NameValueCollection; if (linkTags == null) { linkTags = new NameValueCollection(); } foreach (string key in linkTags.Keys) { writer.WriteLine(linkFormat, key, GlobalSettings.EnsureHtmlEncoded(linkTags[key])); } }
/// <summary> /// 添加样式表 /// </summary> /// <param name="url">样式 URL.</param> /// <param name="media"> media 类型.</param> /// <param name="position">The position.</param> public void AddStyle(string url, HtmlLinkMedia media, StyleRelativePosition position) { if (GlobalSettings.IsNullOrEmpty(url)) { return; } HttpContext context = HttpContext.Current; Queue styleQueue = context.Items[styleKey] as Queue; if (styleQueue == null) { styleQueue = new Queue(); context.Items[styleKey] = styleQueue; } styleQueue.Enqueue(new StyleQueueItem(string.Format(styleFormat, GlobalSettings.EnsureHtmlEncoded(url), (media == HtmlLinkMedia.none?"":" media=\"" + media.ToString() + "\"")), position)); }
/// <summary> /// 输出meta tags /// </summary> /// <param name="settings">站点设置</param> /// <param name="writer">The writer.</param> protected virtual void RenderMetaTags(SiteSettings settings, HtmlTextWriter writer) { NameValueCollection metaTags = Context.Items[metaKey] as NameValueCollection; if (metaTags == null) { metaTags = new NameValueCollection(); } if (GlobalSettings.IsNullOrEmpty(metaTags["description"]) && !GlobalSettings.IsNullOrEmpty(settings.SiteDescription)) { metaTags["description"] = settings.SiteDescription; } if (GlobalSettings.IsNullOrEmpty(metaTags["keywords"]) && !GlobalSettings.IsNullOrEmpty(settings.SearchMetaKeywords)) { metaTags["keywords"] = settings.SearchMetaKeywords; } foreach (string key in metaTags.Keys) { writer.WriteLine(metaFormat, key, GlobalSettings.EnsureHtmlEncoded(metaTags[key])); } }