public Task Invoke(HttpContext context) { var path = context.Request.Path.Value.TrimStart('/'); var response = context.Response; if (path == "topics.js") { response.Headers["content-type"] = "text/javascript"; return(response.WriteAsync(_topicJS)); } var topic = _project.FindTopicByUrl(path); if (topic == null) { response.StatusCode = 404; response.Headers["content-type"] = "text/plain"; return(response.WriteAsync("Unknown topic")); } response.Headers["cache-control"] = "no-cache, no-store, must-revalidate"; response.Headers["pragma"] = "no-cache"; response.Headers["expires"] = "0"; var html = GenerateHtml(topic); response.Headers["content-type"] = "text/html"; return(response.WriteAsync(html)); }
public void post_open(OpenFile request) { var url = new Uri(request.topic); var topic = _project.FindTopicByUrl(url.AbsolutePath.TrimStart('/')); if (topic != null) { Process.Start(topic.File); } }
public Task Invoke(IDictionary <string, object> environment) { var path = environment[OwinConstants.RequestPathKey].As <string>().TrimStart('/'); if (path == "topics.js") { return(Task.Factory.StartNew(() => { var response = new OwinHttpResponse(environment); response.WriteContentType("text/javascript"); response.Write(_topicJS); response.Flush(); })); } var topic = _project.FindTopicByUrl(path); if (topic == null) { return(_inner(environment)); } return(Task.Factory.StartNew(() => { var response = new OwinHttpResponse(environment); response.WriteContentType("text/html"); response.AppendHeader(HttpGeneralHeaders.CacheControl, "no-cache, no-store, must-revalidate"); response.AppendHeader(HttpResponseHeaders.Pragma, "no-cache"); response.AppendHeader(HttpResponseHeaders.Expires, "0"); var html = GenerateHtml(topic); response.Write(html); response.Flush(); })); }
public Task Invoke(IDictionary <string, object> environment) { var path = environment[OwinConstants.RequestPathKey].As <string>().TrimStart('/'); if (path == "topics.js") { return(Task.Factory.StartNew(() => { var response = new OwinHttpResponse(environment); response.WriteContentType("text/javascript"); new AssetSettings().Headers.Each((key, func) => response.AppendHeader(key, func())); response.Write(_topicJS); response.Flush(); })); } var topic = _project.FindTopicByUrl(path); if (topic == null) { return(_inner(environment)); } return(Task.Factory.StartNew(() => { var response = new OwinHttpResponse(environment); response.WriteContentType("text/html"); var html = GenerateHtml(topic); response.Write(html); response.Flush(); })); }