Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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());
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public static string GetThumbnailImage(Media media)
        {
            string link = string.Empty;

            if (media != null)
            {
                IUserUrlService userUrlService = GetUserUrlService();

                MediaFile    thumbnail  = media.GetImageByPhotoType(PhotoType.Thumbnail);
                const string linkFormat = "<img src=\"{0}\" alt=\"{1}\" /></a>";
                link = string.Format(linkFormat, userUrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath), media.Description);
            }

            return(link);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="friend">The friend.</param>
        /// <returns></returns>
        public static string GetFriendImageThumbnailForUserHomepage(Friend friend)
        {
            string val = string.Empty;

            if (friend.Media != null)
            {
                IUserUrlService userUrlService = GetUserUrlService();

                MediaFile    thumbnail  = friend.Media.GetImageByPhotoType(PhotoType.Thumbnail);
                const string linkFormat = "<li><span><a class=\"showimage\" href=\"{0}\" title=\"{1}\"><img src=\"{2}\" alt=\"{3}\" /></a></span><span class=\"albumtitle\">{4}<span></li>";
                val = string.Format(linkFormat,
                                    userUrlService.UserRoot(friend.Username),
                                    friend.DisplayName,
                                    userUrlService.CreateImageUrl(friend.Media.Owner.Username, thumbnail.FilePath),
                                    friend.Media.Description,
                                    friend.DisplayName);
            }
            return(val);
        }
Esempio n. 5
0
        /// <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);
        }