Example #1
0
        public Blogger.Category[] blogger_getCategories(string blogid, string username, string password)
        {
            if (!_dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }

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

            List <Blogger.Category>      arrayList  = new List <Blogger.Category>();
            CategoryCacheEntryCollection categories = _dataService.GetCategories();

            if (categories.Count == 0)
            {
                Blogger.Category bcat = new Blogger.Category();
                bcat.categoryid  = "Front Page";
                bcat.description = "Front Page";
                bcat.htmlUrl     = _dasBlogSettings.GetCategoryViewUrl(bcat.categoryid);
                bcat.rssUrl      = _dasBlogSettings.GetCategoryViewUrl(bcat.categoryid);
                bcat.title       = NoNull(bcat.description);
                arrayList.Add(bcat);
            }
            else
            {
                foreach (CategoryCacheEntry cat in categories)
                {
                    Blogger.Category bcat = new Blogger.Category();
                    bcat.categoryid  = NoNull(cat.Name);
                    bcat.description = NoNull(cat.Name);
                    bcat.htmlUrl     = _dasBlogSettings.GetCategoryViewUrl(cat.Name);
                    bcat.rssUrl      = _dasBlogSettings.GetCategoryViewUrl(cat.Name);                 //Should this be GetRssCategoryUrl()
                    bcat.title       = NoNull(cat.Name);
                    arrayList.Add(bcat);
                }
            }
            return(arrayList.ToArray());
        }
Example #2
0
        newtelligence.DasBlog.Web.Services.Blogger.Category[] IBlogger.blogger_getCategories(string blogid, string username, string password)
        {
            if (!siteConfig.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }
            UserToken token = SiteSecurity.Login(username, password);

            if (token == null)
            {
                throw new System.Security.SecurityException();
            }
            List <newtelligence.DasBlog.Web.Services.Blogger.Category> arrayList = new List <newtelligence.DasBlog.Web.Services.Blogger.Category>();
            CategoryCacheEntryCollection categories = dataService.GetCategories();

            if (categories.Count == 0)
            {
                newtelligence.DasBlog.Web.Services.Blogger.Category bcat = new newtelligence.DasBlog.Web.Services.Blogger.Category();
                bcat.categoryid  = "Front Page";
                bcat.description = "Front Page";
                bcat.htmlUrl     = SiteUtilities.GetCategoryViewUrl(bcat.categoryid);
                bcat.rssUrl      = SiteUtilities.GetRssCategoryUrl(bcat.categoryid);
                bcat.title       = noNull(bcat.description);
                arrayList.Add(bcat);
            }
            else
            {
                foreach (CategoryCacheEntry cat in categories)
                {
                    newtelligence.DasBlog.Web.Services.Blogger.Category bcat = new newtelligence.DasBlog.Web.Services.Blogger.Category();
                    bcat.categoryid  = noNull(cat.Name);
                    bcat.description = noNull(cat.Name);
                    bcat.htmlUrl     = SiteUtilities.GetCategoryViewUrl(cat.Name);
                    bcat.rssUrl      = SiteUtilities.GetRssCategoryUrl(cat.Name);
                    bcat.title       = noNull(cat.Name);
                    arrayList.Add(bcat);
                }
            }
            return(arrayList.ToArray());
        }
Example #3
0
        public MoveableType.Category[] InternalGetCategoryList()
        {
            List <MoveableType.Category> arrayList  = new List <MoveableType.Category>();
            CategoryCacheEntryCollection categories = _dataService.GetCategories();

            if (categories.Count == 0)
            {
                arrayList.Add(InternalGetFrontPageCategory());
            }
            else
            {
                foreach (CategoryCacheEntry catEntry in categories)
                {
                    MoveableType.Category category = new MoveableType.Category();
                    category.categoryId   = NoNull(catEntry.Name);
                    category.categoryName = NoNull(catEntry.Name);
                    //category.isPrimary=false;
                    arrayList.Add(category);
                }
            }
            return(arrayList.ToArray());
        }
Example #4
0
        private newtelligence.DasBlog.Web.Services.MovableType.Category[] InternalGetCategoryList()
        {
            List <newtelligence.DasBlog.Web.Services.MovableType.Category> arrayList = new List <newtelligence.DasBlog.Web.Services.MovableType.Category>();
            CategoryCacheEntryCollection categories = dataService.GetCategories();

            if (categories.Count == 0)
            {
                arrayList.Add(InternalGetFrontPageCategory());
            }
            else
            {
                foreach (CategoryCacheEntry catEntry in categories)
                {
                    newtelligence.DasBlog.Web.Services.MovableType.Category category = new newtelligence.DasBlog.Web.Services.MovableType.Category();
                    category.categoryId   = noNull(catEntry.Name);
                    category.categoryName = noNull(catEntry.Name);
                    //category.isPrimary=false;
                    arrayList.Add(category);
                }
            }
            return(arrayList.ToArray());
        }
Example #5
0
        public urlset GetGoogleSiteMap()
        {
            urlset root = new urlset();

            root.url = new urlCollection();

            //Default first...
            url basePage = new url(dasBlogSettings.GetBaseUrl(), DateTime.Now, changefreq.daily, 1.0M);

            root.url.Add(basePage);

            //Archives next...
            url archivePage = new url(dasBlogSettings.RelativeToRoot("archives"), DateTime.Now, changefreq.daily, 1.0M);

            root.url.Add(archivePage);

            //All Pages
            EntryCollection entryCache = dataService.GetEntries(false);

            foreach (Entry e in entryCache)
            {
                if (e.IsPublic)
                {
                    //Start with a RARE change freq...newer posts are more likely to change more often.
                    // The older a post, the less likely it is to change...
                    changefreq freq = changefreq.daily;

                    //new stuff?
                    if (e.CreatedLocalTime < DateTime.Now.AddMonths(-9))
                    {
                        freq = changefreq.yearly;
                    }
                    else if (e.CreatedLocalTime < DateTime.Now.AddDays(-30))
                    {
                        freq = changefreq.monthly;
                    }
                    else if (e.CreatedLocalTime < DateTime.Now.AddDays(-7))
                    {
                        freq = changefreq.weekly;
                    }
                    if (e.CreatedLocalTime > DateTime.Now.AddDays(-2))
                    {
                        freq = changefreq.hourly;
                    }

                    //Add comments pages, since comments have indexable content...
                    // Only add comments if we aren't showing comments on permalink pages already
                    if (dasBlogSettings.SiteConfiguration.ShowCommentsWhenViewingEntry == false)
                    {
                        url commentPage = new url(dasBlogSettings.GetCommentViewUrl(e.CompressedTitle), e.CreatedLocalTime, freq, 0.7M);
                        root.url.Add(commentPage);
                    }

                    //then add permalinks
                    url permaPage = new url(dasBlogSettings.RelativeToRoot(dasBlogSettings.GetPermaTitle(e.CompressedTitle)), e.CreatedLocalTime, freq, 0.9M);
                    root.url.Add(permaPage);
                }
            }

            //All Categories
            CategoryCacheEntryCollection catCache = dataService.GetCategories();

            foreach (CategoryCacheEntry cce in catCache)
            {
                if (cce.IsPublic)
                {
                    url catPage = new url(dasBlogSettings.GetCategoryViewUrl(cce.Name), DateTime.Now, changefreq.weekly, 0.6M);
                    root.url.Add(catPage);
                }
            }

            return(root);
        }
Example #6
0
 CategoryCacheEntryCollection IBlogDataService.GetCategories()
 {
     CategoryCacheEntryCollection result;
     CategoryCache cache = new CategoryCache();
     cache.Ensure(data);
     if (Thread.CurrentPrincipal.IsInRole("admin"))
     {
         result = cache.Entries;
     }
     else
     {
         result = new CategoryCacheEntryCollection();
         foreach (CategoryCacheEntry category in cache.Entries)
         {
             if (category.IsPublic)
             {
                 result.Add(category);
             }
         }
     }
     return result;
 }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                //Cache the sitemap for 12 hours...
                string    CacheKey = "GoogleSiteMap";
                DataCache cache    = CacheFactory.GetCache();

                urlset root = cache[CacheKey] as urlset;
                if (root == null) //we'll have to build it...
                {
                    ILoggingDataService logService  = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
                    IBlogDataService    dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService);
                    SiteConfig          siteConfig  = SiteConfig.GetSiteConfig();

                    root = new urlset();

                    root.url = new urlCollection();

                    //Default first...
                    url basePage = new url(SiteUtilities.GetBaseUrl(siteConfig), DateTime.Now, changefreq.daily, 1.0M);
                    root.url.Add(basePage);

                    url defaultPage = new url(SiteUtilities.GetStartPageUrl(siteConfig), DateTime.Now, changefreq.daily, 1.0M);
                    root.url.Add(defaultPage);

                    //Archives next...
                    url archivePage = new url(SiteUtilities.RelativeToRoot(siteConfig, "archives.aspx"), DateTime.Now, changefreq.daily, 1.0M);
                    root.url.Add(archivePage);

                    //All Pages
                    EntryCollection entryCache = dataService.GetEntries(false);
                    foreach (Entry e in entryCache)
                    {
                        if (e.IsPublic)
                        {
                            //Start with a RARE change freq...newer posts are more likely to change more often.
                            // The older a post, the less likely it is to change...
                            changefreq freq = changefreq.daily;

                            //new stuff?
                            if (e.CreatedLocalTime < DateTime.Now.AddMonths(-9))
                            {
                                freq = changefreq.yearly;
                            }
                            else if (e.CreatedLocalTime < DateTime.Now.AddDays(-30))
                            {
                                freq = changefreq.monthly;
                            }
                            else if (e.CreatedLocalTime < DateTime.Now.AddDays(-7))
                            {
                                freq = changefreq.weekly;
                            }
                            if (e.CreatedLocalTime > DateTime.Now.AddDays(-2))
                            {
                                freq = changefreq.hourly;
                            }

                            //Add comments pages, since comments have indexable content...
                            // Only add comments if we aren't showing comments on permalink pages already
                            if (siteConfig.ShowCommentsWhenViewingEntry == false)
                            {
                                url commentPage = new url(SiteUtilities.GetCommentViewUrl(siteConfig, e.EntryId), e.CreatedLocalTime, freq, 0.7M);
                                root.url.Add(commentPage);
                            }

                            //then add permalinks
                            url permaPage = new url(SiteUtilities.GetPermaLinkUrl(siteConfig, (ITitledEntry)e), e.CreatedLocalTime, freq, 0.9M);
                            root.url.Add(permaPage);
                        }
                    }

                    //All Categories
                    CategoryCacheEntryCollection catCache = dataService.GetCategories();
                    foreach (CategoryCacheEntry cce in catCache)
                    {
                        if (cce.IsPublic)
                        {
                            url catPage = new url(SiteUtilities.GetCategoryViewUrl(siteConfig, cce.Name), DateTime.Now, changefreq.weekly, 0.6M);
                            root.url.Add(catPage);
                        }
                    }
                    cache.Insert(CacheKey, root, DateTime.Now.AddHours(12));
                }

                XmlSerializer x = new XmlSerializer(typeof(urlset));
                x.Serialize(context.Response.OutputStream, root);
                context.Response.ContentType = "text/xml";
            }
            catch (Exception exc)
            {
                ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, exc);
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            logger.Info("Starting");
            // we need to set the role to admin so we get public entries
            System.Threading.Thread.CurrentPrincipal = new GenericPrincipal(System.Threading.Thread.CurrentPrincipal.Identity, new string[] { "admin" });

            if (args.Length != 1)
            {
                logger.Error(@"Usage: DasBlogGraffitiExporter ""c:\mydasblog\content""");
                Environment.Exit(1);
                return;
            }

            Console.WriteLine("Press ENTER to continue...");
            Console.ReadLine();

            string path = args[0];

            if (Directory.Exists(path))
            {
                // Check all the files again for bad xml which can happen during multithreaded FTP downloads with SmartFTP,
                // plus it doesn't hurt and can catch corruption you don't know you have!
                foreach (string file in Directory.GetFiles(path, "*.xml"))
                {
                    try
                    {
                        XmlDocument x = new XmlDocument();
                        x.Load(file);
                    }
                    catch (XmlException ex)
                    {
                        logger.FatalFormat("ERROR: Malformed Xml in file: {0}", file);
                        logger.Fatal("XmlException", ex);
                    }
                }

                IBlogDataService dataService = BlogDataServiceFactory.GetService(path, null);

                List <UrlMap> categoryMap = new List <UrlMap>();
                CategoryCacheEntryCollection categories = dataService.GetCategories();
                logger.InfoFormat("Found {0} Categories", categories.Count);

                foreach (CategoryCacheEntry entry in categories)
                {
                    string name    = HttpHelper.GetURLSafeString(entry.Name);
                    UrlMap mapping = new UrlMap(name, InternalCompressTitle(entry.DisplayName));
                    categoryMap.Add(mapping);
                    logger.InfoFormat("Adding category name:{0}, display name:{1}", entry.Name, entry.DisplayName);
                }

                UrlMap.Save(categoryMap, Path.Combine(GetDasBlog301Folder(), "CategoryMapping.xml"));

                EntryCollection entries = dataService.GetEntriesForDay(
                    DateTime.MaxValue.AddDays(-2),
                    TimeZone.CurrentTimeZone,
                    String.Empty,
                    int.MaxValue,
                    int.MaxValue,
                    String.Empty);
                logger.InfoFormat("Found {0} entries", entries.Count);

                List <UrlMap> permalinkMapping = new List <UrlMap>();

                foreach (Entry entry in entries)
                {
                    string title   = entry.CompressedTitle;
                    UrlMap mapping = new UrlMap(entry.EntryId, title);
                    permalinkMapping.Add(mapping);
                    logger.InfoFormat("Adding entry id:{0} title:{1}", entry.EntryId, entry.CompressedTitle);
                }

                UrlMap.Save(permalinkMapping, Path.Combine(GetDasBlog301Folder(), "PermalinkMapping.xml"));
            }
        }