4using System.Threading.Tasks;
20 private readonly Dictionary<string, TaskCompletionSource<string>> renderings =
new Dictionary<string, TaskCompletionSource<string>>();
30 public override bool HandlesSubPaths =>
true;
31 public override bool UserSessions =>
true;
38 if (
string.IsNullOrEmpty(Request.
SubPath))
44 string TokenId = Request.
SubPath[1..];
45 int i = TokenId.IndexOf(
'@');
46 if (i < 0 || !Guid.TryParse(TokenId[..i], out
_))
71 TaskCompletionSource<string> Pending;
75 lock (this.renderings)
77 if (this.renderings.TryGetValue(TokenId, out Pending))
82 Pending =
new TaskCompletionSource<string>();
83 this.renderings[TokenId] = Pending;
90 Result = await Pending.Task;
93 StringBuilder Html =
new StringBuilder();
99 Html.AppendLine(
"<!DOCTYPE html>");
100 Html.AppendLine(
"<html itemscope itemtype=\"http://schema.org/WebPage\">");
101 Html.AppendLine(
"<head>");
102 Html.Append(
"<title>");
104 Html.AppendLine(
"</title>");
105 Html.Append(
"<meta name=\"twitter:title\" content=\"");
107 Html.AppendLine(
"\"/>");
108 Html.Append(
"<meta name=\"og:title\" content=\"");
110 Html.AppendLine(
"\"/>");
111 Html.Append(
"<meta itemprop=\"description\" content=\"");
113 Html.AppendLine(
"\"/>");
114 Html.Append(
"<meta name=\"twitter:description\" content=\"");
116 Html.AppendLine(
"\"/>");
117 Html.Append(
"<meta name=\"og:description\" content=\"");
119 Html.AppendLine(
"\"/>");
120 Html.Append(
"<meta name=\"description\" content=\"");
122 Html.Append(
" Author: ");
124 Html.Append(
", Date: ");
126 Html.AppendLine(
"\"/>");
127 Html.AppendLine(
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>");
128 Html.Append(
"<meta name=\"author\" content=\"");
130 Html.AppendLine(
"\"/>");
131 Html.AppendLine(
"<link rel=\"shortcut icon\" href=\"/favicon.ico\"/>");
132 Html.Append(
"<link rel=\"stylesheet\" href=\"");
134 Html.AppendLine(
"\"/>");
135 Html.AppendLine(
"<script type=\"application/javascript\" src=\"/Events.js\"></script>");
136 Html.AppendLine(
"<script type=\"text/javascript\">");
137 Html.AppendLine(
"function UpdatePresent(Data) { document.getElementById('Present').innerHTML=Data; }");
138 Html.AppendLine(
"</script>");
139 Html.AppendLine(
"</head>");
140 Html.AppendLine(
"<body>");
141 Html.AppendLine(
"<main>");
142 Html.AppendLine(
"<section id='Present'>");
146 Html.AppendLine(
"</section>");
147 Html.AppendLine(
"</main>");
148 Html.AppendLine(
"</body>");
149 Html.AppendLine(
"</html>");
151 Result = Html.ToString();
152 Pending.TrySetResult(Result);
158 Pending.TrySetException(ex);
167 lock (this.renderings)
169 this.renderings.Remove(TokenId);
175 Response.
SetHeader(
"Cache-Control",
"max-age=0, no-cache, no-store");
177 await Response.
Write(Result);
181 internal static async Task UpdatePresent(
string[] TabIDs,
Token Token)
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 class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
The ClientEvents class allows applications to push information asynchronously to web clients connecte...
static Task< int > PushEvent(string[] TabIDs, string Type, object Data)
Puses an event to a set of Tabs, given their Tab IDs.
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.
string Description
Description Markdown for the token.
DateTime Created
When token was created.
CaseInsensitiveString Creator
Creator of token
bool AllowsGET
If the GET method is allowed.
override HttpAuthenticationScheme[] GetAuthenticationSchemes(HttpRequest Request)
Any authentication schemes used to authenticate users before access is granted to the corresponding r...
async Task GET(HttpRequest Request, HttpResponse Response)
Executes the GET method on the resource.
PublicTokenView()
Public token view.
GET Interface for HTTP resources.
ReportFormat
Desired report format