public void Pass(HtmlDocument doc)
        {
            var nodes = doc.DocumentNode.SelectNodes("//audio");

            if (nodes != null)
            {
                var c = new Component();
                c.ElementName = "amp-audio";
                c.ScriptPath  = "https://cdn.ampproject.org/v0/amp-audio-0.1.js";

                RequiredComponents.Add(c);

                foreach (HtmlNode n in nodes)
                {
                    n.Name = "amp-audio";

                    if (n.Attributes["width"] == null)
                    {
                        n.Attributes.Add("width", "auto");
                    }

                    n.Attributes["width"].Value = "auto";
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Initialize a set of <see cref="IComponent"/> types that all entities associated with this system must have.
        /// </summary>
        /// <param name="components">The types of <see cref="IComponent"/> this system will require before associating with an entity.</param>
        public void Require(params Type[] components)
        {
            RequiredComponents.Clear();

            for (int i = 0; i < components.Length; i++)
            {
                RequiredComponents.Add(components[i]);
            }
        }
Exemple #3
0
        public void Pass(HtmlDocument doc)
        {
            var nodes = doc.DocumentNode.SelectNodes("//iframe[not(ancestor::noscript)]");

            if (nodes != null)
            {
                var c = new Component();
                c.ElementName = "amp-youtube";
                c.ScriptPath  = "https://cdn.ampproject.org/v0/amp-youtube-0.1.js";

                RequiredComponents.Add(c);

                foreach (HtmlNode n in nodes)
                {
                    if (!IsYouTubeIframe(n))
                    {
                        continue;
                    }

                    var ytCode = GetYouTubeCode(n);

                    if (string.IsNullOrWhiteSpace(ytCode))
                    {
                        continue;
                    }

                    HtmlNode ampYouTube = HtmlNode.CreateNode(string.Format("<amp-youtube data-videoid=\"{0}\" layout=\"responsive\"></amp-youtube>", ytCode));

                    EnsureHeightAndWidthAttributes(n);
                    ScrubAttributes(n, null, true);

                    foreach (HtmlAttribute attr in n.Attributes)
                    {
                        ampYouTube.Attributes.Add(attr.Name, attr.Value);
                    }

                    n.ParentNode.ReplaceChild(ampYouTube, n);
                }
            }
        }