4using System.Threading.Tasks;
18 private readonly Dictionary<string, TaskCompletionSource<string>> renderings =
new Dictionary<string, TaskCompletionSource<string>>();
28 public override bool HandlesSubPaths =>
true;
29 public override bool UserSessions =>
true;
36 if (
string.IsNullOrEmpty(Request.
SubPath))
42 string TokenId = Request.
SubPath[1..];
43 int i = TokenId.IndexOf(
'@');
44 if (i < 0 || !Guid.TryParse(TokenId[..i], out
_))
69 TaskCompletionSource<string> Pending;
73 lock (this.renderings)
75 if (this.renderings.TryGetValue(TokenId, out Pending))
80 Pending =
new TaskCompletionSource<string>();
81 this.renderings[TokenId] = Pending;
88 Result = await Pending.Task;
91 StringBuilder Html =
new StringBuilder();
97 Html.AppendLine(
"<!DOCTYPE html>");
98 Html.AppendLine(
"<html itemscope itemtype=\"http://schema.org/WebPage\">");
99 Html.AppendLine(
"<head>");
100 Html.Append(
"<title>");
102 Html.AppendLine(
"</title>");
103 Html.Append(
"<meta name=\"twitter:title\" content=\"");
105 Html.AppendLine(
"\"/>");
106 Html.Append(
"<meta name=\"og:title\" content=\"");
108 Html.AppendLine(
"\"/>");
109 Html.Append(
"<meta itemprop=\"description\" content=\"");
111 Html.AppendLine(
"\"/>");
112 Html.Append(
"<meta name=\"twitter:description\" content=\"");
114 Html.AppendLine(
"\"/>");
115 Html.Append(
"<meta name=\"og:description\" content=\"");
117 Html.AppendLine(
"\"/>");
118 Html.Append(
"<meta name=\"description\" content=\"");
120 Html.Append(
" Author: ");
122 Html.Append(
", Date: ");
124 Html.AppendLine(
"\"/>");
125 Html.AppendLine(
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>");
126 Html.Append(
"<meta name=\"author\" content=\"");
128 Html.AppendLine(
"\"/>");
129 Html.AppendLine(
"<link rel=\"shortcut icon\" href=\"/favicon.ico\"/>");
130 Html.Append(
"<link rel=\"stylesheet\" href=\"");
132 Html.AppendLine(
"\"/>");
133 Html.AppendLine(
"<script type=\"application/javascript\" src=\"/Events.js\"></script>");
134 Html.AppendLine(
"<script type=\"text/javascript\">");
135 Html.AppendLine(
"function UpdatePresent(Data) { document.getElementById('Present').innerHTML=Data; }");
136 Html.AppendLine(
"</script>");
137 Html.AppendLine(
"</head>");
138 Html.AppendLine(
"<body>");
139 Html.AppendLine(
"<main>");
140 Html.AppendLine(
"<section id='Present'>");
144 Html.AppendLine(
"</section>");
145 Html.AppendLine(
"<section id='History'>");
149 Html.AppendLine(
"</section>");
150 Html.AppendLine(
"</main>");
151 Html.AppendLine(
"</body>");
152 Html.AppendLine(
"</html>");
154 Result = Html.ToString();
155 Pending.TrySetResult(Result);
161 Pending.TrySetException(ex);
170 lock (this.renderings)
172 this.renderings.Remove(TokenId);
178 Response.
SetHeader(
"Cache-Control",
"max-age=0, no-cache, no-store");
180 await Response.
Write(Result);
const string DefaultContentType
Default Content-Type for HTML: text/html
Contains a markdown document. This markdown document class supports original markdown,...
static string Encode(string s)
Encodes all special characters in a string so that it can be included in a markdown document without ...
async Task< string > GeneratePlainText()
Generates Plain Text from the markdown text.
static Task< MarkdownDocument > CreateAsync(string MarkdownText, params Type[] TransparentExceptionTypes)
Contains a markdown document. This markdown document class supports original markdown,...
Helps with common XML-related tasks.
static string HtmlValueEncode(string s)
Differs from Encode(String), in that it does not encode the aposotrophe or the quote.
static string Encode(string s)
Encodes a string for use in XML.
static string HtmlAttributeEncode(string s)
Differs from Encode(String), in that it does not encode the aposotrophe.
static ThemeDefinition CurrentTheme
Current theme.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Base class for all HTTP authentication schemes, as defined in RFC-7235: https://datatracker....
Represents an HTTP request.
string SubPath
Sub-path. If a resource is found handling the request, this property contains the trailing sub-path o...
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Task Write(byte[] Data)
Returns binary data in the response.
void SetHeader(string FieldName, string Value)
Sets a custom header field value.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
Marketplace processor, brokering sales of items via tenders and offers defined in smart contracts.
Task< string > GeneratePresentReport()
Generates a present report for the token, if the token is associated with a state-machine,...
bool HasStateMachine
If the token has an associated state-machine.
bool IsPublic
If the token is public.
string FriendlyName
A friendly name for the token.
Task< string > GenerateHistoryReport()
Generates a history report for the token, if the token is associated with a state-machine,...
string Description
Description Markdown for the token.
DateTime Created
When token was created.
CaseInsensitiveString Creator
Creator of token
Public token history view.
override HttpAuthenticationScheme[] GetAuthenticationSchemes(HttpRequest Request)
Any authentication schemes used to authenticate users before access is granted to the corresponding r...
PublicTokenHistoryView()
Public token history view.
bool AllowsGET
If the GET method is allowed.
async Task GET(HttpRequest Request, HttpResponse Response)
Executes the GET method on the resource.
GET Interface for HTTP resources.
ReportFormat
Desired report format