添加项目文件。
This commit is contained in:
15
TightWiki.Engine.Library/Interfaces/ICommentHandler.cs
Normal file
15
TightWiki.Engine.Library/Interfaces/ICommentHandler.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles wiki comments. These are generally removed from the result.
|
||||
/// </summary>
|
||||
public interface ICommentHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles a wiki comment.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
/// <param name="text">The comment text</param>
|
||||
public HandlerResult Handle(ITightEngineState state, string text);
|
||||
}
|
||||
}
|
||||
14
TightWiki.Engine.Library/Interfaces/ICompletionHandler.cs
Normal file
14
TightWiki.Engine.Library/Interfaces/ICompletionHandler.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles wiki completion events.
|
||||
/// </summary>
|
||||
public interface ICompletionHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles wiki completion events. Is called when the wiki processing competes for a given page.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
public void Complete(ITightEngineState state);
|
||||
}
|
||||
}
|
||||
16
TightWiki.Engine.Library/Interfaces/IEmojiHandler.cs
Normal file
16
TightWiki.Engine.Library/Interfaces/IEmojiHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles wiki emojis.
|
||||
/// </summary>
|
||||
public interface IEmojiHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles an emoji instruction.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
/// <param name="key">The lookup key for the given emoji.</param>
|
||||
/// <param name="scale">The desired 1-100 scale factor for the emoji.</param>
|
||||
public HandlerResult Handle(ITightEngineState state, string key, int scale);
|
||||
}
|
||||
}
|
||||
16
TightWiki.Engine.Library/Interfaces/IExceptionHandler.cs
Normal file
16
TightWiki.Engine.Library/Interfaces/IExceptionHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles exceptions thrown by the wiki engine.
|
||||
/// </summary>
|
||||
public interface IExceptionHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when an exception is thrown by the wiki engine.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
/// <param name="ex">Optional exception, in the case that this was an actual exception.</param>
|
||||
/// <param name="customText">Text that accompanies the exception.</param>
|
||||
public void Log(ITightEngineState state, Exception? ex, string customText);
|
||||
}
|
||||
}
|
||||
18
TightWiki.Engine.Library/Interfaces/IExternalLinkHandler.cs
Normal file
18
TightWiki.Engine.Library/Interfaces/IExternalLinkHandler.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles links the wiki to another site.
|
||||
/// </summary>
|
||||
public interface IExternalLinkHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles an internal wiki link.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
/// <param name="link">The address of the external site being linked to.</param>
|
||||
/// <param name="text">The text which should be show in the absence of an image.</param>
|
||||
/// <param name="image">The image that should be shown.</param>
|
||||
/// <param name="imageScale">The 0-100 image scale factor for the given image.</param>
|
||||
public HandlerResult Handle(ITightEngineState state, string link, string? text, string? image);
|
||||
}
|
||||
}
|
||||
24
TightWiki.Engine.Library/Interfaces/IFunctionHandler.cs
Normal file
24
TightWiki.Engine.Library/Interfaces/IFunctionHandler.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using TightWiki.Engine.Function;
|
||||
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Base function handler for standard, post-processing, scoped and processing-instruction functions.
|
||||
/// </summary>
|
||||
public interface IFunctionHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a collection of function prototypes.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public FunctionPrototypeCollection Prototypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called to handle function calls when proper prototypes are matched.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
/// <param name="function">The parsed function call and all its parameters and their values.</param>
|
||||
/// <param name="scopeBody">For scope functions, this is the text that the function is designed to affect.</param>
|
||||
public HandlerResult Handle(ITightEngineState state, FunctionCall function, string? scopeBody = null);
|
||||
}
|
||||
}
|
||||
17
TightWiki.Engine.Library/Interfaces/IHeadingHandler.cs
Normal file
17
TightWiki.Engine.Library/Interfaces/IHeadingHandler.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles wiki headings. These are automatically added to the table of contents.
|
||||
/// </summary>
|
||||
public interface IHeadingHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles wiki headings. These are automatically added to the table of contents.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
/// <param name="depth">The size of the header, also used for table of table of contents indentation.</param>
|
||||
/// <param name="link">The self link reference.</param>
|
||||
/// <param name="text">The text for the self link.</param>
|
||||
public HandlerResult Handle(ITightEngineState state, int depth, string link, string text);
|
||||
}
|
||||
}
|
||||
21
TightWiki.Engine.Library/Interfaces/IInternalLinkHandler.cs
Normal file
21
TightWiki.Engine.Library/Interfaces/IInternalLinkHandler.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using TightWiki.Library;
|
||||
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles links from one wiki page to another.
|
||||
/// </summary>
|
||||
public interface IInternalLinkHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles an internal wiki link.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
/// <param name="pageNavigation">The navigation for the linked page.</param>
|
||||
/// <param name="pageName">The name of the page being linked to.</param>
|
||||
/// <param name="linkText">The text which should be show in the absence of an image.</param>
|
||||
/// <param name="image">The image that should be shown.</param>
|
||||
/// <param name="imageScale">The 0-100 image scale factor for the given image.</param>
|
||||
public HandlerResult Handle(ITightEngineState state, NamespaceNavigation pageNavigation, string pageName, string linkText, string? image, int imageScale);
|
||||
}
|
||||
}
|
||||
16
TightWiki.Engine.Library/Interfaces/IMarkupHandler.cs
Normal file
16
TightWiki.Engine.Library/Interfaces/IMarkupHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles basic markup/style instructions like bole, italic, underline, etc.
|
||||
/// </summary>
|
||||
public interface IMarkupHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles basic markup instructions like bole, italic, underline, etc.
|
||||
/// </summary>
|
||||
/// <param name="state">Reference to the wiki state object</param>
|
||||
/// <param name="sequence">The sequence of symbols that were found to denotate this markup instruction,</param>
|
||||
/// <param name="scopeBody">The body of text to apply the style to.</param>
|
||||
public HandlerResult Handle(ITightEngineState state, char sequence, string scopeBody);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles post-processing function calls.
|
||||
/// </summary>
|
||||
public interface IPostProcessingFunctionHandler : IFunctionHandler
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles processing-instruction function calls.
|
||||
/// </summary>
|
||||
public interface IProcessingInstructionFunctionHandler : IFunctionHandler
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles scope function calls.
|
||||
/// </summary>
|
||||
public interface IScopeFunctionHandler : IFunctionHandler
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles standard function calls.
|
||||
/// </summary>
|
||||
public interface IStandardFunctionHandler : IFunctionHandler
|
||||
{
|
||||
}
|
||||
}
|
||||
24
TightWiki.Engine.Library/Interfaces/ITightEngine.cs
Normal file
24
TightWiki.Engine.Library/Interfaces/ITightEngine.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using TightWiki.Library.Interfaces;
|
||||
using static TightWiki.Engine.Library.Constants;
|
||||
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
|
||||
public interface ITightEngine
|
||||
{
|
||||
IScopeFunctionHandler ScopeFunctionHandler { get; }
|
||||
IStandardFunctionHandler StandardFunctionHandler { get; }
|
||||
IProcessingInstructionFunctionHandler ProcessingInstructionFunctionHandler { get; }
|
||||
IPostProcessingFunctionHandler PostProcessingFunctionHandler { get; }
|
||||
IMarkupHandler MarkupHandler { get; }
|
||||
IHeadingHandler HeadingHandler { get; }
|
||||
ICommentHandler CommentHandler { get; }
|
||||
IEmojiHandler EmojiHandler { get; }
|
||||
IExternalLinkHandler ExternalLinkHandler { get; }
|
||||
IInternalLinkHandler InternalLinkHandler { get; }
|
||||
IExceptionHandler ExceptionHandler { get; }
|
||||
ICompletionHandler CompletionHandler { get; }
|
||||
ITightEngineState Transform(ISessionState? sessionState, IPage page, int? revision = null, WikiMatchType[]? omitMatches = null);
|
||||
//ITightEngineState TransformChild(ITightEngineState parent, IPage page, int? revision = null);
|
||||
}
|
||||
}
|
||||
75
TightWiki.Engine.Library/Interfaces/ITightEngineState.cs
Normal file
75
TightWiki.Engine.Library/Interfaces/ITightEngineState.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using TightWiki.Library.Interfaces;
|
||||
using static TightWiki.Engine.Library.Constants;
|
||||
|
||||
namespace TightWiki.Engine.Library.Interfaces
|
||||
{
|
||||
public interface ITightEngineState
|
||||
{
|
||||
#region Parameters.
|
||||
|
||||
ISessionState? Session { get; }
|
||||
IQueryCollection QueryString { get; }
|
||||
|
||||
ITightEngine Engine { get; }
|
||||
IPage Page { get; }
|
||||
int? Revision { get; }
|
||||
public HashSet<WikiMatchType> OmitMatches { get; }
|
||||
public int NestDepth { get; } //Used for recursion.
|
||||
|
||||
#endregion
|
||||
|
||||
#region State.
|
||||
|
||||
/// <summary>
|
||||
/// Custom page title set by a call to @@Title("...")
|
||||
/// </summary>
|
||||
public string? PageTitle { get; set; }
|
||||
|
||||
Dictionary<string, string> Variables { get; }
|
||||
Dictionary<string, string> Snippets { get; }
|
||||
List<string> Tags { get; set; }
|
||||
List<string> ProcessingInstructions { get; }
|
||||
List<PageReference> OutgoingLinks { get; }
|
||||
List<TableOfContentsTag> TableOfContents { get; }
|
||||
List<string> Headers { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Results.
|
||||
|
||||
string HtmlResult { get; }
|
||||
TimeSpan ProcessingTime { get; }
|
||||
int ErrorCount { get; }
|
||||
int MatchCount { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Used to store values for handlers that needs to survive only a single wiki processing session.
|
||||
/// </summary>
|
||||
public void SetStateValue<T>(string key, T value);
|
||||
|
||||
/// <summary>
|
||||
/// Used to get values for handlers that needs to survive only a single wiki processing session.
|
||||
/// </summary>
|
||||
public bool TryGetStateValue<T>(string key, [MaybeNullWhen(false)] out T? outValue);
|
||||
|
||||
/// <summary>
|
||||
/// Used to get values for handlers that needs to survive only a single wiki processing session.
|
||||
/// </summary>
|
||||
public T GetStateValue<T>(string key, T defaultValue);
|
||||
|
||||
string GetNextQueryToken();
|
||||
|
||||
/// <summary>
|
||||
/// Transforms "included" wiki pages, for example if a wiki function
|
||||
/// injected additional wiki markup, this 'could' be processed separately.
|
||||
/// </summary>
|
||||
/// <param name="page">The child page to process</param>
|
||||
/// <param name="revision">The optional revision of the child page to process</param>
|
||||
/// <returns></returns>
|
||||
ITightEngineState TransformChild(IPage page, int? revision = null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user