示例#1
0
        public bool metaweblog_editPost(string postid, string username, string password, MetaWeblog.Post post, bool publish)
        {
            if (!_dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }
            UserToken token = _siteSecurity.Login(username, password);

            if (token == null)
            {
                throw new System.Security.SecurityException();
            }
            Entry entry = _dataService.GetEntryForEdit(postid);

            if (entry != null)
            {
                entry.Author = username;
                TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(entry, post);

                entry.IsPublic   = publish;
                entry.Syndicated = publish;

                // TODO: Figure out how to save here
                // SiteUtilities.SaveEntry(entry, trackbackList, siteConfig, this.logService, this.dataService);
            }
            return(true);
        }
示例#2
0
        public string metaweblog_newPost(string blogid, string username, string password, MetaWeblog.Post post, bool publish)
        {
            if (!_dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }
            UserToken token = _siteSecurity.Login(username, password);

            if (token == null)
            {
                throw new System.Security.SecurityException();
            }

            Entry newPost = new Entry();

            newPost.Initialize();
            newPost.Author = username;

            TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(newPost, post);

            newPost.IsPublic   = publish;
            newPost.Syndicated = publish;

            // TODO: Figure out how to SaveEntry here
            // SiteUtilities.SaveEntry(newPost, trackbackList, siteConfig, this.logService, this.dataService);

            return(newPost.EntryId);
        }
示例#3
0
        public bool metaweblog_editPost(string postid, string username, string password, MetaWeblog.Post post, bool publish)
        {
            if (!dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }

            if (!VerifyLogin(username, password))
            {
                throw new SecurityException();
            }

            Entry entry = dataService.GetEntryForEdit(postid);

            if (entry != null)
            {
                entry.Author = username;
                TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(entry, post);

                entry.IsPublic   = publish;
                entry.Syndicated = publish;

                dataService.SaveEntry(entry);
            }
            return(true);
        }
示例#4
0
        public string metaweblog_newPost(string blogid, string username, string password, MetaWeblog.Post post, bool publish)
        {
            if (!dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }

            if (!VerifyLogin(username, password))
            {
                throw new SecurityException();
            }

            Entry newPost = new Entry();

            newPost.Initialize();
            newPost.Author = username;

            TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(newPost, post);

            newPost.IsPublic   = publish;
            newPost.Syndicated = publish;

            dataService.SaveEntry(newPost);

            return(newPost.EntryId);
        }
示例#5
0
        string IMetaWeblog.metaweblog_newPost(string blogid, string username, string password, newtelligence.DasBlog.Web.Services.MetaWeblog.Post post, bool publish)
        {
            if (!siteConfig.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }
            UserToken token = SiteSecurity.Login(username, password);

            if (token == null)
            {
                throw new System.Security.SecurityException();
            }

            Entry newPost = new Entry();

            newPost.Initialize();
            newPost.Author = username;

            TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(newPost, post);

            newPost.IsPublic   = publish;
            newPost.Syndicated = publish;
            // give the XSS upstreamer a hint that things have changed
            //FIX: XSSUpstreamer.TriggerUpstreaming();

            SiteUtilities.SaveEntry(newPost, trackbackList, siteConfig, this.logService, this.dataService);

            return(newPost.EntryId);
        }
示例#6
0
        private EntrySaveState InternalSaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList)
        {
            EntrySaveState rtn = EntrySaveState.Failed;

            // we want to prepopulate the cross post collection with the crosspost footer
            if (dasBlogSettings.SiteConfiguration.EnableCrossPostFooter && dasBlogSettings.SiteConfiguration.CrossPostFooter != null &&
                dasBlogSettings.SiteConfiguration.CrossPostFooter.Length > 0)
            {
                foreach (CrosspostInfo info in crosspostList)
                {
                    info.CrossPostFooter = dasBlogSettings.SiteConfiguration.CrossPostFooter;
                }
            }

            // now save the entry, passign in all the necessary Trackback and Pingback info.
            try
            {
                // if the post is missing a title don't publish it
                if (entry.Title == null || entry.Title.Length == 0)
                {
                    entry.IsPublic = false;
                }

                // if the post is missing categories, then set the categories to empty string.
                if (entry.Categories == null)
                {
                    entry.Categories = "";
                }

                rtn = dataService.SaveEntry(
                    entry,
                    MaybeBuildWeblogPingInfo(),
                    entry.IsPublic
                                                ? trackbackList
                                                : null,
                    MaybeBuildPingbackInfo(entry),
                    crosspostList);

                //TODO: SendEmail(entry, siteConfig, logService);
            }
            catch (Exception ex)
            {
                //TODO: Do something with this????
                // StackTrace st = new StackTrace();
                // logService.AddEvent(new EventDataItem(EventCodes.Error, ex.ToString() + Environment.NewLine + st.ToString(), ""));

                LoggedException le  = new LoggedException("file failure", ex);
                var             edi = new EventDataItem(EventCodes.Error, null
                                                        , "Failed to Save a Post on {date}", System.DateTime.Now.ToShortDateString());
                logger.LogError(edi, le);
            }

            // we want to invalidate all the caches so users get the new post
            // BreakCache(entry.GetSplitCategories());

            return(rtn);
        }
示例#7
0
        private EntrySaveState InternalSaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList)
        {
            EntrySaveState rtn = EntrySaveState.Failed;

            // we want to prepopulate the cross post collection with the crosspost footer
            if (_dasBlogSettings.SiteConfiguration.EnableCrossPostFooter && _dasBlogSettings.SiteConfiguration.CrossPostFooter != null &&
                _dasBlogSettings.SiteConfiguration.CrossPostFooter.Length > 0)
            {
                foreach (CrosspostInfo info in crosspostList)
                {
                    info.CrossPostFooter = _dasBlogSettings.SiteConfiguration.CrossPostFooter;
                }
            }

            // now save the entry, passign in all the necessary Trackback and Pingback info.
            try
            {
                // if the post is missing a title don't publish it
                if (entry.Title == null || entry.Title.Length == 0)
                {
                    entry.IsPublic = false;
                }

                // if the post is missing categories, then set the categories to empty string.
                if (entry.Categories == null)
                {
                    entry.Categories = "";
                }

                rtn = _dataService.SaveEntry(entry,
                                             (_dasBlogSettings.SiteConfiguration.PingServices.Count > 0) ?
                                             new WeblogUpdatePingInfo(_dasBlogSettings.SiteConfiguration.Title, _dasBlogSettings.GetBaseUrl(), _dasBlogSettings.GetBaseUrl(), _dasBlogSettings.RsdUrl, _dasBlogSettings.SiteConfiguration.PingServices) : null,
                                             (entry.IsPublic) ?
                                             trackbackList : null,
                                             _dasBlogSettings.SiteConfiguration.EnableAutoPingback && entry.IsPublic ?
                                             new PingbackInfo(
                                                 _dasBlogSettings.GetPermaLinkUrl(entry.EntryId),
                                                 entry.Title,
                                                 entry.Description,
                                                 _dasBlogSettings.SiteConfiguration.Title) : null,
                                             crosspostList);

                //TODO: SendEmail(entry, siteConfig, logService);
            }
            catch (Exception ex)
            {
                //TODO: Do something with this????
                // StackTrace st = new StackTrace();
                // logService.AddEvent(new EventDataItem(EventCodes.Error, ex.ToString() + Environment.NewLine + st.ToString(), ""));
            }

            // we want to invalidate all the caches so users get the new post
            // TODO: BreakCache(entry.GetSplitCategories());

            return(rtn);
        }
示例#8
0
        public bool metaweblog_editPost(string postid, string username, string password, MetaWeblog.Post post, bool publish)
        {
            VerifyAccess(username, password);

            Entry entry = dataService.GetEntryForEdit(postid);

            if (entry != null)
            {
                entry.Author = username;
                TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(entry, post);

                entry.IsPublic   = publish;
                entry.Syndicated = publish;

                dataService.SaveEntry(entry);
            }
            return(true);
        }
示例#9
0
        /// <summary>Fills a DasBlog entry from a MetaWeblog Post structure.</summary>
        /// <param name="entry">DasBlog entry to fill.</param>
        /// <param name="post">MetaWeblog post structure to fill from.</param>
        /// <returns>TrackbackInfoCollection of posts to send trackback pings.</returns>
        private TrackbackInfoCollection FillEntryFromMetaWeblogPost(Entry entry, MetaWeblog.Post post)
        {
            // W.Bloggar doesn't pass in the DataCreated,
            // so we have to check for that
            if (post.dateCreated != DateTime.MinValue)
            {
                entry.CreatedUtc = post.dateCreated.ToUniversalTime();
            }

            //Patched to avoid html entities in title
            entry.Title       = post.title; // TODO: Find out how to decode this...  HttpUtility.HtmlDecode(post.title);
            entry.Content     = post.description;
            entry.Description = NoNull(post.mt_excerpt);

            // If mt_allow_comments is null, then the sender did not specify.  Use default dasBlog behavior in that case
            if (post.mt_allow_comments != null)
            {
                int nAllowComments = Convert.ToInt32(post.mt_allow_comments);
                if (nAllowComments == 0 || nAllowComments == 2)
                {
                    entry.AllowComments = false;
                }
                else
                {
                    entry.AllowComments = true;
                }
            }

            if (post.categories != null && post.categories.Length > 0)
            {
                // handle categories
                string categories = "";

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                bool needSemi = false;
                post.categories = RemoveDups(post.categories, true);
                foreach (string category in post.categories)
                {
                    //watch for "" as a category
                    if (category.Length > 0)
                    {
                        if (needSemi)
                        {
                            sb.Append(";");
                        }
                        sb.Append(category);
                        needSemi = true;
                    }
                }
                categories = sb.ToString();

                if (categories.Length > 0)
                {
                    entry.Categories = categories;
                }
            }

            // We'll always return at least an empty collection
            TrackbackInfoCollection trackbackList = new TrackbackInfoCollection();

            // Only MT supports trackbacks in the post
            if (post.mt_tb_ping_urls != null)
            {
                foreach (string trackbackUrl in post.mt_tb_ping_urls)
                {
                    trackbackList.Add(new TrackbackInfo(
                                          trackbackUrl,
                                          "", //TODO: Replace SiteUtilities.GetPermaLinkUrl(siteConfig, (ITitledEntry)entry)
                                          entry.Title,
                                          entry.Description,
                                          _dasBlogSettings.SiteConfiguration.Title));
                }
            }
            return(trackbackList);
        }
示例#10
0
 public static void SaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService)
 {
     SiteUtilities.SaveEntry(entry, trackbackList, crosspostList, siteConfig, logService, dataService);
 }
示例#11
0
文件: Utils.cs 项目: AArnott/dasblog
 public static void SaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService)
 {
     SiteUtilities.SaveEntry(entry,trackbackList,crosspostList,siteConfig,logService,dataService);
 }
示例#12
0
        /// <summary>Fills a DasBlog entry from a MetaWeblog Post structure.</summary>
        /// <param name="entry">DasBlog entry to fill.</param>
        /// <param name="post">MetaWeblog post structure to fill from.</param>
        /// <returns>TrackbackInfoCollection of posts to send trackback pings.</returns>
        private TrackbackInfoCollection FillEntryFromMetaWeblogPost( Entry entry, newtelligence.DasBlog.Web.Services.MetaWeblog.Post post )
        {
            // W.Bloggar doesn't pass in the DataCreated,
            // so we have to check for that
            if ( post.dateCreated != DateTime.MinValue )
            {
                entry.CreatedUtc = post.dateCreated.ToUniversalTime();
            }

            //Patched to avoid html entities in title
            entry.Title = HttpUtility.HtmlDecode(post.title);
            entry.Content = post.description;
            entry.Description = noNull( post.mt_excerpt );

            // If mt_allow_comments is null, then the sender did not specify.  Use default dasBlog behavior in that case
            if ( post.mt_allow_comments != null )
            {
                int nAllowComments = Convert.ToInt32( post.mt_allow_comments );
                if ( nAllowComments == 0 || nAllowComments == 2 )
                    entry.AllowComments = false;
                else
                    entry.AllowComments = true;
            }

            if ( post.categories != null && post.categories.Length > 0 )
            {
                // handle categories
                string categories = "";

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                bool needSemi = false;
                post.categories = RemoveDups( post.categories, true );
                foreach( string category in post.categories )
                {
                    //watch for "" as a category
                    if( category.Length > 0 )
                    {
                        if ( needSemi ) sb.Append( ";" );
                        sb.Append( category );
                        needSemi = true;
                    }
                }
                categories = sb.ToString();

                if ( categories.Length > 0 )
                    entry.Categories = categories;
            }

            // We'll always return at least an empty collection
            TrackbackInfoCollection trackbackList = new TrackbackInfoCollection();

            // Only MT supports trackbacks in the post
            if ( post.mt_tb_ping_urls != null )
            {
                foreach ( string trackbackUrl in post.mt_tb_ping_urls )
                {
                    trackbackList.Add( new TrackbackInfo(
                        trackbackUrl,
                        SiteUtilities.GetPermaLinkUrl( siteConfig, entry ),
                        entry.Title,
                        entry.Description,
                        siteConfig.Title ) );
                }
            }
            return trackbackList;
        }
示例#13
0
        private static EntrySaveState InternalSaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService)
        {
            EntrySaveState rtn = EntrySaveState.Failed;
            // we want to prepopulate the cross post collection with the crosspost footer
            if (siteConfig.EnableCrossPostFooter && siteConfig.CrossPostFooter != null && siteConfig.CrossPostFooter.Length > 0)
            {
                foreach (CrosspostInfo info in crosspostList)
                {
                    info.CrossPostFooter = siteConfig.CrossPostFooter;
                }
            }

            // now save the entry, passign in all the necessary Trackback and Pingback info.
            try
            {
                // if the post is missing a title don't publish it
                if (entry.Title == null || entry.Title.Length == 0)
                {
                    entry.IsPublic = false;
                }

                // if the post is missing categories, then set the categories to empty string.
                if (entry.Categories == null)
                    entry.Categories = "";

                rtn = dataService.SaveEntry(
                    entry,
                    (siteConfig.PingServices.Count > 0) ?
                        new WeblogUpdatePingInfo(siteConfig.Title, SiteUtilities.GetBaseUrl(siteConfig), SiteUtilities.GetBaseUrl(siteConfig), SiteUtilities.GetRssUrl(siteConfig), siteConfig.PingServices) : null,
                    (entry.IsPublic) ?
                        trackbackList : null,
                    siteConfig.EnableAutoPingback && entry.IsPublic ?
                        new PingbackInfo(
                            SiteUtilities.GetPermaLinkUrl(siteConfig, entry),
                            entry.Title,
                            entry.Description,
                            siteConfig.Title) : null,
                    crosspostList);

                SendEmail(entry, siteConfig, logService);

            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                logService.AddEvent(
                    new EventDataItem(EventCodes.Error, ex.ToString() + Environment.NewLine + st.ToString(), ""));
            }

            // we want to invalidate all the caches so users get the new post
            BreakCache(siteConfig, entry.GetSplitCategories());

            // give the XSS upstreamer a hint that things have changed
            //FIX:  XSSUpstreamer.TriggerUpstreaming();

            return rtn;
        }
示例#14
0
        public static EntrySaveState UpdateEntry(Entry entry, string trackbackUrl, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService)
        {
            EntrySaveState rtn = EntrySaveState.Failed;

            entry.ModifiedLocalTime = DateTime.Now;

            TrackbackInfoCollection trackbackList = null;
            if (trackbackUrl != null && trackbackUrl.Length > 0)
            {
                trackbackList = new TrackbackInfoCollection();
                trackbackList.Add(new TrackbackInfo(
                    trackbackUrl,
                    SiteUtilities.GetPermaLinkUrl(siteConfig, entry),
                    entry.Title,
                    entry.Description,
                    siteConfig.Title));
            }

            rtn = InternalSaveEntry(entry, trackbackList, crosspostList, siteConfig, logService, dataService);

            logService.AddEvent(
                new EventDataItem(
                    EventCodes.EntryChanged, entry.Title,
                    SiteUtilities.GetPermaLinkUrl(entry.EntryId)));

            return rtn;
        }
示例#15
0
        public static void SaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService)
        {
            InternalSaveEntry(entry, trackbackList, crosspostList, siteConfig, logService, dataService);

            logService.AddEvent(
                new EventDataItem(
                    EventCodes.EntryAdded, entry.Title,
                    SiteUtilities.GetPermaLinkUrl(siteConfig, entry.EntryId)));
        }
示例#16
0
        public static void SaveEntry(Entry entry, string trackbackUrl, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService)
        {
            TrackbackInfoCollection trackbackList = null;
            if (trackbackUrl != null && trackbackUrl.Length > 0)
            {
                trackbackList = new TrackbackInfoCollection();
                trackbackList.Add(new TrackbackInfo(
                    trackbackUrl,
                    SiteUtilities.GetPermaLinkUrl(siteConfig, entry),
                    entry.Title,
                    entry.Description,
                    siteConfig.Title));
            }
            InternalSaveEntry(entry, trackbackList, crosspostList, siteConfig, logService, dataService);

            logService.AddEvent(
                new EventDataItem(
                EventCodes.EntryAdded, entry.Title,
                SiteUtilities.GetPermaLinkUrl(siteConfig, entry.EntryId)));
        }