예제 #1
0
        private string Serve(string resource, string contentType)
        {
            if (resource == "/")
            {
                resource    = "/default.html";
                contentType = "text/html";
            }

            string header  = "";
            string content = "";
            string footer  = "";

            content = GetResourceContents(resource);

            if (contentType == "text/html")
            {
                header = GetResourceContents("/include/header.html");

                Dictionary <string, string> pageData = SearchHelpers.GetPageAttributes(content, out content);

                foreach (KeyValuePair <string, string> each in pageData)
                {
                    header  = header.Replace(SearchHelpers.VariableDelimiter + each.Key, each.Value);
                    content = content.Replace(SearchHelpers.VariableDelimiter + each.Key, each.Value);
                }

                footer = GetResourceContents("/include/footer.html");
            }

            return(header + content + footer);
        }
예제 #2
0
        private void ServeIndex(HttpProcessor p, string url)
        {
            List <SearchResult> results = new List <SearchResult>();

            string[] index = SearchHelpers.SearchIndex;

            foreach (string each in index)
            {
                string contents = SearchHelpers.GetResourceContents(each);

                Dictionary <string, string> meta = SearchHelpers.GetPageAttributes(contents, out contents);
                SearchResult result = new SearchResult(each, meta[SearchHelpers.TitleAttribute]);
                results.Add(result);
            }

            HtmlGenerator html = new HtmlGenerator(results, "");

            p.WriteSuccessHeaders(200, "text/html", html.HTML);
        }