public ActionResult Index()
        {
            var searchUrl = UrlHelper.SearchPageUrl().ToFullyQualifiedUrl(Blog);

            string manifestXml = string.Format(ManifestXml, Blog.Title, Blog.SubTitle, Blog.Email, searchUrl);

            return(Content(manifestXml, "application/opensearchdescription+xml"));
        }
예제 #2
0
        //Body of text to insert into a post with Trackback
        public static string TrackBackTag(Entry entry, Blog blog, UrlHelper 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));
        }
예제 #3
0
 public SubtextContext(Blog blog, RequestContext requestContext, UrlHelper urlHelper, ObjectProvider repository,
     IPrincipal user, ICache cache, IServiceLocator serviceLocator)
 {
     Blog = blog;
     RequestContext = requestContext;
     UrlHelper = urlHelper;
     Repository = repository;
     User = user ?? requestContext.HttpContext.User;
     Cache = cache ?? new SubtextCache(requestContext.HttpContext.Cache);
     ServiceLocator = serviceLocator;
 }
예제 #4
0
        public virtual void Write(IEnumerable<Blog> blogs, TextWriter writer, UrlHelper urlHelper)
        {
            var settings = new XmlWriterSettings
            {
                Encoding = Encoding.UTF8,
                OmitXmlDeclaration = true,
                ConformanceLevel = ConformanceLevel.Document,
                Indent = true,
                IndentChars = ("\t")
            };

            using(XmlWriter xmlWriter = XmlWriter.Create(writer, settings))
            {
                if(xmlWriter != null)
                {
                    xmlWriter.WriteStartDocument();

                    //OPML ROOT
                    xmlWriter.WriteStartElement("opml");
                    xmlWriter.WriteAttributeString("version", "1.0");
                    xmlWriter.WriteStartElement("head");
                    xmlWriter.WriteStartElement("title");
                    xmlWriter.WriteString(ConfigurationManager.AppSettings["AggregateTitle"]);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteEndElement();
                    //Body
                    xmlWriter.WriteStartElement("body");

                    xmlWriter.WriteStartElement("outline");
                    xmlWriter.WriteAttributeString("text", ConfigurationManager.AppSettings["AggregateTitle"] + " Feeds");
                    foreach(Blog blog in blogs)
                    {
                        xmlWriter.WriteStartElement("outline");

                        string title = blog.Title;
                        string xmlUrl = urlHelper.RssUrl(blog).ToString();

                        xmlWriter.WriteAttributeString("type", "rss");
                        xmlWriter.WriteAttributeString("text", title);
                        xmlWriter.WriteAttributeString("xmlUrl", xmlUrl);
                        xmlWriter.WriteEndElement();
                    }
                    xmlWriter.WriteEndElement(); //outline
                    xmlWriter.WriteEndElement(); //body
                    xmlWriter.WriteEndElement(); //opml
                    xmlWriter.Flush();
                }
            }
        }
예제 #5
0
        public void Ctor_WithAllNonNullArgs_SetsProperties()
        {
            //arrange
            var requestContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData());
            var urlHelper = new UrlHelper(requestContext, new RouteCollection());
            ObjectProvider objectRepository = new Mock<ObjectProvider>().Object;
            var blog = new Blog();

            //act
            var subtextContext = new SubtextContext(blog, requestContext, urlHelper, objectRepository, null, null, null);

            //assert
            Assert.AreEqual(blog, subtextContext.Blog);
            Assert.AreEqual(urlHelper, subtextContext.UrlHelper);
            Assert.AreEqual(requestContext, subtextContext.RequestContext);
            Assert.AreEqual(objectRepository, subtextContext.Repository);
        }
        public static void AddCommunityCredits(Entry entry, UrlHelper 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);
                }
            }
        }
예제 #7
0
        public static LinkCategory Links(CategoryType catType, Blog blog, UrlHelper urlHelper)
        {
            switch(catType)
            {
                case CategoryType.PostCollection:
                    return Transformer.BuildLinks(UIText.PostCollection, CategoryType.PostCollection, blog, urlHelper);

                case CategoryType.ImageCollection:
                    return Transformer.BuildLinks(UIText.ImageCollection, CategoryType.ImageCollection, blog, urlHelper);

                case CategoryType.StoryCollection:
                    return Transformer.BuildLinks(UIText.ArticleCollection, CategoryType.StoryCollection, blog, urlHelper);

                default:
                    Debug.Fail(String.Format(CultureInfo.InvariantCulture,
                                             "Invalid CategoryType: {0} via Subtext.Web.UI.UIData.Links", catType));
                    return null;
            }
        }
예제 #8
0
 private static AdminUrlHelper SetupUrlHelper(string appPath, RouteData routeData)
 {
     var routes = new RouteCollection();
     var subtextRoutes = new SubtextRouteMapper(routes, new Mock<IServiceLocator>().Object);
     Routes.RegisterRoutes(subtextRoutes);
     var httpContext = new Mock<HttpContextBase>();
     httpContext.Setup(c => c.Request.ApplicationPath).Returns(appPath);
     httpContext.Setup(c => c.Response.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(s => s);
     var requestContext = new RequestContext(httpContext.Object, routeData);
     var helper = new UrlHelper(requestContext, routes);
     return new AdminUrlHelper(helper);
 }
예제 #9
0
 public AdminUrlHelper(UrlHelper urlHelper)
 {
     Url = urlHelper;
 }
예제 #10
0
        /// <summary>
        /// Writes the RSD for the specified blog into the XmlWriter.
        /// </summary>
        public void WriteRsd(XmlWriter writer, Blog blog, UrlHelper urlHelper)
        {
            writer.WriteStartDocument();
            writer.WriteStartElement("rsd", "http://archipelago.phrasewise.com/rsd");
            writer.WriteAttributeString("version", "1.0");
            writer.WriteStartElement("service");
            writer.WriteElementString("engineName", "Subtext");
            writer.WriteElementString("engineLink", "http://subtextproject.com/");
            writer.WriteElementString("homePageLink", urlHelper.BlogUrl().ToFullyQualifiedUrl(blog).ToString());

            writer.WriteStartElement("apis");

            //When we have more than one API, we'll list them here.
            writer.WriteStartElement("api");
            writer.WriteAttributeString("name", "MetaWeblog");
            writer.WriteAttributeString("preferred", "true");
            writer.WriteAttributeString("apiLink", urlHelper.MetaWeblogApiUrl(blog).ToString());
            writer.WriteAttributeString("blogID", blog.Id.ToString(CultureInfo.InvariantCulture));
            writer.WriteEndElement(); // </api>

            writer.WriteEndElement(); // </apis>

            writer.WriteEndElement(); // </service>
            writer.WriteEndElement(); // </rsd>
            writer.WriteEndDocument();
            writer.Flush();
        }
예제 #11
0
        public void EntryUrl_WithNullEntry_ThrowsArgumentNullException()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            var requestContext = new RequestContext(httpContext.Object, new RouteData());
            var helper = new UrlHelper(requestContext, new RouteCollection());

            //act, assert
            UnitTestHelper.AssertThrowsArgumentNullException(() => helper.EntryUrl(null));
        }
예제 #12
0
 //Text to insert into a file with pinkback service location
 public static string GetPingPackTag(UrlHelper urlHelper)
 {
     return string.Format(CultureInfo.InvariantCulture,
                          "<link rel=\"pingback\" href=\"{0}Services/Pingback.aspx\"></link>",
                          urlHelper.BlogUrl());
 }
예제 #13
0
 public SearchEngine(Blog blog, UrlHelper urlHelper, string connectionString)
 {
     _blog = blog;
     _procedures = new StoredProcedures(connectionString);
     _urlHelper = urlHelper;
 }
예제 #14
0
 /// <summary>
 /// Builds a <see cref="LinkCategory"/> using the specified url formats. 
 /// A LinkCategory is a common item to databind to a web control.
 /// </summary>
 /// <returns></returns>
 public static LinkCategory ArchiveMonth(UrlHelper urlHelper, Blog blog)
 {
     return Transformer.BuildMonthLinks(UIText.Archives, urlHelper, blog);
 }
예제 #15
0
 public static Mock<ISubtextContext> SetupUrlHelper(this Mock<ISubtextContext> context, UrlHelper urlHelper)
 {
     context.Setup(c => c.UrlHelper).Returns(urlHelper);
     return context;
 }
예제 #16
0
        public void EntryUrl_WithEntryHavingPostTypeOfNone_ThrowsArgumentException()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            var requestContext = new RequestContext(httpContext.Object, new RouteData());
            var helper = new UrlHelper(requestContext, new RouteCollection());

            //act
            UnitTestHelper.AssertThrows<ArgumentException>(() => helper.EntryUrl(new Entry(PostType.None)));
        }
예제 #17
0
        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 cat = ObjectProvider.Instance().GetLinkCategory(categoryName, false);
                posts = Repository.GetEntries(PostType.BlogPost, cat.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 UrlHelper(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.DateModified.ToShortDateString());
                }
            }
        }