Beispiel #1
0
        private static Entry CreateWelcomeBlogPost(ISubtextContext context, Blog blog, IEntryPublisher entryPublisher, AdminUrlHelper adminUrlHelper, IEntryIdentity article)
        {
            string body       = ScriptHelper.UnpackEmbeddedScriptAsString("WelcomePost.htm");
            string articleUrl = context.UrlHelper.EntryUrl(article);

            body = String.Format(body, articleUrl, adminUrlHelper.Home(), context.UrlHelper.HostAdminUrl("default.aspx"));

            var entry = new Entry(PostType.BlogPost)
            {
                Title                    = "Welcome to Subtext!",
                EntryName                = "welcome-to-subtext",
                BlogId                   = blog.Id,
                Author                   = blog.Author,
                Body                     = body,
                DateCreated              = DateTime.Now,
                DateModified             = DateTime.Now,
                DateSyndicated           = DateTime.Now,
                IsActive                 = true,
                IncludeInMainSyndication = true,
                DisplayOnHomePage        = true,
                AllowComments            = true
            };

            entryPublisher.Publish(entry);
            return(entry);
        }
Beispiel #2
0
        private static Entry CreateWelcomeArticle(Blog blog, IEntryPublisher entryPublisher, AdminUrlHelper adminUrlHelper)
        {
            string body = ScriptHelper.UnpackEmbeddedScriptAsString("WelcomeArticle.htm");

            body = String.Format(body, adminUrlHelper.ArticlesList());

            var article = new Entry(PostType.Story)
            {
                EntryName    = "welcome-to-subtext-article",
                Title        = "Welcome to Subtext!",
                BlogId       = blog.Id,
                Author       = blog.Author,
                Body         = body,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now,
                IsActive     = true,
            };

            entryPublisher.Publish(article);
            return(article);
        }
Beispiel #3
0
        public static int Create(Entry entry)
        {
            var requestContext      = new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData());
            var serviceLocator      = new Mock <IDependencyResolver>().Object;
            var searchEngineService = new Mock <IIndexingService>().Object;

            DependencyResolver.SetResolver(serviceLocator);
            var routes        = new RouteCollection();
            var subtextRoutes = new SubtextRouteMapper(routes, serviceLocator);

            Routes.RegisterRoutes(subtextRoutes);
            var urlHelper      = new BlogUrlHelper(requestContext, routes);
            var subtextContext = new SubtextContext(Config.CurrentBlog, requestContext, urlHelper,
                                                    new DatabaseObjectProvider(), requestContext.HttpContext.User,
                                                    new SubtextCache(requestContext.HttpContext.Cache), serviceLocator);
            IEntryPublisher entryPublisher = CreateEntryPublisher(subtextContext, searchEngineService);
            int             id             = entryPublisher.Publish(entry);

            entry.Id = id;
            return(id);
        }
        private static Entry CreateWelcomeBlogPost(ISubtextContext context, Blog blog, IEntryPublisher entryPublisher, AdminUrlHelper adminUrlHelper, IEntryIdentity article)
        {
            string body = ScriptHelper.UnpackEmbeddedScriptAsString("WelcomePost.htm");
            string articleUrl = context.UrlHelper.EntryUrl(article);
            body = String.Format(body, articleUrl, adminUrlHelper.Home(), context.UrlHelper.HostAdminUrl("default.aspx"));

            var entry = new Entry(PostType.BlogPost)
            {
                Title = "Welcome to Subtext!",
                EntryName = "welcome-to-subtext",
                BlogId = blog.Id,
                Author = blog.Author,
                Body = body,
                DateCreated = DateTime.Now,
                DateModified = DateTime.Now,
                DateSyndicated = DateTime.Now,
                IsActive = true,
                IncludeInMainSyndication = true,
                DisplayOnHomePage = true,
                AllowComments = true
            };

            entryPublisher.Publish(entry);
            return entry;
        }
        private static Entry CreateWelcomeArticle(Blog blog, IEntryPublisher entryPublisher, AdminUrlHelper adminUrlHelper)
        {
            string body = ScriptHelper.UnpackEmbeddedScriptAsString("WelcomeArticle.htm");
            body = String.Format(body, adminUrlHelper.ArticlesList());

            var article = new Entry(PostType.Story)
            {
                EntryName = "welcome-to-subtext-article",
                Title = "Welcome to Subtext!",
                BlogId = blog.Id,
                Author = blog.Author,
                Body = body,
                DateCreated = DateTime.Now,
                DateModified = DateTime.Now,
                IsActive = true,
            };

            entryPublisher.Publish(article);
            return article;
        }