private void Save(HttpListenerRequest request, HttpListenerResponse response, ILog log) { Dictionary <string, string> parameters = request.ParsePostParameters(); if (parameters.ContainsKey("file") && parameters.ContainsKey("content")) { string file = Uri.UnescapeDataString(parameters["file"]); string content = Uri.UnescapeDataString(parameters["content"]); bool result = EditorLoadSaveHelper.SaveFile(_workdir, file, content, log); if (result) { response.WriteString("OK", "text/plain"); } else { response.WriteString("Error", "text/plain"); } } }
private void Preview(HttpListenerRequest request, HttpListenerResponse response) { Dictionary <string, string> parameters = request.ParsePostParameters(); if (parameters.ContainsKey("content")) { string base64content = Uri.UnescapeDataString(parameters["content"]); byte[] contentBytes = Convert.FromBase64String(base64content); string rawContent = Encoding.UTF8.GetString(contentBytes); using (var pipeline = new BookGenPipeline(BookGenPipeline.Preview)) { pipeline.InjectPath(new FsPath(_workdir)); string rendered = pipeline.RenderMarkdown(rawContent); response.WriteString(rendered, "text/html"); } } }