Пример #1
0
 public EntryCollection GetFrontPagePosts(string acceptLanguageHeader)
 {
     return(dataService.GetEntriesForDay(SettingsUtils.GetContentLookAhead(opts.ContentLookaheadDays)
                                         , SettingsUtils.GetConfiguredTimeZone(opts.AdjustDisplayTimeZone, opts.DisplayTimeZoneIndex),
                                         acceptLanguageHeader, opts.FrontPageEntryCount,
                                         opts.FrontPageEntryCount, string.Empty));
 }
Пример #2
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);
        }
Пример #3
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));
 }