Exemplo n.º 1
0
 private Uri MakePermaLinkFromCompressedTitle(Entry entry)
 {
     if (opts.EnableTitlePermaLinkUnique)
     {
         return
             (new Uri(new Uri(opts.Root),
                      SettingsUtils.RelativeToRoot(entry.CreatedUtc.ToString("yyyyMMdd") + "/" +
                                                   SettingsUtils.GetPermaTitle(entry.CompressedTitle, opts.TitlePermalinkSpaceReplacement), opts.Root))
             );
     }
     else
     {
         return
             (new Uri(new Uri(opts.Root),
                      SettingsUtils.RelativeToRoot(
                          SettingsUtils.GetPermaTitle(entry.CompressedTitle, opts.TitlePermalinkSpaceReplacement), opts.Root)));
     }
 }
Exemplo n.º 2
0
 /// <param name="dt">if non-null then the post must be dated on that date</param>
 public Entry GetBlogPost(string postid, DateTime?dt)
 {
     if (dt == null)
     {
         return(dataService.GetEntry(postid));
     }
     else
     {
         EntryCollection entries = dataService.GetEntriesForDay(dt.Value, null, null, 1, 10, null);
         return(entries.FirstOrDefault(e =>
                                       Pass(() => dasBlogSettings.GetPermaTitle(e.CompressedTitle), () => SettingsUtils.GetPermaTitle(e.CompressedTitle, opts.TitlePermalinkSpaceReplacement))
                                       .Replace(Pass(() => dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement, () => opts.TitlePermalinkSpaceReplacement), string.Empty)
                                       == postid));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// not sure what this is about but it is legacy
 /// TODO: reconsider when strategy for handling pingback in legacy site.config is decided.
 /// </summary>
 private PingbackInfo MaybeBuildPingbackInfo(Entry entry)
 {
     return(Pass(() => dasBlogSettings.SiteConfiguration.EnableAutoPingback, () => opts.EnableAutoPingBack) && entry.IsPublic
                         ? new PingbackInfo(
                Pass(() => dasBlogSettings.GetPermaLinkUrl(entry.EntryId), () => SettingsUtils.GetPermaLinkUrl(entry.EntryId, opts.Root)),
                entry.Title,
                entry.Description,
                Pass(() => dasBlogSettings.SiteConfiguration.Title, () => opts.Title))
                         : null);
 }
Exemplo n.º 4
0
        public EntryCollection SearchEntries(string searchString, string acceptLanguageHeader)
        {
            var searchWords = GetSearchWords(searchString);

            var entries = dataService.GetEntriesForDay(DateTime.MaxValue.AddDays(-2),
                                                       Pass(() => dasBlogSettings.GetConfiguredTimeZone(), () => SettingsUtils.GetConfiguredTimeZone(opts.AdjustDisplayTimeZone, opts.DisplayTimeZoneIndex)),
                                                       acceptLanguageHeader,
                                                       int.MaxValue,
                                                       int.MaxValue,
                                                       null);

            // no search term provided, return all the results
            if (searchWords.Count == 0)
            {
                return(entries);
            }

            EntryCollection matchEntries = new EntryCollection();

            foreach (Entry entry in entries)
            {
                string entryTitle       = entry.Title;
                string entryDescription = entry.Description;
                string entryContent     = entry.Content;

                foreach (string searchWord in searchWords)
                {
                    if (entryTitle != null)
                    {
                        if (searchEntryForWord(entryTitle, searchWord))
                        {
                            if (!matchEntries.Contains(entry))
                            {
                                matchEntries.Add(entry);
                            }
                            continue;
                        }
                    }
                    if (entryDescription != null)
                    {
                        if (searchEntryForWord(entryDescription, searchWord))
                        {
                            if (!matchEntries.Contains(entry))
                            {
                                matchEntries.Add(entry);
                            }
                            continue;
                        }
                    }
                    if (entryContent != null)
                    {
                        if (searchEntryForWord(entryContent, searchWord))
                        {
                            if (!matchEntries.Contains(entry))
                            {
                                matchEntries.Add(entry);
                            }
                            continue;
                        }
                    }
                }
            }

            // log the search to the event log

            /*
             *                      ILoggingDataService logService = requestPage.LoggingService;
             *                      string referrer = Request.UrlReferrer != null ? Request.UrlReferrer.AbsoluteUri : Request.ServerVariables["REMOTE_ADDR"];
             *                      logger.LogInformation(
             *                              new EventDataItem(EventCodes.Search, String.Format("{0}", searchString), referrer));
             */

            return(matchEntries);
        }
Exemplo n.º 5
0
 public EntryCollection GetFrontPagePosts(string acceptLanguageHeader)
 {
     return(dataService.GetEntriesForDay(Pass(() => dasBlogSettings.GetContentLookAhead(), () => SettingsUtils.GetContentLookAhead(opts.ContentLookaheadDays), AreStringsEqual)
                                         , Pass(() => dasBlogSettings.GetConfiguredTimeZone(), () => SettingsUtils.GetConfiguredTimeZone(opts.AdjustDisplayTimeZone, opts.DisplayTimeZoneIndex)),
                                         acceptLanguageHeader, Pass(() => dasBlogSettings.SiteConfiguration.FrontPageDayCount, () => opts.FrontPageEntryCount),
                                         Pass(() => dasBlogSettings.SiteConfiguration.FrontPageEntryCount, () => opts.FrontPageEntryCount), string.Empty));
 }