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()); }
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()); }
protected EntryCollection BuildEntries(string category, int maxDayCount, int maxEntryCount) { EntryCollection entryList = new EntryCollection(); if (category != null) { int entryCount = _dasBlogSettings.SiteConfiguration.RssEntryCount; category = category.ToUpper(); foreach (CategoryCacheEntry catEntry in _dataService.GetCategories()) { if (catEntry.Name.ToUpper() == category) { foreach (CategoryCacheEntryDetail detail in catEntry.EntryDetails) { Entry entry = _dataService.GetEntry(detail.EntryId); if (entry != null) { entryList.Add(entry); entryCount--; } if (entryCount <= 0) { break; } } // foreach (CategoryCacheEntryDetail } if (entryCount <= 0) { break; } } // foreach (CategoryCacheEntry } else { entryList = _dataService.GetEntriesForDay(DateTime.Now.AddDays(_dasBlogSettings.SiteConfiguration.ContentLookaheadDays).ToUniversalTime(), new newtelligence.DasBlog.Util.UTCTimeZone(), null, maxDayCount, maxEntryCount, null); } entryList.Sort(new EntrySorter()); return(entryList); }
protected EntryCollection BuildEntries(string category, int maxDayCount, int maxEntryCount) { EntryCollection entryList = new EntryCollection(); if (category != null) { int entryCount = dasBlogSettings.SiteConfiguration.RssEntryCount; category = category.ToUpper(); foreach (CategoryCacheEntry catEntry in dataService.GetCategories()) { if (catEntry.Name.ToUpper() == category) { foreach (CategoryCacheEntryDetail detail in catEntry.EntryDetails) { Entry entry = dataService.GetEntry(detail.EntryId); if (entry != null) { entryList.Add(entry); entryCount--; } if (entryCount <= 0) { break; } } // foreach (CategoryCacheEntryDetail } if (entryCount <= 0) { break; } } // foreach (CategoryCacheEntry } else { entryList = dataService.GetEntriesForDay(dasBlogSettings.GetContentLookAhead(), dasBlogSettings.GetConfiguredTimeZone(), null, maxDayCount, maxEntryCount, null); } entryList.Sort(new EntrySorter()); return(entryList); }
protected EntryCollection BuildEntries(string category, int maxDayCount, int maxEntryCount) { var entryList = new EntryCollection(); if (category != null) { int entryCount = dasBlogSettings.SiteConfiguration.RssEntryCount; category = category.Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement, " "); foreach (var catEntry in dataService.GetCategories()) { if (string.Compare(catEntry.Name, category, CultureInfo.CurrentCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0) { foreach (CategoryCacheEntryDetail detail in catEntry.EntryDetails) { Entry entry = dataService.GetEntry(detail.EntryId); if (entry != null) { entryList.Add(entry); entryCount--; } if (entryCount <= 0) { break; } } // foreach (CategoryCacheEntryDetail } if (entryCount <= 0) { break; } } // foreach (CategoryCacheEntry } else { entryList = dataService.GetEntriesForDay(dasBlogSettings.GetContentLookAhead(), dasBlogSettings.GetConfiguredTimeZone(), null, maxDayCount, maxEntryCount, null); } entryList.Sort(new EntrySorter()); return(entryList); }
public CategoryCacheEntryCollection GetCategories() { return(dataService.GetCategories()); }
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); }
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); } }
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")); } }