/// <summary> /// Create a list of links from a Snippet's tags. Tag string should /// be comma delimited. /// </summary> /// <param name="urlHelper"></param> /// <param name="tags"></param> /// <returns></returns> public string GetTagLinkList(string tags) { if (tags == null) { tags = Entity.Tags; } if (string.IsNullOrEmpty(tags)) { return(string.Empty); } string[] tagStrings = tags.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder html = new StringBuilder(); foreach (string tagString in tagStrings) { string urlAction = WebUtils.ResolveUrl("~/list/tag/") + StringUtils.UrlEncode(tagString.Trim()); html.Append(HtmlUtils.Href(HttpUtility.HtmlEncode(tagString.Trim()), urlAction) + ", "); } if (html.Length > 2) { html.Length -= 2; } return(html.ToString()); }
/// <summary> /// Create a list of links from a Snippet's tags. Tag string should /// be comma delimited. /// </summary> /// <param name="urlHelper"></param> /// <param name="tags"></param> /// <returns></returns> public static string GetTagLinkList(this UrlHelper urlHelper, string tags) { if (string.IsNullOrEmpty(tags)) { return(string.Empty); } string[] tagStrings = tags.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder html = new StringBuilder(); foreach (string tagString in tagStrings) { string urlAction = urlHelper.Content("~/list/tag/") + tagString.Trim(); //string urlAction = urlHelper.Action("List", "Snippet", // new { // listAction = "tag", // listFilter = tagString.Trim() // }); html.Append(HtmlUtils.Href(tagString.Trim(), urlAction) + ", "); } if (html.Length > 2) { html.Length -= 2; } return(html.ToString()); }
/// <summary> /// Returns an author either as a name /// </summary> /// <returns></returns> public string GetAuthorLink() { if (UserId == string.Empty) { return(HtmlUtils.HtmlEncode(Author)); } return(HtmlUtils.Href(HtmlUtils.HtmlEncode(Author), WebUtils.ResolveUrl("~/list/user/") + UserId)); }