コード例 #1
0
 public static string UrlFriendly(this IUrlHelper urlHelper, string text)
 {
     return(UrlUtils.UrlFriendly(text));
 }
コード例 #2
0
        public static IHtmlContent FormatRaw(this IHtmlHelper htmlHelper, PageView pageView, string html)
        {
            // Nothing to do if page does not have a preview image
            if (!pageView.PreviewImageBlobId.HasValue)
            {
                return(new HtmlString(html));
            }

            // Nothing to do if HTML does not contain the jumbotron outer class
            if (html == null || !html.Contains("class=\"jumbotron-outer\""))
            {
                return(new HtmlString(html));
            }

            // Update HTML so page preview image is background of div with jumbotron outer class
            IUrlHelper urlHelper       = new UrlHelper(htmlHelper.ViewContext);
            string     previewImageUrl = urlHelper.RouteUrl(RouteNames.PageImage, new { pageid = pageView.PageId, pageImageType = "preview", description = UrlUtils.UrlFriendly(pageView.Title), t = pageView.PreviewImageBlobId.Value });
            string     replaceText     = string.Format("class=\"jumbotron-outer\" style=\"background-image: url({0});\"", previewImageUrl);

            html = html.Replace("class=\"jumbotron-outer\"", replaceText);
            return(new HtmlString(html));
        }