public string UpdateRepo()
        {
            FullPathCleaner cleaner    = new FullPathCleaner(s => Server.MapPath(s));
            string          repoFolder = cleaner.CleanPath(Config.GetConfigValue(CommonConsts.AppSettings.MarkdownSourceFolder));

            new FaintingGoat(this.Config, repoFolder).Update();


            return("Updating");
        }
        private MarkdownPageModel MakeMarkDownViewModel(string mdroute)
        {
            FullPathCleaner cleaner   = new FullPathCleaner(s => Server.MapPath(s));
            string          localPath = this.PathHelper.ConvertMdUriToLocalPath(mdroute, s => cleaner.CleanPath(s));

            if (!System.IO.File.Exists(localPath))
            {
                throw new FileNotFoundException(string.Format("Markdown file not found at [{0}]", localPath));
            }

            string md = this.ContentRepo.GetContentFor(new Uri(localPath));

            MarkdownPageModel pm = new MarkdownPageModel {
                FaintingGoatWebTitle = this.GetTitle(),
                HtmlToRender         = this.MarkdownToHtml.ConvertToHtml(md),
                HeaderHtml           = this.GetHeaderHtml(),
                FooterHtml           = this.GetFooterHtml()
            };

            return(pm);
        }
Exemplo n.º 3
0
        private void UpdateGitRepo(IKernel kernel)
        {
            if (kernel == null)
            {
                throw new ArgumentNullException("kernel");
            }

            IConfig config = kernel.Get <IConfig>();
            // first check to see if we should automaticall update or not

            bool autoUpadate = bool.Parse(config.GetConfigValue(CommonConsts.AppSettings.GitAutoUpdateOnAppStart, false, "true"));

            if (autoUpadate)
            {
                FullPathCleaner cleaner  = new FullPathCleaner(s => Server.MapPath(s));
                string          repoPath = cleaner.CleanPath(
                    config.GetConfigValue(
                        CommonConsts.AppSettings.MarkdownSourceFolder));

                new FaintingGoat(kernel.Get <IConfig>(), repoPath).Update();
            }
        }
        protected string GetHtmlFromFirstFound(IEnumerable <string> filesToCheck)
        {
            if (filesToCheck == null)
            {
                throw new ArgumentNullException("filesToCheck");
            }
            string result = null;

            List <string> filesToTryRelative = new List <string>(filesToCheck);
            List <string> filesToTryAbsolute = new List <string>();

            FullPathCleaner cleaner = new FullPathCleaner(s => Server.MapPath(s));

            filesToTryRelative.ForEach(file => {
                filesToTryAbsolute.Add(this.PathHelper.ConvertMdUriToLocalPath(file, (s) => cleaner.CleanPath(s)));
            });


            string currentFile = null;

            foreach (var nf in filesToTryAbsolute)
            {
                if (System.IO.File.Exists(nf))
                {
                    currentFile = nf;
                    break;
                }
            }

            if (currentFile != null)
            {
                string md = this.ContentRepo.GetContentFor(new Uri(currentFile));
                result = this.MarkdownToHtml.ConvertToHtml(md);
            }

            return(result);
        }
        protected string GetDefaultDocumentFullLocalPath()
        {
            IList <string> defaultDocListConfig = this.Config.GetList(CommonConsts.AppSettings.DefaultDocList, defaultValue: CommonConsts.AppSettings.DefaultValues.DefaultDocList);

            string          result  = null;
            FullPathCleaner cleaner = new FullPathCleaner(s => Server.MapPath(s));

            for (int i = 0; i < defaultDocListConfig.Count; i++)
            {
                string fileName = defaultDocListConfig[i];

                string fileNameLocalpath = this.PathHelper.ConvertMdUriToLocalPath(
                    fileName,
                    s => cleaner.CleanPath(s));

                if (System.IO.File.Exists(fileNameLocalpath))
                {
                    result = fileNameLocalpath;
                    break;
                }
            }

            return(result);
        }