コード例 #1
0
        public static void CreateCategoryPages(string projectRoot, string resultDir)
        {
            string template = QwfReader.ReadFileText(projectRoot + "\\layout\\template.html");

            foreach (KeyValuePair <string, Dictionary <string, List <string> > > category in categories)
            {
                string text = "";
                text += "<h1>" + "Category: " + category.Key + "</h2>";
                text += "<p>" + categoryDescriptions[category.Key] + "</p>";
                foreach (KeyValuePair <string, List <string> > section in category.Value)
                {
                    text += "<h2>" + section.Key + "</h2>";
                    for (int i = 0; i < section.Value.Count; i += 2)
                    {
                        text += "<a href=" + section.Value[i] + ">" + section.Value[i + 1] + "</a>" + "<br><br>";
                    }
                }
                string resultHtml = template;
                resultHtml = resultHtml.Replace(";;TITLE;;", "Category: " + category.Key);
                resultHtml = resultHtml.Replace(";;ARTICLE;;", text);
                resultHtml = resultHtml.Replace(";;SIDEBAR_LINKS;;", GetSidebarLinks());
                resultHtml = resultHtml.Replace(";;FOOTER;;", GetFooterText());

                System.IO.File.WriteAllText(resultDir + "\\categories\\" + category.Key + ".html", resultHtml);
            }
        }
コード例 #2
0
        public static string ProcessArticle(string path, string projectRoot)
        {
            string result = QwfReader.ReadFileText(projectRoot + "\\layout\\template.html");
            // Get document info
            var           lines          = QwfReader.GetFileTextLines(path);
            List <string> qwiLines       = new List <string>();
            List <string> articleLines   = new List <string>();
            bool          readingArticle = false;

            foreach (string line in lines)
            {
                if (line == "==")
                {
                    readingArticle = true;
                    continue;
                }
                if (readingArticle)
                {
                    articleLines.Add(line);
                }
                else
                {
                    qwiLines.Add(line);
                }
            }
            var    qwi     = QwfReader.ReadQwi(qwiLines);
            string article = QwfReader.MDToHTML(articleLines);

            result = result.Replace(";;TITLE;;", qwi["Title"]);
            result = result.Replace(";;ARTICLE;;", article);
            result = result.Replace(";;SIDEBAR_LINKS;;", GetSidebarLinks());
            result = result.Replace(";;FOOTER;;", GetFooterText());
            return(result);
        }
コード例 #3
0
        public static string GenerateHomepage(string projectRoot, string resultDir, Dictionary <string, string> siteSettings)
        {
            string        result       = QwfReader.ReadFileText(projectRoot + "\\layout\\template.html");
            List <string> articleLines = new List <string>()
            {
                "# Welcome to the Qudical Developer Wiki!",
                "Here you'll _(hopefully)_ find some useful information regarding the technical side of Qudical projects.",
                "# Categories:"
            };
            string article = QwfReader.MDToHTML(articleLines);

            foreach (KeyValuePair <string, Dictionary <string, List <string> > > category in categories)
            {
                string path = "\\qudicalwiki\\categories\\" + category.Key + ".html";
                article += "<h2><a href=\"" + path + "\">" + category.Key + "</a></h2>";
                article += $"<p>{categoryDescriptions[category.Key]}</p>";
            }
            result = result.Replace(";;TITLE;;", siteSettings["SiteName"]);
            result = result.Replace(";;ARTICLE;;", article);
            result = result.Replace(";;SIDEBAR_LINKS;;", GetSidebarLinks());
            result = result.Replace(";;FOOTER;;", GetFooterText());
            return(result);
        }