public string Render(string markdown, Route context)
		{
			// convert markdown to html
			// create context
			// 
			throw new NotImplementedException();
		}
Exemple #2
0
		private void Serve(HttpStatusCode statusCode, IDictionary<string, object> environment, Route node)
		{
			var content = _renderingEngine.Render(node.Resource, _context);

			Serve(statusCode, "text/html", content, environment);
		}
		private static Dictionary<string, Route> ScanRootDirectoryForRoutes(string rootDirectoryPath, string rootRequestPath)
		{
			var routes = new Dictionary<string, Route>();
			var mdFiles = new List<string>();
			var cshtmlFiles = new List<string>();

			ScanFolderAndAppendFilesRecursive(rootDirectoryPath, mdFiles, "*.md");
			ScanFolderAndAppendFilesRecursive(rootDirectoryPath, cshtmlFiles, "*.cshtml");

			var mdByPath = mdFiles.ToDictionary(x => GetRelativeRequestPath(x, ".md", rootDirectoryPath, rootRequestPath));
			var cshtmlByPath = cshtmlFiles.ToDictionary(x => GetRelativeRequestPath(x, ".cshtml", rootDirectoryPath, rootRequestPath));

			foreach (var mdPath in mdByPath.Keys)
			{
				var cshtmlPath = cshtmlByPath.Where(x =>
					x.Key.Equals(mdPath, StringComparison.OrdinalIgnoreCase) ||
					mdPath.StartsWith(x.Key + "/", StringComparison.OrdinalIgnoreCase))
					.OrderBy(x => x.Key.Length)
					.Last()
					.Key;

				var node = new Route
				{
					RequestPath = mdPath,
					Resource = new Resource
					{
						Markdown = mdByPath[mdPath],
						Template = cshtmlByPath[cshtmlPath]
					}
				};

				routes.Add(node.RequestPath, node);
			}

			return routes;
		}