4using System.Threading.Tasks;
25 : base(
"/" + NodeName)
27 this.nodeName = NodeName;
30 public override bool HandlesSubPaths =>
true;
31 public override bool UserSessions =>
true;
34 private static async Task<PubSubContent.Content> GetContent(
PubSubItem Item)
36 if (!(Item.
Tag is PubSubContent.Content Content))
38 XmlDocument Xml =
new XmlDocument()
40 PreserveWhitespace =
true
44 Content = await PubSubContent.Content.Deserialize(Xml.DocumentElement, Item.
Publisher,
45 new PubSubContent.NodeReference[] { new PubSubContent.NodeReference(Item.Node, Item.Service) }, Item.
ItemId);
62 if (
string.IsNullOrEmpty(ItemId) || ItemId ==
"/")
79 string ItemId2 = HttpUtility.UrlDecode(ItemId);
81 if (ItemId != ItemId2)
100 Settings = PubSubContent.MarkdownContent.GetMarkdownSettings(v,
true);
101 Markdown = File.ReadAllText(FileName);
106 await Response.
Write(HTML);
109 public static async Task<string> GetItemTitle(PubSubContent.Content Content,
PubSubItem Item)
121 if (!
string.IsNullOrEmpty(s))
130 s = Content.ObjectOrItemId ??
string.Empty;
131 int i = s.LastIndexOf(
'/');
133 s = s.Substring(i + 1);
135 StringBuilder sb =
new StringBuilder();
138 foreach (
char ch
in s)
147 sb.Append(
char.ToUpper(ch));
151 sb.Append(
char.ToLower(ch));
154 return sb.ToString().Trim();
157 public static async Task<string> GetItemDescription(PubSubContent.Content Content,
PubSubItem Item)
169 if (!
string.IsNullOrEmpty(s))
178 return "Item published on node " + Item?.
Node;
181 public static async Task<string> GetItemDate(PubSubContent.Content Content,
PubSubItem Item)
193 if (!
string.IsNullOrEmpty(s))
208 public static async Task<string> GetItemAuthor(PubSubContent.Content Content,
PubSubItem Item)
220 if (!
string.IsNullOrEmpty(s))
234 Tuple<PubSubItem[], bool, string> T = GetItemsAsync(Node, From, MaxCount).Result;
242 public static async Task<Tuple<PubSubItem[], bool, string>> GetItemsAsync(
CaseInsensitiveString Node,
string From,
int MaxCount)
246 return new Tuple<PubSubItem[], bool, string>(
null,
false,
string.Empty);
248 Tuple<PubSubItem[], bool, string> Result = await
XmppServerModule.PubSub.LoadItems(
string.Empty, Node, From, MaxCount)
252 await GetContent(Item);
const string DefaultContentType
Default Content-Type for HTML: text/html
Class that can be used to encapsulate Markdown to be returned from a Web Service, bypassing any encod...
Contains a markdown document. This markdown document class supports original markdown,...
async Task< string > GenerateHTML()
Generates HTML from the markdown text.
static Task< MarkdownDocument > CreateAsync(string MarkdownText, params Type[] TransparentExceptionTypes)
Contains a markdown document. This markdown document class supports original markdown,...
Contains settings that the Markdown parser uses to customize its behavior.
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
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.
Static class managing the runtime environment of the IoT Gateway.
static string RootFolder
Web root folder.
Represents an HTTP request.
HttpRequestHeader Header
Request header.
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 Write(byte[] Data)
Returns binary data in the response.
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...
Contains information about one XMPP address.
static readonly XmppAddress Empty
Empty address.
Represents a case-insensitive string.
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
bool StartsWith(CaseInsensitiveString value)
Determines whether the beginning of this string instance matches the specified string.
CaseInsensitiveString Substring(int startIndex, int length)
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Contains information about a variable.
async Task< PubSubNode > GetNodeAsync(CaseInsensitiveString Service, CaseInsensitiveString NodeName, NodeAccessModel? AutoCreateAccess, XmppAddress From, CaseInsensitiveString Domain)
Gets a pubsub node.
Defines a published item.
CaseInsensitiveString Node
Name of node.
CaseInsensitiveString Publisher
Publisher of content.
object Tag
Allows the caller to tag the object with an arbitrary value.
DateTime Created
When item was created.
CaseInsensitiveString ItemId
Item ID.
Defines a node on which items can be published.
bool PublishOnWeb
If the items published to the node should be available on the web or not.
async Task GET(HttpRequest Request, HttpResponse Response)
Executes the GET method on the resource.
bool AllowsGET
If the GET method is allowed.
Service Module hosting the XMPP broker and its components.
GET Interface for HTTP resources.