Tavenem.Wiki.Blazor.Client 0.1.1-preview

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
This is a prerelease version of Tavenem.Wiki.Blazor.Client.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Tavenem.Wiki.Blazor.Client --version 0.1.1-preview
NuGet\Install-Package Tavenem.Wiki.Blazor.Client -Version 0.1.1-preview
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tavenem.Wiki.Blazor.Client" Version="0.1.1-preview" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tavenem.Wiki.Blazor.Client --version 0.1.1-preview
#r "nuget: Tavenem.Wiki.Blazor.Client, 0.1.1-preview"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tavenem.Wiki.Blazor.Client as a Cake Addin
#addin nuget:?package=Tavenem.Wiki.Blazor.Client&version=0.1.1-preview&prerelease

// Install Tavenem.Wiki.Blazor.Client as a Cake Tool
#tool nuget:?package=Tavenem.Wiki.Blazor.Client&version=0.1.1-preview&prerelease

build NuGet downloads

Tavenem.Wiki.Blazor

This is the "reference" implementation of Tavenem.Wiki for Blazor. It is comprised of a pair of Razor class libraries: a Client library which can be included in a Blazor client app, and a Server library which can be included in an ASP.NET Core host project. Working together, this hosted Blazor project will function as a complete wiki.

It is also possible to use only one of the libraries, and provide your own implementation for the other. The server library, in particular, is very bare-bones. Its source code could easily be adapted to integrate more closely with your main server project, or reimagined as a cloud-native set of functions and APIs, or replaced by any number of other implementations.

Installation

Tavenem.Wiki.Blazor is available as a NuGet package.

Configuration

In order to use Tavenem.Wiki.Blazor, the following steps should be taken:

The Client App

  1. Call one of the overloads of AddTavenemWikiClient on an IServiceCollection instance in your Program.cs file.

    For example:

    var builder = WebAssemblyHostBuilder.CreateDefault(args);
    builder.Services.AddTavenemWikiClient();
    

    AddTavenemWikiClient has two optional parameters.

    The first parameter is either an instance of WikiOptions or a function which provides one. This interface allows you to configure the wiki's core features. See the README for Tavenem.Wiki for more information.

    The second parameter is either an instance of IWikiBlazorClientOptions or a function which provides one. This interface allows you to configure the wiki's Blazor implementation features, and includes the following properties:

    • AppBar: The type of an optional component (typically containing an AppBar from the Tavenem Blazor Framework) which will appear at the top of wiki pages.

      The type must implement IComponent.

    • CompactLayout: The type of layout used when requesting a compact version of a wiki page. Wiki pages will be nested within this layout.

      If omitted, a default layout will be used.

    • CompactRouteHostPart: The host part which will be recognized as indicating a request for the compact version of the wiki.

      If left empty the compact view cannot be reached at a particular host path.

    • CompactRouteHostPosition: The position (zero-based) within the parts of the host string which will be examined to determine a request for the compact version of the wiki.

      If left null position zero will be assumed.

      Only used when CompactRouteHostPart is non-empty.

    • CompactRoutePort: The port which will be recognized as indicating a request for the compact version of the wiki.

      If left null the compact view cannot be reached at a particular port.

    • LoginPath: The relative path to the site's login page.

      For security reasons, only a local path is permitted. If your authentication mechanisms are handled externally, this should point to a local page which redirects to that source (either automatically or via interaction).

      A query parameter with the name "returnUrl" whose value is set to the page which initiated the logic request will be appended to this URL (if provided). Your login page may ignore this parameter, but to improve user experience it should redirect the user back to this URL after performing a successful login. Be sure to validate that the value of the parameter is from a legitimate source to avoid exploits.

      If this option is omitted, a generic "not signed in" message will be displayed whenever a user who is not logged in attempts any action which requires an account.

    • MainLayout: The type of the main layout for the wiki. Wiki pages will be nested within this layout.

      If omitted, a default layout will be used.

    • TalkHubRoute: The relative path to the SignalR Hub used for discussion pages. If omitted, the path "/wikiTalkHub" will be used.

    • TenorAPIKey: The API key to be used for Tenor GIF integration. If omitted, discussion pages will not have built-in GIF functionality.

    • WikiServerApiRoute: The relative URL of the wiki's server API.

      If omitted, the path "/wikiapi" will be used.

    In addition there are two interface methods which can be overridden: GetArticleFrontMatter and GetArticleEndMatter these accept an Article parameter and should return type of a component which should be displayed after the content of the given wiki article (before the category list), or null if no additional component should be displayed.

    If you provide an instance of the WikiBlazorClientOptions class, these methods can be provided by overriding the ArticleFrontMatter and ArticleEndMatter properties, which accept functions.

  2. Add a page with the following content to your client:

    @page "/wiki/{*route}"
    <Wiki />
    
    @code {
        [Parameter] public string? Route { get; set; }
    }
    

    Replace "wiki" in the page route with your preferred wiki route prefix (which should match what your configure in your WikiOptions instance).

    This page will handle requests for wiki pages.

  3. (Optional) In your main App.razor component, place a Wiki component in the NotFound content slot of your Router component. This will allow the wiki to handle requests for unrecognized routes (i.e. users who do not add your wiki prefix to a typed URL will still get to the expected page). Routes which do not match wiki content will display an "article not found" wiki page.

    If you prefer not to handle unrecognized routes as requests for wiki pages, this step can be skipped.

  4. In your index.html page, add the following content to the head section:

    <link href="https://fonts.googleapis.com/css2?family=Encode+Sans+SC:wdth,wght@75,100..900&family=Recursive:slnt,wght,CASL,MONO@-15..0,300..1000,0..1,0..1&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined" rel="stylesheet">
    <link href="_content/Tavenem.Blazor.Framework/framework.css" rel="stylesheet">
    <link href="_content/Tavenem.Wiki.Blazor.Client/wiki.css" rel="stylesheet">
    <link href="_content/Tavenem.Wiki.Blazor.Client/Tavenem.Wiki.Blazor.Client.bundle.scp.css" rel="stylesheet">
    

    This adds Tavenem.Wiki.Blazor styles, and dependency styles for the Tavenem Blazor Framework. The font choices can be adapted to suit your needs. See the Tavenem Blazor Framework documentation for details.

The Server App

  1. (Optional) Call AddWikiJsonContext on an IServiceCollection instance in your Program.cs file. This configures the JsonOptions for MVC with the WikiBlazorJsonSerializerContext source gererated serializer context. It also adds SignalR, configures the JSON protocol to use the same WikiBlazorJsonSerializerContext, and adds response compression.

    This is an optional step. If you wish to provide your own JSON serializer context (or not), you should call AddSignalR directly, and optionally call AddResponseCompression.

  2. Call one of the overloads of AddWiki on an IServiceCollection instance in your Program.cs file. AddWiki has two required parameters and four optional parameters.

    The first parameter is either an instance of IWikiUserManager, or the type of an implementation of that interface which is available via dependency injection, or a function which provides one. This interface allows the wiki to get information about users. Typically this will be a wrapper around your actual user persistence mechanism (e.g. ASP.NET Core Identity).

    The second parameter is either an instance of IWikiGroupManager, or the type of an implementation of that interface which is available via dependency injection, or a function which provides one. This interface allows the wiki to get information about user groups. Typically this will be a wrapper around your actual user group persistence mechanism.

    The next parameter is either an instance of WikiOptions or a function which provides one. This interface allows you to configure the wiki's core features. See the README for Tavenem.Wiki for more information.

    The next parameter is either an instance of IWikiBlazorServerOptions or a function which provides one. This interface allows you to configure the wiki's Blazor implementation features, and includes the following properties:

    • LoginPath: The relative path to the site's login page.

      For security reasons, only a local path is permitted. If your authentication mechanisms are handled externally, this should point to a local page which redirects to that source (either automatically or via interaction).

      A query parameter with the name "returnUrl" whose value is set to the page which initiated the logic request will be appended to this URL (if provided). Your login page may ignore this parameter, but to improve user experience it should redirect the user back to this URL after performing a successful login. Be sure to validate that the value of the parameter is from a legitimate source to avoid exploits.

      If this option is omitted, a generic "not signed in" message will be displayed whenever a user who is not logged in attempts any action which requires an account.

    • TalkHubRoute: The relative path to the SignalR Hub used for discussion pages. If omitted, the path "/wikiTalkHub" will be used.

    • WikiServerApiRoute: The relative URL of the wiki's server API.

      If omitted, the path "/wikiapi" will be used.

    The next parameter is either an instance of IFileManager, or the type of an implementation of that interface which is available via dependency injection, or a function which provides one. If omitted, an instance of LocalFileManager will be used, which stores files in a subfolder of wwwroot.

    The next parameter is either an instance of ISearchClient, or the type of an implementation of that interface which is available via dependency injection, or a function which provides one. If omitted, an instance of DefaultSearchClient will be used.

    Note: the DefaultSearchClient is not recommended for production use. It is provided only to ensure that basic search functionality operates when an implementation of ISearchClient is not available (e.g. during debugging if the production client cannot be used during development).

  3. Call UseResponseCompression on an IApplicationBuilder instance in your Program.cs file. This should normally only be done if you called AddWikiJsonContext or if you called AddResponseCompression directly.

  4. Call MapWiki on an IEndpointRouteBuilder instance in your Program.cs file.

    For example:

    var builder = WebAssemblyHostBuilder.CreateDefault(args);
    var app = builder.Build();
    app.MapWiki();
    

    This call should normally precede any other mapped endpoints.

Roadmap

Tavenem.Wiki.Blazor is currently in a prerelease state. Development is ongoing, and breaking changes are possible before the first production release.

No release date is currently set for v1.0 of Tavenem.Wiki.Blazor. The project is currently in a "wait and see" phase while Tavenem.DataStore (a dependency of Tavenem.Wiki.Blazor) is in prerelease. When that project has a stable release, a production release of Tavenem.Wiki.Blazor will follow.

Contributing

Contributions are always welcome. Please carefully read the contributing document to learn more before submitting issues or pull requests.

Code of conduct

Please read the code of conduct before engaging with our community, including but not limited to submitting or replying to an issue or pull request.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Tavenem.Wiki.Blazor.Client:

Package Downloads
Tavenem.Wiki.Blazor.Server The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

An implementation of Tavenem.Wiki for Blazor.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.8.0-preview 52 3/28/2024
0.7.8-preview 51 2/21/2024
0.7.7-preview 50 2/20/2024
0.7.6-preview 45 2/20/2024
0.7.5-preview 58 2/19/2024
0.7.4-preview 55 2/12/2024
0.7.3-preview 46 2/2/2024
0.7.2-preview 46 2/1/2024
0.7.1-preview 46 2/1/2024
0.7.0-preview 61 1/12/2024
0.6.6-preview 66 1/9/2024
0.6.5-preview 59 1/3/2024
0.6.4-preview 95 11/29/2023
0.6.3-preview 95 9/26/2023
0.6.2-preview 75 9/12/2023
0.6.1-preview 68 9/12/2023
0.6.0-preview 65 9/8/2023
0.5.8-preview 69 9/5/2023
0.5.7-preview 67 9/5/2023
0.5.6-preview 70 9/1/2023
0.5.5-preview 81 8/14/2023
0.5.4-preview 79 8/9/2023
0.5.3-preview 82 8/4/2023
0.5.2-preview 73 8/4/2023
0.5.1-preview 78 8/4/2023
0.5.0-preview 71 8/4/2023
0.4.1-preview 77 7/27/2023
0.4.0-preview 83 7/26/2023
0.3.0-preview 90 3/6/2023
0.2.8-preview 97 3/2/2023
0.2.7-preview 94 3/2/2023
0.2.6-preview 92 3/1/2023
0.2.5-preview 91 3/1/2023
0.2.4-preview 92 2/28/2023
0.2.3-preview 90 2/28/2023
0.2.2-preview 86 2/28/2023
0.2.1-preview 100 2/3/2023
0.2.0-preview 99 1/12/2023
0.1.1-preview 98 9/30/2022
0.1.0-preview 105 9/8/2022