public void GetAbsoluteUrlReturnsUrlForComment()
        {
            Site site = new Site()
            {
                Host = new Uri("http://test.com/foo")
            };
            RouteCollection routes = new RouteCollection();

            routes.Add("PostCommentPermalink", new Route("{areaName}/{slug}#{comment}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(site, routes);

            string url = helper.GetAbsolutePath(new Post()
            {
                Area = new Area()
                {
                    Name = "area"
                }, Slug = "test"
            }, new Comment()
            {
                Created = new DateTime(2009, 1, 1, 1, 24, 1, 100)
            }).Replace("%23", "#");

            Assert.Equal("http://test.com/foo/area/test#c-200901010124011", url);
        }
Пример #2
0
        private IEnumerable <MessageOutbound> generateMessages(IPluginContext pluginContext, Post post, Comment comment)
        {
            ILocalizationService           localizationService = pluginContext.Container.Resolve <ILocalizationService>();
            IPostService                   postService         = pluginContext.Container.Resolve <IPostService>();
            IEnumerable <PostSubscription> subscriptions       = postService.GetSubscriptions(post);
            List <MessageOutbound>         messages            = new List <MessageOutbound>();
            Site site = pluginContext.Container.Resolve <Site>();
            AbsolutePathHelper absolutePathHelper = pluginContext.Container.Resolve <AbsolutePathHelper>();
            int retryCount = int.Parse(pluginContext.Plugin.Settings["RetryCount"]);

            foreach (PostSubscription subscription in subscriptions)
            {
                MessageOutbound message = new MessageOutbound
                {
                    ID                  = Guid.NewGuid(),
                    To                  = string.Format("{0} <{1}>", subscription.User.DisplayName, subscription.User.Email),
                    Subject             = string.Format(getPhrase(localizationService, "Messages.Formats.ReplySubject", site.LanguageDefault, "RE: {0}"), post.Title),
                    Body                = generateMessageBody(post, comment, site, localizationService, absolutePathHelper),
                    RemainingRetryCount = retryCount
                };

                messages.Add(message);
            }

            return(messages);
        }
Пример #3
0
 public AkismetSpamFilterService(AppSettingsHelper settings, Site site, AbsolutePathHelper pathHelper)
 {
     this.settings   = settings;
     this.site       = site;
     this.pathHelper = pathHelper;
     BuildParameters();
 }
Пример #4
0
        public void PingCreatesNewTrackbackForNotFoundTrackback()
        {
            FakePostService postService = new FakePostService();

            postService.AddedPosts.Add(new Oxite.Model.Post()
            {
                Slug = "test", Trackbacks = new List <Trackback>()
            });

            RouteCollection routes = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(new Site()
            {
                Host = new Uri("http://foo.com")
            }, routes);

            PingbackService service = new PingbackService(postService, helper);

            string result = service.Ping("http://test.com/foo", "http://foo.com/test/area");

            Assert.NotNull(result);
            Assert.NotNull(postService.AddedTrackback);
            Assert.Equal("http://test.com/foo", postService.AddedTrackback.Url);
        }
Пример #5
0
        public void PingReturnsSuccessIfTrackbackFound()
        {
            FakePostService postService = new FakePostService();

            postService.AddedPosts.Add(new Oxite.Models.Post()
            {
                Slug = "test", Trackbacks = new List <Trackback>(new[] { new Trackback()
                                                                         {
                                                                             Url = "http://test.com/foo"
                                                                         } })
            });

            RouteCollection routes = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(new Site()
            {
                Host = new Uri("http://foo.com")
            }, routes);

            PingbackService service = new PingbackService(postService, helper);

            string result = service.Ping("http://test.com/foo", "http://foo.com/test/area");

            Assert.Null(postService.AddedTrackback);
        }
Пример #6
0
 public BlogController(IBlogService blogService, IPostService postService, IBlogsCommentService commentService, ILanguageService languageService, AbsolutePathHelper absolutePathHelper)
 {
     this.blogService        = blogService;
     this.postService        = postService;
     this.commentService     = commentService;
     this.languageService    = languageService;
     this.absolutePathHelper = absolutePathHelper;
 }
Пример #7
0
 public PostService(IPostRepository repository, ILocalizationRepository localizationRepository, Site site, IValidationService validator, AbsolutePathHelper absolutePathHelper)
 {
     this.repository             = repository;
     this.localizationRepository = localizationRepository;
     this.site               = site;
     this.validator          = validator;
     this.absolutePathHelper = absolutePathHelper;
 }
        public void GetAbsoluteUrlForPostFaultsForNullAreaName()
        {
            AbsolutePathHelper helper = new AbsolutePathHelper(null, null);

            Assert.Throws <ArgumentException>(() => helper.GetAbsolutePath(new Post()
            {
                Slug = "test", Area = new Area()
            }));
        }
Пример #9
0
 public AreaController(Site site, IAreaService areaService, IPostService postService, ILanguageService languageService, ISiteService siteService, AbsolutePathHelper absolutePathHelper)
 {
     this.site               = site;
     this.areaService        = areaService;
     this.postService        = postService;
     this.languageService    = languageService;
     this.siteService        = siteService;
     this.absolutePathHelper = absolutePathHelper;
 }
Пример #10
0
 public PostService(IPostRepository repository, ILocalizationRepository localizationRepository, ITrackbackOutboundRepository trackbackOutboundRepository, IMessageOutboundRepository messageOutboundRepository, AbsolutePathHelper absolutePathHelper, Site site, IValidationService validator)
 {
     this.repository                  = repository;
     this.localizationRepository      = localizationRepository;
     this.trackbackOutboundRepository = trackbackOutboundRepository;
     this.messageOutboundRepository   = messageOutboundRepository;
     this.absolutePathHelper          = absolutePathHelper;
     this.site      = site;
     this.validator = validator;
 }
Пример #11
0
 public PostService(IPostRepository repository, ITrackbackOutboundRepository trackbackOutboundRepository, AbsolutePathHelper absolutePathHelper, IRegularExpressions expressions, IValidationService validator, IPluginEngine pluginEngine, ITagService tagService, ICommentService commentService, IModulesLoaded modules, OxiteContext context)
 {
     this.repository = repository;
     this.trackbackOutboundRepository = trackbackOutboundRepository;
     this.absolutePathHelper          = absolutePathHelper;
     this.expressions    = expressions;
     this.validator      = validator;
     this.pluginEngine   = pluginEngine;
     this.tagService     = tagService;
     this.commentService = commentService;
     this.cache          = modules.GetModules <IOxiteCacheModule>().Reverse().First();
     this.context        = context;
 }
 public ConferencesCommentService(IConferencesCommentRepository conferencesCommentRepository, ICommentRepository commentRepository, IScheduleItemRepository scheduleItemRepository, IMessageOutboundRepository messageOutboundRepository, ILanguageRepository languageRepository, ILocalizationRepository localizationRepository, AbsolutePathHelper absolutePathHelper, IValidationService validator, IPluginEngine pluginEngine, IModulesLoaded modules, OxiteContext context)
 {
     this.conferencesCommentRepository = conferencesCommentRepository;
     this.commentRepository            = commentRepository;
     this.scheduleItemRepository       = scheduleItemRepository;
     this.messageOutboundRepository    = messageOutboundRepository;
     this.languageRepository           = languageRepository;
     this.localizationRepository       = localizationRepository;
     this.absolutePathHelper           = absolutePathHelper;
     this.validator    = validator;
     this.pluginEngine = pluginEngine;
     this.cache        = modules.GetModules <IOxiteCacheModule>().Reverse().First();
     this.context      = context;
 }
Пример #13
0
        public void PingFaultsForNotFoundPost()
        {
            FakePostService postService = new FakePostService();
            RouteCollection routes      = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(new Site()
            {
                Host = new Uri("http://foo.com")
            }, routes);

            PingbackService service = new PingbackService(postService, helper);

            Assert.Throws <ArgumentException>(() => service.Ping("http://test.com/foo", "http://foo.com/test/area"));
        }
        public void GetPostReturnsNullOnNonPostUrl()
        {
            Site site = new Site()
            {
                Host = new Uri("http://test.com/foo")
            };
            RouteCollection routes = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(site, routes);

            PostAddress postAddress = helper.GetPostAddressFromUri(new Uri("http://test.com/foo/postSlug"));

            Assert.Null(postAddress);
        }
        public void GetPostReturnsPostWithSlugAndAreaWithName()
        {
            Site site = new Site()
            {
                Host = new Uri("http://test.com")
            };
            RouteCollection routes = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(site, routes);

            PostAddress postAddress = helper.GetPostAddressFromUri(new Uri("http://test.com/postSlug/area"));

            Assert.NotNull(postAddress);
            Assert.Equal("postSlug", postAddress.Slug);
            Assert.Equal("area", postAddress.AreaName);
        }
        public void GetAbsoluteUrlReturnsUrlForPost()
        {
            Site site = new Site()
            {
                Host = new Uri("http://test.com/foo")
            };
            RouteCollection routes = new RouteCollection();

            routes.Add("Post", new Route("{slug}/{areaName}", null));

            AbsolutePathHelper helper = new AbsolutePathHelper(site, routes);

            string url = helper.GetAbsolutePath(new Post()
            {
                Slug = "test", Area = new Area()
                {
                    Name = "area"
                }
            });

            Assert.Equal("http://test.com/foo/test/area", url);
        }
Пример #17
0
 public PingbackService(IPostService postService, AbsolutePathHelper pathHelper)
 {
     this.postService = postService;
     this.pathHelper  = pathHelper;
 }
Пример #18
0
        private string generateMessageBody(Post post, Comment comment, Site site, ILocalizationService localizationService, AbsolutePathHelper absolutePathHelper)
        {
            string body = getPhrase(localizationService, "Messages.NewComment", site.LanguageDefault, getDefaultBody());
            //TODO: (erikpo) Change this to come from the user this message is going to if applicable
            double timeZoneOffset = site.TimeZoneOffset;

            body = body.Replace("{Site.Name}", site.DisplayName);
            body = body.Replace("{User.Name}", comment.Creator.DisplayName);
            body = body.Replace("{Post.Title}", post.Title);
            //TODO: (erikpo) Change the published date to be relative (e.g. 5 minutes ago)
            body = body.Replace("{Comment.Created}", comment.Created.Value.AddHours(timeZoneOffset).ToLongTimeString());
            body = body.Replace("{Comment.Body}", comment.Body);
            body = body.Replace("{Comment.Permalink}", absolutePathHelper.GetAbsolutePath(post, comment).Replace("%23", "#"));

            return(body);
        }
        public void GetAbsoluteUrlForPostFaultsForNullPost()
        {
            AbsolutePathHelper helper = new AbsolutePathHelper(null, null);

            Assert.Throws <ArgumentNullException>(() => helper.GetAbsolutePath((Post)null));
        }
        public void GetAbsoluteUrlForPostFaultsForNoSlug()
        {
            AbsolutePathHelper helper = new AbsolutePathHelper(null, null);

            Assert.Throws <ArgumentException>(() => helper.GetAbsolutePath(new Post()));
        }
        public void GetPostFromUriFaultsOnNullUri()
        {
            AbsolutePathHelper helper = new AbsolutePathHelper(null, null);

            Assert.Throws <ArgumentNullException>(() => helper.GetPostAddressFromUri(null));
        }