Example #1
0
        private static string GetMailText(MediaWiki wiki)
        {
            var text = wiki.GetPage(IssuePage, followRedirects: true);

            var issues = new SectionedArticle <Section>(text, 2);
            var sb     = new StringBuilder();

            foreach (var issue in issues)
            {
                var items = GetItems(new SectionedArticle <Section>(issue.Text, 3));
                if (items.Length == 0)
                {
                    continue;
                }

                sb.AppendFormat(@"== '''Сайнпост-дайджест.''' {0} ==

[[Проект:Сайнпост-Дайджест|В этом номере]]:

", StripRefs(GetTitle(issue)));

                foreach (var item in items)
                {
                    sb.AppendFormat("* {0}\n", item);
                }
            }

            if (sb.Length == 0)
            {
                return(null);
            }

            sb.AppendLine("\n'''<small>Сообщение оставлено [[У:Lê Lợi (bot)|ботом]]. Чтобы отписаться, удалите эту страницу из [[Проект:Сайнпост-Дайджест/Подписка|списка рассылки]].</small>''' ~~~~~");
            return(sb.ToString());
        }
Example #2
0
 public NextIssuePreparation(string text)
 {
     _page    = new SectionedArticle <Section>(text, 2);
     Sections = new Preparation(_page.Prefix);
     if (_page.Count > 1)
     {
         NewSections = new Preparation(_page.Last().Text);
     }
 }
Example #3
0
        private IEnumerable <string> GetSubscribers(MediaWiki wiki)
        {
            var text    = wiki.GetPage(SubscribersPage, followRedirects: true);
            var section = new SectionedArticle <Section>(text, 2).Single();

            foreach (var line in section.Text.Split('\n'))
            {
                if (!line.StartsWith("*"))
                {
                    continue;
                }
                yield return(ParserUtils.FindAnyLinks(line).Single());
            }
        }
Example #4
0
        private static IEnumerable <string> GetArticles(SectionedArticle <Section> sections)
        {
            foreach (var section in sections)
            {
                var subSections = new SectionedArticle <Section>(section.Text, sections.Level + 1);
                if (subSections.Select(s => s.Title.TrimEnd().Trim('=').Trim()).Any(title => ResultTitles.Contains(title, StringComparer.InvariantCultureIgnoreCase)))
                {
                    continue;
                }

                foreach (var link in ParserUtils.FindAnyLinks(section.Title))
                {
                    yield return(link);
                }

                if (sections.Level < 3)
                {
                    foreach (var article in GetArticles(subSections))
                    {
                        yield return(article);
                    }
                }
            }
        }