CreateHtmlArticle() 공개 정적인 메소드

public static CreateHtmlArticle ( string title ) : XmlElement
title string
리턴 System.Xml.XmlElement
예제 #1
0
        public IResponse HandleRequest(IRequest req)
        {
            var article  = HtmlTools.CreateHtmlArticle("Index");
            var document = article.OwnerDocument;

            var list   = document.EL("ul");
            var mounts = owner.MediaMounts.OrderBy(m =>
            {
                return(m.Value);
            }, NaturalStringComparer.CurrentCultureIgnoreCase);

            foreach (var m in mounts)
            {
                var li = document.EL("li");
                li.AppendChild(document.EL(
                                   "a",
                                   new AttributeCollection()
                {
                    { "href", m.Key }
                },
                                   m.Value
                                   ));
                list.AppendChild(li);
            }

            article.AppendChild(list);

            return(new StringResponse(HttpCode.Ok, document.OuterXml));
        }
예제 #2
0
        public IResponse HandleRequest(IRequest req)
        {
            var article  = HtmlTools.CreateHtmlArticle("Index");
            var document = article.OwnerDocument;

            if (document == null)
            {
                throw new HttpStatusException(HttpCode.InternalError);
            }

            var list   = document.EL("ul");
            var mounts = owner.MediaMounts.OrderBy(m => m.Value, NaturalStringComparer.Comparer);

            foreach (var m in mounts)
            {
                var li = document.EL("li");
                li.AppendChild(document.EL(
                                   "a",
                                   new AttributeCollection {
                    { "href", m.Key }
                },
                                   m.Value));
                list.AppendChild(li);
            }

            article.AppendChild(list);

            return(new StringResponse(HttpCode.Ok, document.OuterXml));
        }
예제 #3
0
        private IResponse ProcessHtmlRequest(IMediaItem aItem)
        {
            var item = aItem as IMediaFolder;

            if (item == null)
            {
                throw new HttpStatusException(HttpCode.NotFound);
            }

            var article = HtmlTools.CreateHtmlArticle(
                string.Format("Folder: {0}", item.Title));
            var document = article.OwnerDocument;

            XmlNode e;
            var     folders = document.EL(
                "ul",
                new AttributeCollection()
            {
                { "class", "folders" }
            }
                );

            if (item.Parent != null)
            {
                folders.AppendChild(e = document.EL("li"));
                e.AppendChild(document.EL(
                                  "a",
                                  new AttributeCollection()
                {
                    { "href", String.Format("{0}index/{1}", prefix, item.Parent.Id) },
                    { "class", "parent" }
                },
                                  "Parent"
                                  ));
            }
            foreach (var i in item.ChildFolders)
            {
                folders.AppendChild(e = document.EL("li"));
                e.AppendChild(document.EL(
                                  "a",
                                  new AttributeCollection()
                {
                    { "href", String.Format("{0}index/{1}", prefix, i.Id) }
                },
                                  string.Format("{0} ({1})", i.Title, i.ChildCount)
                                  ));
            }
            article.AppendChild(folders);

            var items = (XmlNode)null;

            article.AppendChild(items = document.EL(
                                    "ul", new AttributeCollection()
            {
                { "class", "items" }
            }));
            foreach (var i in item.ChildItems)
            {
                items.AppendChild(e = document.EL("li"));
                var link = document.EL(
                    "a",
                    new AttributeCollection()
                {
                    { "href", string.Format(
                          "{0}file/{1}/{2}.{3}", prefix, i.Id, i.Title,
                          DlnaMaps.Dlna2Ext[i.Type][0]) }
                }
                    );
                var details = document.EL("section");
                link.AppendChild(details);
                e.AppendChild(link);

                details.AppendChild(document.EL(
                                        "h3", new AttributeCollection {
                    { "title", i.Title }
                }, i.Title));

                var props = i.Properties;
                if (props.ContainsKey("HasCover"))
                {
                    details.AppendChild(document.EL(
                                            "img",
                                            new AttributeCollection {
                        { "title", "Cover image" },
                        { "alt", "Cover image" },
                        { "src", String.Format(
                              "{0}cover/{1}/{2}.{3}", prefix, i.Id, i.Title,
                              DlnaMaps.Dlna2Ext[i.Type][0]) }
                    }));
                }

                var table = document.EL("table");
                foreach (var p in htmlItemProperties)
                {
                    string v;
                    if (props.TryGetValue(p, out v))
                    {
                        table.AppendChild(e = document.EL("tr"));
                        e.AppendChild(document.EL("th", text: p));
                        e.AppendChild(document.EL("td", text: v));
                    }
                }
                if (table.ChildNodes.Count != 0)
                {
                    details.AppendChild(table);
                }

                string description;
                if (props.TryGetValue("Description", out description))
                {
                    link.AppendChild(document.EL(
                                         "p", new AttributeCollection()
                    {
                        { "class", "desc" }
                    },
                                         description));
                }
            }

            return(new StringResponse(HttpCode.Ok, document.OuterXml));
        }