Tavenem.Wiki.Blazor.Client 0.11.3-preview

Prefix Reserved
This is a prerelease version of Tavenem.Wiki.Blazor.Client.
dotnet add package Tavenem.Wiki.Blazor.Client --version 0.11.3-preview                
NuGet\Install-Package Tavenem.Wiki.Blazor.Client -Version 0.11.3-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.11.3-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.11.3-preview                
#r "nuget: Tavenem.Wiki.Blazor.Client, 0.11.3-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.11.3-preview&prerelease

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

build NuGet downloads

Tavenem.Wiki.Blazor

This is an 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 will function as a complete wiki.

It is also possible to use only the client library, and provide your own implementation for the server library. 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.

It is also possible to use the client library "offline" by providing direct access to wiki data, without the need for any back-end at all. Data might be persisted locally on the client in browser storage, or the local filesystem.

Installation

Tavenem.Wiki.Blazor is available as a pair of NuGet packages: one for the client library, and one for the server library.

The client package should be installed in your Blazor client app, and the server library can optionally be installed in your host app.

Configuration

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

The Client App

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

    For example:

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

    AddWikiClient has two optional parameters.

    The first parameter is either an instance of WikiBlazorOptions or a function which configures one. This object inherits from WikiOptions and allows you to configure the wiki's core features as well as the Blazor client. See the README for Tavenem.Wiki for more information. It includes the following additional 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.

    • AppBarRenderMode: The render mode to use for the AppBar component, or null to use static rendering.

      The type must implement IComponent.

    • ArticleFrontMatter and ArticleEndMatter: these can be set to functions which accept an Article parameter and should return type of a component which should be displayed before or after the content of the given wiki article (before the category list), or null if no additional component should be displayed.

    • ArticleFrontMatterRenderMode and ArticleEndMatterRenderMode: The render mode to use for the ArticleFrontMatter and ArticleEndMatter components, or null to use static rendering.

    • CanEditOffline: Can be set to a function which determines whether content may be edited locally.

      If this function is not defined, no content may be edited locally (i.e. local content may only be viewed).

    • 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.

    • DomainArchivePermission: The minimum permission the user must have in order to create an archive of a domain.

      This property does not apply when creating an archive for content without a domain, or for the entire wiki.

      Since it would be prohibitive to check individual pages' permission, archiving only requires that a user has this level of permission (defaults to Read) for the target domain. This could represent a potential security breach, if individual pages within the domain are further restricted. It is strongly recommended that the ability to create archives is restricted in your client code in a manner specific to your implementation's use of domains, which guarantees that only those with the correct permissions can create archives.

    • IsOfflineDomain: A function which determines whether the given domain should always be retrieved from the local DataStore, and never from the WikiServerApiRoute.

    • 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.

    • 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.

      This is initialized to <see langword="null"/> by default, WikiBlazorClientOptions.DefaultWikiServerApiRoute may be assigned to use the default value for a hosting server app with default values.

      If the WikiServerApiRoute is defined, the client will try to reach the server first for all wiki operations. If the server cannot be reached or the requested content is unavailable at the server, the client will fall back to the local data store (if one is configured).

      If both the server and the local data store are unavailable, the wiki will remain operational, but will show no content and will not allow any content to be added.

      No automatic synchronization occurs from the local data store to the server (for instance when an offline client reestablishes network connectivity). If your app model requires synchronization of offline content to a server, that logic must be implemented separately.

    When providing a configuration function (rather than a preconfigured options instance) the following additional properties are available:

    • ArticleRenderManager: an instance of IArticleRenderManager. The overloads of ConfigureArticleRenderManager also allow configuring this from dependency injection. If omitted, an instance of the default ArticleRenderManager will be used, which always returns null for all members.
    • OfflineManager: an instance of IOfflineManager. The overloads of ConfigureOfflineManager also allow configuring this from dependency injection. If omitted, an instance of the default OfflineManager will be used, which always returns false for all members.
    • PageManager: an instance of IPageManager. The overloads of ConfigurePageManager also allow configuring this from dependency injection. If omitted, an instance of the default PageManager will be used, which performs no actions.
    • PermissionManager: an instance of IPermissionManager. The overloads of ConfigurePermissionManager also allow configuring this from dependency injection. If omitted, an instance of the default PermissionManager will be used, which which always returns null.
  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.

The Server App

  1. Call one of the overloads of AddWikiServer on an IServiceCollection instance in your Program.cs file. AddWikiServer has two optional parameters which are similar to those used for AddWikiClient. The configuration parameter adds the following additional properties:

    • FileManager: an instance of IFileManager. The overloads of ConfigureFileManager also allow configuring this from dependency injection. If omitted, an instance of LocalFileManager will be used, which stores files in a subfolder of wwwroot. Note that you can disable file uploads entirely in WikiOptions.
    • GroupManager: an instance of IWikiGroupManager. The overloads of ConfigureGroupManager also allow configuring this from dependency injection. This interface allows the wiki to get information about user groups. Typically this will be a wrapper around your actual user group persistence mechanism. If omitted, an instance of WikiGroupManager will be used, which keeps its data in the IDataStore.
    • UserManager: an instance of IWikiUserManager. The overloads of ConfigureUserManager also allow configuring this from dependency injection. 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). If omitted, an instance of WikiUserManager will be used, which keeps its data in the IDataStore.
    • UseDefaultAuthorization: Defaults to true, which allows anonymous reads and requires an authenticated user for edits. If set to false, custom AuthorizationHandler{TRequirement,TResource} implementations should be registered for WikiDefaultRequirement (for read operations) and WikiEditRequirement (for edit operations). Both receive a PageTitle for the resource parameter, although it may be set to a default value (i.e. the main wiki page) for operations which do not reference a specific wiki page, such as search.
  2. Call MapWiki to adds endpoint for the wiki to the ASP.NET Host server app for a Blazor WebAssembly client. If WikiServerApiRoute was set to a custom value in the options, it should be provided as a parameter to this method.

    For example:

    var builder = WebAssemblyHostBuilder.CreateDefault(args);
    builder.Services.AddWikiServer();
    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.

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 net9.0 is compatible. 
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

An implementation of Tavenem.Wiki for Blazor.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.11.3-preview 52 12/4/2024
0.11.2-preview 41 12/3/2024
0.11.1-preview 50 11/26/2024
0.11.0-preview 44 11/25/2024
0.10.1-preview 44 11/21/2024
0.10.0-preview 42 11/21/2024
0.9.13-preview 52 11/15/2024
0.9.12-preview 45 11/15/2024
0.9.11-preview 42 11/15/2024
0.9.10-preview 42 11/14/2024
0.9.9-preview 42 11/14/2024
0.9.8-preview 41 11/14/2024
0.9.7-preview 46 11/8/2024
0.9.6-preview 46 11/8/2024
0.9.5-preview 43 11/8/2024
0.9.4-preview 44 11/7/2024
0.9.3-preview 42 11/7/2024
0.9.2-preview 47 11/6/2024
0.9.1-preview 49 10/31/2024
0.9.0-preview 81 10/18/2024
0.8.0-preview 68 3/28/2024
0.7.8-preview 62 2/21/2024
0.7.7-preview 62 2/20/2024
0.7.6-preview 58 2/20/2024
0.7.5-preview 70 2/19/2024
0.7.4-preview 76 2/12/2024
0.7.3-preview 62 2/2/2024
0.7.2-preview 63 2/1/2024
0.7.1-preview 68 2/1/2024
0.7.0-preview 77 1/12/2024
0.6.6-preview 82 1/9/2024
0.6.5-preview 76 1/3/2024
0.6.4-preview 119 11/29/2023
0.6.3-preview 121 9/26/2023
0.6.2-preview 92 9/12/2023
0.6.1-preview 92 9/12/2023
0.6.0-preview 84 9/8/2023
0.5.8-preview 100 9/5/2023
0.5.7-preview 92 9/5/2023
0.5.6-preview 89 9/1/2023
0.5.5-preview 107 8/14/2023
0.5.4-preview 101 8/9/2023
0.5.3-preview 97 8/4/2023
0.5.2-preview 95 8/4/2023
0.5.1-preview 94 8/4/2023
0.5.0-preview 92 8/4/2023
0.4.1-preview 94 7/27/2023
0.4.0-preview 104 7/26/2023
0.3.0-preview 108 3/6/2023
0.2.8-preview 115 3/2/2023
0.2.7-preview 112 3/2/2023
0.2.6-preview 103 3/1/2023
0.2.5-preview 104 3/1/2023
0.2.4-preview 106 2/28/2023
0.2.3-preview 105 2/28/2023
0.2.2-preview 98 2/28/2023
0.2.1-preview 120 2/3/2023
0.2.0-preview 116 1/12/2023
0.1.1-preview 121 9/30/2022
0.1.0-preview 121 9/8/2022