private List <SearchResult> GetSearchResults(string query) { query = Trim(query); List <SearchResult> results = new List <SearchResult>(); string[] index = SearchHelpers.SearchIndex; foreach (string each in index) { string content = SearchHelpers.GetResourceContents(each); Dictionary <string, string> pageData = SearchHelpers.GetPageAttributes(content, out content); foreach (KeyValuePair <string, string> de in pageData) { content = content.Replace(SearchHelpers.VariableDelimiter + de.Key, de.Value); } if (SearchHelpers.MatchesQuery(query, content)) { SearchResult result = new SearchResult(each, pageData[SearchHelpers.TitleAttribute]); results.Add(result); } } return(results); }
private void Finalize(bool hasResults, string query) { string header = SearchHelpers.GetResourceContents("include/header.html"); if (!string.IsNullOrWhiteSpace(query)) { header = header.Replace(SearchHelpers.VariableDelimiter + SearchHelpers.TitleAttribute, "Search results for " + query); if (hasResults) { header += "<h1>Search results for "" + query + ""</h1>"; } else { header += "<h1>We didn't find anything</h1>"; } } else { header = header.Replace(SearchHelpers.VariableDelimiter + SearchHelpers.TitleAttribute, "Help Index") + "<h1>Help Index</h1>"; } string footer = SearchHelpers.GetResourceContents("include/footer.html"); _html = header + _html + footer; }