Exemple #1
0
        public bool Has(ViewType view)
        {
            switch (view)
            {
            case ViewType.Toc:
                return(true);

            case ViewType.Index:
                try
                {
                    return(DataFolder.GetFileIgnoreCase(LemmataTxt).Length != 0);    // lemmata.txt can be empty
                }
                catch (Exception)
                {
                    return(false);
                }

            case ViewType.Search:
                return(true);

            case ViewType.Images:
                return(true);
            }

            return(false);
        }
Exemple #2
0
        public Task <IEnumerable <ICategoryItem> > QueryCategories()
        {
            FileInfo lemmataTxt = DataFolder.GetFileIgnoreCase(LemmataTxt);

            if (lemmataTxt.Exists)
            {
                return(Task.FromResult(IndexUtil.LoadCategories(lemmataTxt, Ini).AsEnumerable <ICategoryItem>()));
            }

            return(Task.FromResult(Enumerable.Empty <ICategoryItem>()));
        }
Exemple #3
0
        public Task <IEnumerable <IIndexItem> > QueryIndex(string pattern, IEnumerable <ICategoryItem> categories, int page)
        {
            FileInfo lemmataTxt = DataFolder.GetFileIgnoreCase(LemmataTxt);

            if (lemmataTxt.Exists)
            {
                return(Task.FromResult(IndexUtil.LoadLemmata(lemmataTxt, pattern, categories, page)
                                       .AsEnumerable <IIndexItem>()));
            }

            return(Task.FromResult(Enumerable.Empty <IIndexItem>()));
        }
Exemple #4
0
        public Task <bool> Html(int pagenumber, DirectoryInfo folder, string highlight)
        {
            string filename = Path.Combine(folder.FullName,
                                           Path.ChangeExtension(pagenumber.ToString(), html.ToString()));
            ISet <int> highlightedOffsets = string.IsNullOrWhiteSpace(highlight)
                ? new HashSet <int>()
                : SearchUtil.HighlightedOffsets(pagenumber, highlight, DataFolder);

            using (HtmlWriter writer = new HtmlWriter(new FileStream(filename, FileMode.Create, FileAccess.Write),
                                                      pagenumber, highlightedOffsets))
            {
                TocItem            item  = FindItem(pagenumber);
                IEnumerable <Page> pages = PageUtil.LoadPages(DataFolder.GetFileIgnoreCase(TextDki), item.Pagenumber,
                                                              item.Pagecount);
                foreach (Page page in pages)
                {
                    PageUtil.Parse(page, writer);
                }

                DumpImages(writer.ImageIdsToExtensions, folder);
            }

            return(Task.FromResult(true));
        }