/// <summary> /// Gets the image link. /// </summary> /// <param name="upload">The upload.</param> /// <returns></returns> public static string RenderRecentUploadHtml(RecentUploads upload) { string val = string.Empty; if (upload != null) { MediaFile thumbnail = upload.GetImageByPhotoType(PhotoType.Thumbnail); MediaFile webSize = upload.GetImageByPhotoType(PhotoType.Websize); const string linkFormat = @"<tr> <td><span class=""imagecontainer"" ><a rel=""{0}"" href=""{7}"" class=""showimage lightbox"" title=""{1}""><img src=""{2}"" alt=""{3}"" /></a></span></td> <td> <ul class=""albummetadata"" > <li><label class=""albumtitle"" ><span>{4}</span></label></li> <li><abbr class=""timeago"" title=""{5}"">{6}</abbr></li> </ul> </td> </tr>"; val = string.Format(linkFormat, _urlService.CreateImageUrl(upload.Owner.Username, webSize.FilePath), upload.Title, _urlService.UserUrl(upload.Owner.Username, "services/grayscale/" + thumbnail.MediaId), upload.Title, upload.Title, upload.CreateDate.ToString("o"), upload.CreateDate.ToLongDateString(), _urlService.UserUrl(upload.Owner.Username, "photos/show/#/photo/" + upload.MediaId)); } return(val); }
/// <summary> /// Gets the image link. /// </summary> /// <param name="album">The album.</param> /// <returns></returns> public static string GetAlbumImageThumbnailForUserHomepage(Album album) { string val = string.Empty; if (album.Media != null) { MediaFile thumbnail = album.Media[0].GetImageByPhotoType(PhotoType.Thumbnail); const string linkFormat = @"<tr> <td><span class=""imagecontainer"" ><a class=""showimage"" href=""{0}"" title=""{1}""><img src=""{2}"" alt=""{3}"" /></a></span></td> <td> <ul class=""albummetadata"" > <li><label class=""albumtitle"" ><span>{4}</span></label></li> <li><label>photos </label><span>{5}</span></li> <li><label>sub albums </label><span>{6}</span></li> </ul> </td> </tr>"; val = string.Format(linkFormat, _urlService.UserUrl(album.Media[0].Owner.Username, string.Format("albums/#/show/{0}", album.AlbumId)), album.Name, _urlService.UserUrl(album.Media[0].Owner.Username, "services/grayscale/" + thumbnail.MediaId), album.Media[0].Title, album.Name, album.PhotoCount, album.ChildAlbumCount); } return(val); }
/// <summary> /// Renders the specified media. /// </summary> /// <param name="media">The media.</param> /// <param name="user">The user.</param> /// <param name="set">The set.</param> /// <returns></returns> public static string Render(IList <Media> media, User user, string set) { IUserUrlService urlService = UserUrlService.GetInstance(user); StringBuilder builder = new StringBuilder(); const string thumbFormat = @" <div class=""thumbnails"" {3}> <span > <a href=""{9}"" rel=""{0}"" name=""{4}"" class=""showimage lightbox"" title=""{2}"" ><img src=""{1}"" alt=""{2}"" /></a> </span> <ul class=""largethumbnailmetadata"" > <li class=""title"" >{5}</li> <li>{6}</li> <li class=""comment hyperlinks"" ><a href=""{8}/comments/leave/{4}"">comments ({7})</a></li> </ul> </div>"; if (media == null) { throw new System.ArgumentNullException("media", "Parameter 'media' is null, value expected"); } if (media.Count > 0) { string imagePath = PhotoHtmlHelper.GetImageDetailLinkForFirst(media[0], "homepagefullsize", set, PhotoType.Websize); builder.AppendLine(string.Format("<div class=\"firstimage\" >{0} <div > <h3 class=\"firstphototitle\" >{1}</h3> <p>{2}</p></div> <br class=\"clearboth\" /> </div>", imagePath, media[0].Title, media[0].Description)); if (media.Count > 15) { builder.AppendLine("<div class=\"largethumbs\" >"); for (int index = 1; index < media.Count && index < 16; index++) { string showUrl = urlService.UserUrl("photos/show/" + set + "/#/photo/" + media[index].MediaId); MediaFile webSize = media[index].GetImageByPhotoType(PhotoType.Websize); string websizeUrl = urlService.CreateImageUrl(webSize.FilePath); builder.AppendLine(string.Format(thumbFormat, websizeUrl, websizeUrl, media[index].Title, (index % 3 == 0 ? "style=\"margin-right:0px;\"" : string.Empty), media[index].MediaId, TruncateText(media[index].Title, 20), TruncateText(media[index].Description, 35), media[index].CommentCount, urlService.UserRoot(), showUrl)); } builder.AppendLine("<div class=\"clearboth\" ></div>"); builder.AppendLine("</div>"); } } return(builder.ToString()); }
/// <summary> /// Sets the bread crumb. /// </summary> /// <param name="currentView">The current view.</param> /// <param name="text">The text.</param> private List <BreadCrumb> SetBreadCrumb(string currentView, string text) { List <BreadCrumb> crumbs = new List <BreadCrumb> { new BreadCrumb { Href = urlService.UserRoot(), Text = "home" }, new BreadCrumb { Text = "photos" }, new BreadCrumb { Href = urlService.UserUrl("photos/" + currentView), Text = text } }; return(crumbs); }
/// <summary> /// Gets the image link. /// </summary> /// <param name="set">The set.</param> /// <param name="media">The media.</param> /// <returns></returns> public static string GetImageLink(string set, Media media) { MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail); MediaFile websize = media.GetImageByPhotoType(PhotoType.Websize); IUserUrlService userUrlService = GetUserUrlService(); const string linkFormat = "<a id=\"{4}\" class=\"showimage lightbox\" name=\"{3}\" rel=\"{2}\" href=\"{5}\" title=\"{1}\"><img src=\"{0}\" alt=\"{1}\" /></a>"; string link = string.Format(linkFormat, userUrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, thumbnail.FilePath), media.Title, userUrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, websize.FilePath), media.MediaId, media.Owner.Username, userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId)); return(link); }
/// <summary> /// Gets the image link. /// </summary> /// <param name="media">The media.</param> /// <param name="cssClass">The CSS class.</param> /// <param name="set">The set.</param> /// <param name="type">The type.</param> /// <returns></returns> public static string GetImageDetailLinkForFirst(Media media, string cssClass, string set, PhotoType type) { IUserUrlService userUrlService = GetUserUrlService(); Func <string, string> title = s => (string.IsNullOrEmpty(media.Title) ? string.Empty : string.Format("title=\"{0} - {1} {2}\"", media.Title, media.Owner.FirstName, media.Owner.LastName)); MediaFile thumbnail = media.GetImageByPhotoType(type); const string linkFormat = "<a class=\"{5} lightbox\" name=\"{6}\" href=\"{0}\" {1} ><img src=\"{2}\" alt=\"{3}\" {4} /></a>"; string link = string.Format(linkFormat, userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId), title(media.Title), userUrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath), media.Title, title(media.Title), cssClass, media.MediaId); return(link); }
/// <summary> /// Gets the photo detail links. /// </summary> /// <param name="media">The media.</param> /// <param name="isAuthenticated">if set to <c>true</c> [is authenticated].</param> /// <returns></returns> public static string GetPhotoDetailLinks(Media media, bool isAuthenticated) { IUserUrlService userUrlService = GetUserUrlService(); ITagService tagService = DependencyInjection.Resolve <ITagService>(); const string perminateLinkFormat = @"<li><a href=""{0}"" title=""{1}"" >permalink</a></li>"; string perminateLink = string.Format(perminateLinkFormat, userUrlService.UserUrl(media.Owner.Username, "photos/show/" + media.MediaId), media.Title); string html = @"<ul> <li> <span>"; html += (isAuthenticated ? @"<a id=""editlink"" href=""{0}/photos/edit/{1}"">edit</a>" : string.Empty); html += @"</span> </li>"; html += "{2}"; html += @" </li> {3} {5} <li><span><a href=""{0}/comments/leave/{1}"">comments ({4})</a></span> </ul>"; string tags = string.Empty; if (!string.IsNullOrEmpty(media.Tags)) { const string tagFormat = @"<li><span>tags:</span> {0}</li>"; string renderedTags = tagService.HyperlinkTheTags(media.Tags, media.Owner.Username); tags = string.Format(tagFormat, renderedTags); } string date = GetDate(media); string content = string.Format(html, userUrlService.UserRoot(media.Owner.Username), HttpUtility.HtmlEncode(media.MediaId.ToString()), date, tags, media.CommentCount, perminateLink); return(content); }