Beispiel #1
0
        /// <summary>
        /// Posts trackbacks and pingbacks for the specified entry.
        /// </summary>
        public static void Run(Entry entry, Blog blog, BlogUrlHelper urlHelper)
        {
            if (!blog.TrackbacksEnabled)
            {
                return;
            }

            if (!Config.Settings.Tracking.EnablePingBacks && !Config.Settings.Tracking.EnableTrackBacks)
            {
                return;
            }

            if (entry != null)
            {
                VirtualPath blogUrl = urlHelper.BlogUrl();
                Uri fullyQualifiedUrl = blogUrl.ToFullyQualifiedUrl(blog);

                var notify = new Notifier
                {
                    FullyQualifiedUrl = fullyQualifiedUrl.AbsoluteUri,
                    BlogName = blog.Title,
                    Title = entry.Title,
                    PostUrl = urlHelper.EntryUrl(entry).ToFullyQualifiedUrl(blog),
                    Description = entry.HasDescription ? entry.Description : entry.Title,
                    Text = entry.Body
                };

                //This could take a while, do it on another thread
                ThreadHelper.FireAndForget(notify.Notify, "Exception occured while attempting trackback notification");
            }
        }
Beispiel #2
0
        //Body of text to insert into a post with Trackback
        public static string TrackBackTag(Entry entry, Blog blog, BlogUrlHelper urlHelper)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            Uri entryUrl = urlHelper.EntryUrl(entry).ToFullyQualifiedUrl(blog);
            return String.Format(CultureInfo.InvariantCulture, Resources.TrackbackTag, entryUrl, entryUrl, entry.Title,
                                 urlHelper.BlogUrl(), entry.Id.ToString(CultureInfo.InvariantCulture));
        }
        public static void AddCommunityCredits(Entry entry, BlogUrlHelper urlHelper, Blog blog)
        {
            string result;

            bool commCreditsEnabled;

            if (!bool.TryParse(ConfigurationManager.AppSettings["CommCreditEnabled"], out commCreditsEnabled))
            {
                return;
            }

            if (commCreditsEnabled && entry.IsActive)
            {
                var wsCommunityCredit = new AffiliateServices();

                string url = urlHelper.EntryUrl(entry).ToFullyQualifiedUrl(blog).ToString();
                string category = String.Empty;
                if (entry.PostType == PostType.BlogPost)
                {
                    category = "Blog";
                }
                else if (entry.PostType == PostType.Story)
                {
                    category = "Article";
                }
                string description = "Blogged about: " + entry.Title;

                string firstName = string.Empty;
                string lastName = blog.Author;
                string email = blog.Email;
                string affiliateCode = ConfigurationManager.AppSettings["CommCreditAffiliateCode"];
                string affiliateKey = ConfigurationManager.AppSettings["CommCreditAffiliateKey"];

                Log.InfoFormat("Sending notification to community credit for url {0} in category {1} for user {2}", url,
                               category, email);

                result = wsCommunityCredit.AddCommunityCredit(email, firstName, lastName, description, url, category,
                                                              affiliateCode, affiliateKey);

                Log.InfoFormat("Response Received was: {0}", result);
                if (!result.Equals("Success"))
                {
                    throw new CommunityCreditNotificationException(result);
                }
            }
        }
Beispiel #4
0
        public void EntryUrl_WithNullEntry_ThrowsArgumentNullException()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            var requestContext = new RequestContext(httpContext.Object, new RouteData());
            var helper = new BlogUrlHelper(requestContext, new RouteCollection());

            //act, assert
            UnitTestHelper.AssertThrowsArgumentNullException(() => helper.EntryUrl(null));
        }
Beispiel #5
0
        public void EntryUrl_WithEntryHavingPostTypeOfNone_ThrowsArgumentException()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            var requestContext = new RequestContext(httpContext.Object, new RouteData());
            var helper = new BlogUrlHelper(requestContext, new RouteCollection());

            //act
            UnitTestHelper.AssertThrows<ArgumentException>(() => helper.EntryUrl(new Entry(PostType.None)));
        }
        private void GetPosts(XmlNode connectorNode, string currentFolder)
        {
            IPagedCollection<EntryStatsView> posts;
            if (currentFolder.Equals("/"))
            {
                posts = Repository.GetEntries(PostType.BlogPost, -1, 0, 1000);
            }
            else
            {
                string categoryName = currentFolder.Substring(1, currentFolder.Length - 2);
                LinkCategory category = Repository.GetLinkCategory(categoryName, false);
                posts = Repository.GetEntries(PostType.BlogPost, category.Id, 0, 1000);
            }

            // Create the "Files" node.
            XmlNode oFilesNode = XmlUtil.AppendElement(connectorNode, "Files");
            foreach (var entry in posts)
            {
                // Create the "File" node.
                if (entry.IsActive)
                {
                    XmlNode oFileNode = XmlUtil.AppendElement(oFilesNode, "File");

                    //TODO: Seriously refactor.
                    var urlHelper = new BlogUrlHelper(null, null);

                    XmlUtil.SetAttribute(oFileNode, "name",
                                         string.Format(CultureInfo.InvariantCulture, "{0}|{1}", entry.Title,
                                                       urlHelper.EntryUrl(entry).ToFullyQualifiedUrl(Config.CurrentBlog)));
                    XmlUtil.SetAttribute(oFileNode, "size", entry.DateModifiedUtc.ToShortDateString());
                }
            }
        }