Пример #1
0
        public FullPost[] GetRecentPosts(String blogid, String emailAddress, String password, Int32 maxEntryCount)
        {
            String blogGuid = blogid;

            //+
            if (this.Reporter.Initialized)
            {
                this.Reporter.SendSingle(new Object[] { blogGuid, emailAddress, password, maxEntryCount }, "XmlRpcApi::GetRecentPosts", false);
            }
            //+
            List <BlogEntry> blogEntryList = BlogAgent.GetBlogEntryList(blogGuid, maxEntryCount, false, BlogEntryRetreivalType.Full, emailAddress, password);

            //+
            return(blogEntryList.Select(p => new FullPost
            {
                dateCreated = p.PostDateTime,
                description = p.Content,
                title = p.Title,
                link = Themelia.Web.Http.Root + "/" + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.First()),
                permalink = Themelia.Web.Http.Root + "/" + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.First()),
                postid = p.Guid,
                mt_allow_comments = "1",
                mt_convert_breaks = "0",
                mt_text_mode = "",
                mt_excerpt = "0",
                mt_tb_ping_urls = new String[0],
                categories = p.LabelList != null ? p.LabelList.Select(q => q.Title).ToArray() : null
            }).ToArray());
        }
Пример #2
0
        //+
        //- #GetDataSource -//
        protected override Object GetDataSource()
        {
            Int32 maxEntryCount = BlogSection.GetConfigSection().EntriesToShow;

            if (this.MaxEntryCount > 0)
            {
                maxEntryCount = this.MaxEntryCount;
            }
            List <BlogEntry> blogEntryList = BlogAgent.GetBlogEntryList(this.BlogGuid, maxEntryCount, false, BlogEntryRetreivalType.Full);

            //+
            return(blogEntryList.Select(p => new
            {
                Url = "/" + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.First()),
                Title = p.Title
            }));
        }
Пример #3
0
        //- @ProcessRequest -//
        public override void Process()
        {
            String blogGuid = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.BlogGuid);
            String key      = "SiteMap_" + blogGuid;

            if (String.IsNullOrEmpty(Themelia.Web.Http.Cache[key] as String))
            {
                List <BlogEntry> blogEntryList = BlogAgent.GetBlogEntryList(blogGuid, 0, false, BlogEntryRetreivalType.Full);
                StringBuilder    xml           = new StringBuilder();
                XmlWriter        xmlWriter     = XmlWriter.Create(xml);
                xmlWriter.WriteProcessingInstruction("xml", @"version=""1.0"" encoding=""UTF-8""");
                xmlWriter.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9");
                foreach (BlogEntry blogEntry in blogEntryList)
                {
                    xmlWriter.WriteStartElement("url");
                    //+
                    xmlWriter.WriteStartElement("loc");
                    //xmlWriter.WriteValue(blogEntry.BlogEntryUri.AbsoluteUri);
                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteStartElement("lastmod");
                    xmlWriter.WriteValue(blogEntry.PostDateTime.ToString("yyyy-MM-dd"));
                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteStartElement("changefreq");
                    xmlWriter.WriteValue("never");
                    xmlWriter.WriteEndElement();
                    //+
                    xmlWriter.WriteEndElement();
                }
                xmlWriter.WriteEndElement();
                xmlWriter.Close();
                //+
                Themelia.Web.Http.Cache.Insert(key, xml.ToString());
            }
            ContentType = "text/xml";
            Output.Append(Themelia.Web.Http.Cache[key] as String);
        }
Пример #4
0
        //+
        //- #OnInit -//
        protected override void OnInit(EventArgs e)
        {
            Func <BlogEntry, IndexEntry> indexTransformation = p => new IndexEntry
            {
                Url             = Themelia.Web.WebDomain.GetUrl() + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.FirstOrDefault()),
                Title           = p.Title,
                TypeGuid        = p.BlogEntryTypeGuid,
                PostDateTime    = p.PostDateTime,
                LabelList       = p.LabelList,
                DateTimeString  = String.Format("{0}, {1} {2}, {3}", p.PostDateTime.DayOfWeek, p.PostDateTime.ToString("MMMM"), p.PostDateTime.Day, p.PostDateTime.Year),
                DateTimeDisplay = String.Format("{0}/{1}/{2} {3}", p.PostDateTime.Month, p.PostDateTime.Day, p.PostDateTime.Year, p.PostDateTime.ToShortTimeString())
            };
            List <IndexEntry> indexDataSource;

            //+ index
            if (this.Index > 0)
            {
                String   blogGuid      = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.BlogGuid);
                DateTime startDateTime = new DateTime(this.Index, 1, 1, 0, 0, 0);
                DateTime endDateTime   = new DateTime(this.Index, 12, 31, 23, 59, 59);
                //+
                indexDataSource = BlogAgent.GetBlogEntryListByDateRange(blogGuid, startDateTime, endDateTime, false, true).Select(indexTransformation).ToList();
                List <Int32> yearDataSource = BlogAgent.GetBlogEntryList(blogGuid, 0, false, BlogEntryRetreivalType.VeryBasic)
                                              .Where(p => p.PostDateTime.Year != this.Index)
                                              .Select(p => p.PostDateTime.Year)
                                              .Distinct()
                                              .OrderByDescending(p => p)
                                              .ToList();
                indexListSeries = new IndexListSeries()
                {
                    HeadingSuffix       = BlogSection.GetConfigSection().Suffix.Index,
                    BlogEntryDataSource = indexDataSource,
                    YearDataSource      = yearDataSource,
                    Year = this.Index
                };
                indexListSeries.ID = "indexListSeries";
                this.Controls.Add(indexListSeries);
            }
            //+ blog
            else
            {
                if (this.AccessType == AccessType.Archive || this.AccessType == AccessType.Label)
                {
                    if (this.DataSource != null && this.DataSource.Count > 0)
                    {
                        indexDataSource   = this.DataSource.Select(indexTransformation).ToList();
                        indexEntryList    = new IndexEntryList(this.AccessType, indexDataSource);
                        indexEntryList.ID = "indexEntryList";
                        this.Controls.Add(indexEntryList);
                    }
                }
                //+
                phNoEntries    = __BuildNoEntryPlaceHolderControl();
                phNoEntries.ID = "phNoEntries";
                this.Controls.Add(phNoEntries);
                //+
                rptPosts    = this.__BuildPostRepeaterControl();
                rptPosts.ID = "rptPosts";
                this.Controls.Add(rptPosts);
                //+
                if (this.SupportCommenting)
                {
                    mvCommentContent = this.__BuildCommentMultiViewControl();
                    this.Controls.Add(mvCommentContent);
                }
            }
            //+
            base.OnInit(e);
        }