コード例 #1
0
        public string FullMediaUrl(string s)
        {
            XElement content = XElement.Parse(s);

            foreach (XElement img in content.Descendants(content.Name.Namespace + "img"))
            {
                try
                {
                    XAttribute src = img.Attribute("src");
                    if (src != null)
                    {
                        Match match = Regex.Match(src.Value, @"Renderers/ShowMedia\.ashx.*");
                        if (match.Success)
                        {
                            img.SetAttributeValue("src",
                                                  BlogFacade.GetFullPath(UrlUtils.PublicRootPath + "/" + match.Value));
                        }
                    }
                }
                catch
                {
                }
            }
            return(content.ToString());
        }
コード例 #2
0
        private string GetFullBlogPageUrl(Guid blogPageId)
        {
            var pageUrl = string.Empty;

            if (blogPageId != Guid.Empty)
            {
                pageUrl = BlogFacade.GetPageUrlById(blogPageId);
                if (!string.IsNullOrEmpty(pageUrl))
                {
                    pageUrl = BlogFacade.GetFullPath(pageUrl);
                }
            }
            return(pageUrl);
        }
コード例 #3
0
        private BlogListItemModel CreateBlogItemModel(Entries entry, string blogPageUrl)
        {
            using (var con = new DataConnection())
            {
                var image = con.Get <IMediaFile>().FirstOrDefault(m => m.KeyPath == entry.Image);
                var model = new BlogListItemModel
                {
                    Title      = entry.Title,
                    Url        = BlogFacade.GetBlogUrl(entry, blogPageUrl),
                    Tags       = entry.Tags,
                    TagsByType = BlogFacade.GetTagsByType(entry.Tags),
                    ImageUrl   = image != null?BlogFacade.GetFullPath(MediaUrls.BuildUrl(image)) : string.Empty
                };

                return(model);
            }
        }