コード例 #1
0
        private async Task <string> GetPostContentAsync(News news)
        {
            var postContent = await _contextHelper.ReplacePlaceholdersAsync(news.ShortText);

            if (!string.IsNullOrEmpty(news.AddText))
            {
                var addText = "<div class=\"ipsSpoiler\" data-ipsspoiler=\"\">" +
                              "<div class=\"ipsSpoiler_header\">" +
                              "<span>Скрытый текст</span>" +
                              "</div>" +
                              "<div class=\"ipsSpoiler_contents\">" +
                              $"{await _contextHelper.ReplacePlaceholdersAsync(news.AddText)}" +
                              "</div>" +
                              "</div>";

                postContent += addText;
            }

            postContent = postContent.Replace("<ul>", "<ul class=\"bbc\">");
            postContent = postContent.Replace("<ol>", "<ul class=\"bbcol decimal\">");
            postContent = postContent.Replace("</ol>", "</ul>");
            postContent = BlockQuoteRegex.Replace(postContent,
                                                  "<blockquote class=\"bioQuote\">$1</blockquote>");

            return(postContent);
        }
コード例 #2
0
        public async Task <string> GetPageDescription()
        {
            var description = await GetDescription();

            if (!string.IsNullOrEmpty(description))
            {
                description = await ContentHelper.ReplacePlaceholdersAsync(description);
            }

            return(ContentHelper.StripTags(description));
        }
コード例 #3
0
        public async Task <IActionResult> Index(string query, string block)
        {
            var viewModel = new SearchViewModel(ViewModelConfig, query);

            if (!string.IsNullOrEmpty(query))
            {
                var hasBlock = !string.IsNullOrEmpty(block);
                var limit    = hasBlock ? 0 : 5;
                if (!hasBlock || block == "games")
                {
                    var games = await SearchEntities <Game>(query, limit);

                    var gamesCount = await CountEntities <Game>(query);

                    var searchBlock = CreateSearchBlock("Игры", Url.Search().BlockUrl("games", query), gamesCount,
                                                        games, x => x.Title,
                                                        x => Url.Base().PublicUrl(x),
                                                        x => _contentHelper.ReplacePlaceholdersAsync(x.Desc));
                    viewModel.AddBlock(await searchBlock);
                }

                if (!hasBlock || block == "news")
                {
                    var news = await SearchEntities <News>(query, limit);

                    var newsCount = await CountEntities <News>(query);

                    var searchBlock = CreateSearchBlock("Новости", Url.Search().BlockUrl("news", query), newsCount,
                                                        news, x => x.Title,
                                                        x => Url.News().PublicUrl(x),
                                                        x => _contentHelper.ReplacePlaceholdersAsync(x.ShortText));
                    viewModel.AddBlock(await searchBlock);
                }

                if (!hasBlock || block == "articles")
                {
                    var articles = await SearchEntities <Article>(query, limit);

                    var articlesCount = await CountEntities <Article>(query);

                    var searchBlock = CreateSearchBlock("Статьи", Url.Search().BlockUrl("articles", query),
                                                        articlesCount,
                                                        articles, x => x.Title,
                                                        x => Url.Articles().PublicUrl(x),
                                                        x => _contentHelper.ReplacePlaceholdersAsync(x.Announce));
                    viewModel.AddBlock(await searchBlock);
                }

                if (!hasBlock || block == "articlesCats")
                {
                    var articlesCats = await SearchEntities <ArticleCat>(query, limit);

                    var articlesCatsCount = await CountEntities <ArticleCat>(query);

                    var searchBlock = CreateSearchBlock("Категории статей",
                                                        Url.Search().BlockUrl("articlesCats", query),
                                                        articlesCatsCount,
                                                        articlesCats, x => x.Title,
                                                        x => Url.Articles().CatPublicUrl(x),
                                                        x => _contentHelper.ReplacePlaceholdersAsync(x.Descr));
                    viewModel.AddBlock(await searchBlock);
                }

                if (!hasBlock || block == "files")
                {
                    var files = await SearchEntities <File>(query, limit);

                    var filesCount = await CountEntities <File>(query);

                    var searchBlock = CreateSearchBlock("Файлы", Url.Search().BlockUrl("files", query),
                                                        filesCount,
                                                        files, x => x.Title,
                                                        x => Url.Files().PublicUrl(x),
                                                        x => _contentHelper.ReplacePlaceholdersAsync(x.Announce));
                    viewModel.AddBlock(await searchBlock);
                }

                if (!hasBlock || block == "filesCat")
                {
                    var fileCats = await SearchEntities <FileCat>(query, limit);

                    var fileCatsCount = await CountEntities <FileCat>(query);

                    var searchBlock = CreateSearchBlock("Категории файлов",
                                                        Url.Search().BlockUrl("filesCat", query),
                                                        fileCatsCount,
                                                        fileCats, x => x.Title,
                                                        x => Url.Files().CatPublicUrl(x),
                                                        x => _contentHelper.ReplacePlaceholdersAsync(x.Descr));
                    viewModel.AddBlock(await searchBlock);
                }

                if (!hasBlock || block == "galleryCats")
                {
                    var galleryCats = await SearchEntities <GalleryCat>(query, limit);

                    var galleryCatsCount = await CountEntities <GalleryCat>(query);

                    var searchBlock = CreateSearchBlock("Категории картинок",
                                                        Url.Search().BlockUrl("galleryCats", query),
                                                        galleryCatsCount,
                                                        galleryCats, x => x.Title,
                                                        x => Url.Gallery().CatPublicUrl(x),
                                                        x => _contentHelper.ReplacePlaceholdersAsync(x.Desc));
                    viewModel.AddBlock(await searchBlock);
                }
            }
            return(View(viewModel));
        }