public void Displaying(ShapeDisplayingContext context) { if(!IsMobileDevice()) { return; } var shapeMetadata = context.ShapeMetadata; if (shapeMetadata.Type != "HeadLinks" && shapeMetadata.Type != "Metas") return; var workContext = _workContextAccessor.GetContext(_httpContextAccessor.Current()); var resourceManager = workContext.Resolve<IResourceManager>(); if (shapeMetadata.Type == "HeadLinks") { // <link rel="alternate" type="text/html" media="handheld" href="" /> var handheldLink = new LinkEntry { Type = "text/html", Rel = "alternate", Href = "" }; handheldLink.AddAttribute("media", "handheld"); resourceManager.RegisterLink(handheldLink); // Set the transcoding protection http response headers workContext.HttpContext.Response.Cache.SetNoTransforms(); workContext.HttpContext.Response.AppendHeader("Vary", "User-Agent"); } else if (shapeMetadata.Type == "Metas") { resourceManager.SetMeta(new MetaEntry { // HACK: Orchard doesn't allow metas without a name. Name = "no-transform", HttpEquiv = "Cache-control", Content = "no-transform" }); } }
public void RegisterLink(LinkEntry link) { _links.Add(link); }
public void RegisterLink(LinkEntry entry, HtmlHelper html) { _links.Add(entry); }