Ejemplo n.º 1
0
        public void BlogIt(Photo photo, PostDetails genericPostDetails)
        {
            if (photo == null) throw new ArgumentNullException("photo");
            if (genericPostDetails == null) throw new ArgumentNullException("genericPostDetails");

            BloggerAtomId bloggerAtomId = ExtractBlogAtomId(Settings.BlogName);

            CreateNewPost(bloggerAtomId, photo, genericPostDetails);
        }
Ejemplo n.º 2
0
        private static string GenerateContent(Photo photo, User user)
        {
            string photoHref = String.Format("{0}{1}", user.PhotosUrl, photo.Id);
            string photoTitle = String.Format("{0} by {1}, on Flickr", photo.Title, user.Username);
            string photoSrc = photo.SourceUrl;
            string photoCaption = String.Format(
                "{0}, {1}s, f/{2}, ISO-{3}, {4} @ {5}",
                photo.Exif.Model,
                photo.Exif.Exposure,
                photo.Exif.Aperture,
                photo.Exif.IsoSpeed,
                photo.Exif.LensDetails,
                photo.Exif.FocalLength);

            const string content = @"<table cellpadding=""0"" cellspacing=""0"" class=""tr-caption-container"" style=""margin-left: auto; margin-right: auto; text-align: center;""><tbody><tr><td style=""text-align: center;""><a href=""{0}"" style=""clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"" title=""{1}""><img alt=""{2}"" height=""{3}"" src=""{4}"" width=""{5}"" /></a></td></tr><tr><td class=""tr-caption"" style=""text-align: center;"">{6}</td></tr></tbody></table><br/>{7}";

            return String.Format(content, photoHref, photoTitle, photo.Title, photo.PhotoHeight("Medium 640"), photoSrc, photo.PhotoWidth("Medium 640"), photoCaption, photo.PhotoDescriptionInHtml());
        }
Ejemplo n.º 3
0
 private static string GeneratePostTitle(Photo photo, PostDetails genericPostDetails)
 {
     return String.Format("{0}: {1}", !String.IsNullOrEmpty(photo.PostDetails.TitlePrefix) ? photo.PostDetails.TitlePrefix : genericPostDetails.TitlePrefix, photo.Title);
 }
Ejemplo n.º 4
0
 private static DateTime CalculatePublishedDateTime(Photo photo, PostDetails genericPostDetails)
 {
     return genericPostDetails.UsePostDate ? photo.Exif.CreatedDateTime : genericPostDetails.PostDate;
 }
Ejemplo n.º 5
0
        private void CreateNewPost(BloggerAtomId bloggerAtomId, Photo photo, PostDetails genericPostDetails)
        {
            AtomEntry newPost = new AtomEntry
            {
                Title = { Text = GeneratePostTitle(photo, genericPostDetails) },
                Content = new AtomContent
                {
                    Content = GenerateContent(photo, User),
                    Type = "html"
                },
                Published = CalculatePublishedDateTime(photo, genericPostDetails)
            };

            AddPostLabels(newPost, genericPostDetails);

            Uri blogFeedUri = new Uri("http://www.blogger.com/feeds/" + bloggerAtomId.BlogId + "/posts/default");
            AtomEntry createdEntry = BloggerService.Insert(blogFeedUri, newPost);
        }