/// <summary> /// Injects additional CSS stylesheets into the index.html page. /// </summary> /// <param name="options">Options for configuring <see cref="SpaUIMiddleware"/> middleware.</param> /// <param name="path">A path to the stylesheet - i.e. the link "href" attribute.</param> /// <param name="media">The target media - i.e. the link "media" attribute.</param> public static SpaUIOptions InjectStylesheet(this SpaUIOptions options, string path, string media = "screen") { var builder = new StringBuilder(options.HeadContent); builder.AppendLine($"<link href='{path}' rel='stylesheet' media='{media}' type='text/css' />"); options.HeadContent = builder.ToString(); return(options); }
/// <summary> /// Injects additional Javascript files into the index.html page. /// </summary> /// <param name="options">Options for configuring <see cref="SpaUIMiddleware"/> middleware.</param> /// <param name="path">A path to the javascript - i.e. the script "src" attribute.</param> /// <param name="type">The script type - i.e. the script "type" attribute.</param> /// <returns></returns> public static SpaUIOptions InjectJavascript(this SpaUIOptions options, string path, string type = "text/javascript") { var builder = new StringBuilder(options.HeadContent); builder.AppendLine($"<script src='{path}' type='{type}'></script>"); options.HeadContent = builder.ToString(); return(options); }
/// <summary> /// Registers the single page application, using the provided options. /// </summary> /// <param name="builder">Defines a class that provides the mechanisms to configure an application's request pipeline.</param> /// <param name="embeddedUIRoot">Embedded UI root folder name.</param> /// <param name="assembly">The assembly containing the embedded resources.</param> /// <param name="optionsAction">Options for configuring <see cref="SpaUIMiddleware"/> middleware.</param> public static IApplicationBuilder UseSpaUI(this IApplicationBuilder builder, string embeddedUIRoot = "spa-ui-dist", Assembly assembly = null, Action <SpaUIOptions> optionsAction = null) { var options = new SpaUIOptions { Version = assembly.GetName().Version.ToString(fieldCount: 3) }; optionsAction?.Invoke(options); return(builder.UseSpaUI(options, embeddedUIRoot, assembly ?? Assembly.GetCallingAssembly())); }
/// <summary> /// Registers the single page application, using the provided options. /// </summary> /// <param name="builder">Defines a class that provides the mechanisms to configure an application's request pipeline.</param> /// <param name="options">Options for configuring <see cref="SpaUIMiddleware"/> middleware.</param> /// <param name="embeddedUIRoot">Embedded UI root folder name.</param> /// <param name="assembly">The assembly containing the embedded resources.</param> public static IApplicationBuilder UseSpaUI(this IApplicationBuilder builder, SpaUIOptions options, string embeddedUIRoot, Assembly assembly) { if (options.Enabled) { options.Version = assembly.GetName().Version.ToString(fieldCount: 3); builder.UseMiddleware <SpaUIMiddleware>(options, embeddedUIRoot, assembly); } return(builder); }
/// <summary> /// Registers the Identity Server's Admin UI single page application, using the provided options. /// </summary> /// <param name="builder">Defines a class that provides the mechanisms to configure an application's request pipeline.</param> /// <param name="options">Options for configuring <see cref="SpaUIMiddleware"/> middleware.</param> public static IApplicationBuilder UseAdminUI(this IApplicationBuilder builder, SpaUIOptions options) => builder.UseSpaUI(options, "admin-ui-dist", typeof(AdminUIMiddlewareExtensions).Assembly);
/// <summary> /// Registers the Campaigns UI single page application, using the provided options. /// </summary> /// <param name="builder">Defines a class that provides the mechanisms to configure an application's request pipeline.</param> /// <param name="options">Options for configuring <see cref="SpaUIMiddleware"/> middleware.</param> public static IApplicationBuilder UseCampaignsUI(this IApplicationBuilder builder, SpaUIOptions options) => builder.UseSpaUI(options, "campaigns-ui-dist", typeof(CampaignsUIMiddlewareExtensions).Assembly);