示例#1
0
        private void ConvertAndWritePage(string wikiPath, string wikiUrl, string pageText)
        {
            // actually parse the markdown
            string convertedHtml = convertor.Convert(pageText);

            // and write to the wiki location (write directory tree first if required)
            CreateDirectoryAndParents(Directory.GetParent(wikiPath).FullName);

            // write to the cache
            pageCache.CachePageContents(wikiUrl, convertedHtml);

            // write to file
            System.IO.File.WriteAllText(wikiPath, convertedHtml, Encoding.UTF8);
        }
示例#2
0
        private async Task <Tuple <bool, string> > TryGetPageContents(string siteName, ImmutableWikiPage page)
        {
            IPageCache pageCache = null;
            string     content   = null;

            // TODO: Async-ify
            bool hasCache           = config.TryGetPageCache(siteName, out pageCache);
            bool pageContentsCached = hasCache && pageCache.TryGetContents(page.WikiUrl, out content);

            Tuple <bool, string> results = new Tuple <bool, string>(false, string.Empty);

            if (!pageContentsCached)
            {
                results = await fileReader.TryReadFile(page.WikiPath);
            }

            // cache the contents if they weren't already
            if (hasCache && !pageContentsCached && results.Item1)
            {
                pageCache.CachePageContents(page.WikiUrl, results.Item2);
            }

            return(results);
        }