Compact authenticated navigation and retire global Word follow
This commit is contained in:
parent
528a8808d5
commit
a76d201b87
70
PlotLine.Tests/ApplicationNavigationTests.cs
Normal file
70
PlotLine.Tests/ApplicationNavigationTests.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using PlotLine.Data;
|
||||
using PlotLine.Models;
|
||||
using PlotLine.Services;
|
||||
using PlotLine.ViewModels;
|
||||
|
||||
internal static class ApplicationNavigationTests
|
||||
{
|
||||
public static void ContextAndPermissions() => Run().GetAwaiter().GetResult();
|
||||
|
||||
private static async Task Run()
|
||||
{
|
||||
var project = new Project { ProjectID = 7, ProjectName = "Navigation project" };
|
||||
var book = new Book { BookID = 12, ProjectID = 7, BookTitle = "Volume two" };
|
||||
var projectCalls = 0;
|
||||
var bookCalls = 0;
|
||||
var projects = Proxy<IProjectRepository>((name, args) =>
|
||||
{
|
||||
if (name != "GetForUserAsync") throw new Exception(name);
|
||||
projectCalls++;
|
||||
Check((int)args![1]! == 4, "Project lookup must use current user.");
|
||||
return Task.FromResult((int)args[0]! == 7 ? project : null);
|
||||
});
|
||||
var books = Proxy<IBookRepository>((name, args) =>
|
||||
{
|
||||
if (name != "ListByProjectAsync") throw new Exception(name);
|
||||
bookCalls++;
|
||||
Check((int)args![0]! == 7, "Never load books for an inaccessible project.");
|
||||
return Task.FromResult<IReadOnlyList<Book>>([book, new() { BookID = 13, ProjectID = 7, IsArchived = true }]);
|
||||
});
|
||||
var user = Proxy<ICurrentUserService>((_, _) => (int?)4);
|
||||
var navigation = new ApplicationNavigation(projects, books, user);
|
||||
var request = new DefaultHttpContext().Request;
|
||||
request.RouteValues["controller"] = "Names";
|
||||
var names = await navigation.BuildAsync(new NamesLibraryViewModel { Project = project, Filter = new() { BookID = 12 } }, null, request);
|
||||
Check(names.Book == book && names.Project == project && names.ActiveSection == "Names", "Names should preserve selected book and active section.");
|
||||
Check(names.Books.Count == 1, "Archived books must not appear in switcher.");
|
||||
var all = await navigation.BuildAsync(new TimelineViewModel { Project = project }, "Timeline", request);
|
||||
Check(all.Book is null, "Project-wide timeline must not invent a current book.");
|
||||
request.QueryString = new QueryString("?bookId=12");
|
||||
var calendar = await navigation.BuildAsync(new StoryCalendarViewModel { Project = project }, "Calendar", request);
|
||||
Check(calendar.Book is null, "An all-books page model must take precedence over a URL hint.");
|
||||
var point = await navigation.BuildAsync(new StoryPointViewModel { Project = project, Snapshot = new() { Book = book } }, "At This Point", request);
|
||||
Check(point.Book == book, "Story Point should use the snapshot book.");
|
||||
var chapter = await navigation.BuildAsync(new ChapterDetailViewModel { Project = project, Book = book }, "Overview", request);
|
||||
Check(chapter.Book == book, "Chapter context should retain its book.");
|
||||
var badBook = await navigation.BuildAsync(new NamesLibraryViewModel { Project = project, Filter = new() { BookID = 999 } }, null, request);
|
||||
Check(badBook.Book is null, "Book from another project must not enter the menu.");
|
||||
request.QueryString = QueryString.Empty;
|
||||
var writing = await navigation.BuildAsync(new WritingContextPageViewModel { ProjectID = 7, BookID = 12 }, "Writer", request);
|
||||
Check(writing.Project == project && writing.Book == book, "Writing window scope should resolve without changing it.");
|
||||
var before = bookCalls;
|
||||
var denied = await navigation.BuildAsync(new WritingIntentPageViewModel { ProjectID = 88, BookID = 12 }, "Writer", request);
|
||||
Check(denied.Project is null && denied.Books.Count == 0 && bookCalls == before, "Unauthorised scope must not expose books or project actions.");
|
||||
var global = await navigation.BuildAsync(new object(), null, request);
|
||||
Check(global.Project is null, "Global pages must not inherit a prior project's context.");
|
||||
var anonymous = new ApplicationNavigation(projects, books, Proxy<ICurrentUserService>((_, _) => null));
|
||||
before = projectCalls;
|
||||
Check((await anonymous.BuildAsync(new NamesLibraryViewModel { Project = project }, null, request)).Project is null && before == projectCalls, "Anonymous navigation must not load project data.");
|
||||
}
|
||||
|
||||
private static T Proxy<T>(Func<string, object?[]?, object?> handler) where T : class
|
||||
{
|
||||
var proxy = DispatchProxy.Create<T, StoryPointProxy>();
|
||||
((StoryPointProxy)(object)proxy).Handler = handler;
|
||||
return proxy;
|
||||
}
|
||||
private static void Check(bool condition, string message) { if (!condition) throw new InvalidOperationException(message); }
|
||||
}
|
||||
@ -309,7 +309,8 @@ var tests = new (string Name, Action Test)[]
|
||||
("Writing Context preserves selected tab and avoids event loops", WritingContextPreservesSelectedTabAndAvoidsEventLoops),
|
||||
("Writing Intent route uses canonical story context and planning data", WritingIntentRouteUsesCanonicalStoryContextAndPlanningData),
|
||||
("Writing Intent client uses shared writing follow helper", WritingIntentClientUsesSharedWritingFollowHelper),
|
||||
("Writing mode pages are isolated from global Word navigation", WritingModePagesAreIsolatedFromGlobalWordNavigation),
|
||||
("Obsolete global Word navigation is removed while writing windows remain live", GlobalWordNavigationIsRemoved),
|
||||
("Application navigation resolves authorised project and book context", ApplicationNavigationTests.ContextAndPermissions),
|
||||
("Writing pair shares canonical follow infrastructure", WritingPairSharesCanonicalFollowInfrastructure),
|
||||
("Writing workspace presence scopes browser windows", WritingWorkspacePresenceScopesBrowserWindows),
|
||||
("Writing workspace client uses session window identity and stable names", WritingWorkspaceClientUsesSessionIdentityAndStableNames),
|
||||
@ -1844,16 +1845,20 @@ static void WritingIntentClientUsesSharedWritingFollowHelper()
|
||||
Assert(!helper.Contains("window.location.assign", StringComparison.Ordinal) && !helper.Contains("window.location.href", StringComparison.Ordinal), "Writing Intent must not navigate away when Word changes scene.");
|
||||
}
|
||||
|
||||
static void WritingModePagesAreIsolatedFromGlobalWordNavigation()
|
||||
static void GlobalWordNavigationIsRemoved()
|
||||
{
|
||||
var root = Path.Combine(AppContext.BaseDirectory, "../../../../PlotLine");
|
||||
var site = File.ReadAllText(Path.Combine(root, "wwwroot/js/site.js"));
|
||||
|
||||
Assert(site.Contains("document.querySelector(\"[data-writing-mode]\")", StringComparison.Ordinal), "Global Word follow should recognize writing-mode markers.");
|
||||
Assert(site.Contains("path === \"/writing/context\"", StringComparison.Ordinal), "Writing Context route should be exempt from global scene navigation.");
|
||||
Assert(site.Contains("path === \"/writing/intent\"", StringComparison.Ordinal), "Writing Intent route should be exempt from global scene navigation.");
|
||||
Assert(site.Contains("window.location.assign(url)", StringComparison.Ordinal), "Normal pages should retain existing Word follow navigation.");
|
||||
Assert(site.Contains("safeRelativeUrl(payload?.sceneUrl || payload?.SceneUrl || \"\", \"/Scenes/Edit/\")", StringComparison.Ordinal), "Normal scene follow should still target canonical Scene Edit URLs.");
|
||||
var controller = File.ReadAllText(Path.Combine(root, "Controllers/WordCompanionController.cs"));
|
||||
var follow = File.ReadAllText(Path.Combine(root, "wwwroot/js/writing-follow.js"));
|
||||
Assert(!site.Contains("plotdirector.followWordCompanion", StringComparison.Ordinal), "Obsolete persisted global-follow preference must not control the browser.");
|
||||
Assert(!site.Contains("data-word-companion-follow-toggle", StringComparison.Ordinal), "Obsolete global-follow toggle handler must be removed.");
|
||||
Assert(!controller.Contains("wordCompanionSceneChanged", StringComparison.Ordinal) && !controller.Contains("wordCompanionCharactersCreated", StringComparison.Ordinal), "Broadcasts used only by global navigation must be removed.");
|
||||
Assert(site.Contains("window.PlotDirectorStoryPosition", StringComparison.Ordinal), "Shared position event helper must remain for writing windows.");
|
||||
var workspace = File.ReadAllText(Path.Combine(root, "wwwroot/js/writing-workspace.js"));
|
||||
Assert(workspace.Contains("connection.on(\"storyPositionChanged\"", StringComparison.Ordinal), "The workspace launcher must retain its live canonical-position feed without global follow.");
|
||||
Assert(controller.Contains("BroadcastToCurrentUserAsync(\"storyPositionChanged\"", StringComparison.Ordinal), "Current scene API must still notify the writing windows.");
|
||||
Assert(follow.Contains("connection.on(\"storyPositionChanged\"", StringComparison.Ordinal), "Writing windows must still receive canonical positions directly.");
|
||||
}
|
||||
|
||||
static void WritingPairSharesCanonicalFollowInfrastructure()
|
||||
|
||||
@ -155,16 +155,6 @@ public sealed class WordCompanionController(
|
||||
response.ChapterId,
|
||||
response.SceneId);
|
||||
|
||||
await BroadcastToCurrentUserAsync("wordCompanionSceneChanged", new
|
||||
{
|
||||
response.ProjectId,
|
||||
response.BookId,
|
||||
response.ChapterId,
|
||||
response.SceneId,
|
||||
response.SceneUrl,
|
||||
response.Position
|
||||
});
|
||||
|
||||
await BroadcastToCurrentUserAsync("storyPositionChanged", new
|
||||
{
|
||||
Source = "WordCompanion",
|
||||
@ -272,15 +262,6 @@ public sealed class WordCompanionController(
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
if (response.CreatedCount > 0)
|
||||
{
|
||||
await BroadcastToCurrentUserAsync("wordCompanionCharactersCreated", new
|
||||
{
|
||||
response.ProjectId,
|
||||
CharactersUrl = Url.Action("Index", "Characters", new { projectId = response.ProjectId }) ?? $"/Characters?projectId={response.ProjectId}"
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
|
||||
@ -111,6 +111,7 @@ public class Program
|
||||
builder.Services.AddScoped<IUserFileRepository, UserFileRepository>();
|
||||
builder.Services.AddScoped<IFeatureRequestRepository, FeatureRequestRepository>();
|
||||
builder.Services.AddScoped<IProjectRepository, ProjectRepository>();
|
||||
builder.Services.AddScoped<ApplicationNavigation>();
|
||||
builder.Services.AddScoped<IBookRepository, BookRepository>();
|
||||
builder.Services.AddScoped<IManuscriptDocumentRepository, ManuscriptDocumentRepository>();
|
||||
builder.Services.AddScoped<IChapterRepository, ChapterRepository>();
|
||||
|
||||
60
PlotLine/Services/ApplicationNavigation.cs
Normal file
60
PlotLine/Services/ApplicationNavigation.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using PlotLine.Data;
|
||||
using PlotLine.Models;
|
||||
using PlotLine.ViewModels;
|
||||
|
||||
namespace PlotLine.Services;
|
||||
|
||||
// Request-scoped: existing project partials register their already-authorised context
|
||||
// while the body renders, before the shared layout renders the application menu.
|
||||
public sealed class ApplicationNavigation(IProjectRepository projects, IBookRepository books, ICurrentUserService currentUser)
|
||||
{
|
||||
public Project? Project { get; set; }
|
||||
|
||||
public async Task<ApplicationNavigationViewModel> BuildAsync(object? model, string? section, HttpRequest request)
|
||||
{
|
||||
var controller = request.RouteValues["controller"]?.ToString() ?? string.Empty;
|
||||
var result = new ApplicationNavigationViewModel { ActiveSection = section ?? controller switch
|
||||
{
|
||||
"Projects" or "Books" or "Chapters" or "Scenes" => "Overview",
|
||||
"StoryCalendar" => "Calendar", "StoryPoint" => "At This Point",
|
||||
"RelationshipMap" => "Relationships", "StoryAssets" => "Assets",
|
||||
"FloorPlans" => "Floor Plans", "PlotThreads" => "Threads",
|
||||
"ProjectMetrics" => "Metrics", "StoryBible" => "Story Bible",
|
||||
"ContinuityExplorer" => "Continuity Explorer", "Analytics" or "Dynamics" => "Health",
|
||||
"Archives" => "Archive", _ => controller
|
||||
} };
|
||||
if (currentUser.UserId is not int userId) return result;
|
||||
|
||||
var project = Project ?? Property(model, "Project") as Project ?? model as Project;
|
||||
var book = Property(model, "Book") as Book ?? (model as StoryPointViewModel)?.Snapshot?.Book;
|
||||
var projectId = project?.ProjectID ?? PositiveId(Property(model, "ProjectID"))
|
||||
?? book?.ProjectID ?? PositiveId(request.Query["projectId"].FirstOrDefault());
|
||||
if (projectId is not > 0) return result;
|
||||
|
||||
// Resolve through the user-scoped repository even on models that only carry IDs.
|
||||
// Never use a remembered project or an unverified URL value as navigation context.
|
||||
project = await projects.GetForUserAsync(projectId.Value, userId);
|
||||
if (project is null) return result;
|
||||
var projectBooks = await books.ListByProjectAsync(project.ProjectID);
|
||||
var selectedBookId = model switch
|
||||
{
|
||||
StoryPointViewModel point => point.Snapshot?.Book.BookID,
|
||||
TimelineViewModel timeline => timeline.SelectedBookID,
|
||||
StoryCalendarViewModel calendar => calendar.SelectedBookID,
|
||||
NamesLibraryViewModel names => names.Filter.BookID,
|
||||
_ => book?.BookID ?? PositiveId(Property(model, "SelectedBookID"))
|
||||
?? PositiveId(Property(model, "BookID"))
|
||||
?? PositiveId(Property(Property(model, "Filter"), "BookID"))
|
||||
?? PositiveId(request.Query["bookId"].FirstOrDefault())
|
||||
};
|
||||
result.Project = project;
|
||||
result.Books = projectBooks.Where(x => !x.IsArchived).ToList();
|
||||
result.Book = result.Books.FirstOrDefault(x => x.BookID == selectedBookId);
|
||||
return result;
|
||||
}
|
||||
|
||||
// The existing view models share these named properties but no common base class.
|
||||
// Keep that compatibility boundary here rather than modifying every page/model.
|
||||
private static object? Property(object? model, string name) => model?.GetType().GetProperty(name)?.GetValue(model);
|
||||
private static int? PositiveId(object? value) => int.TryParse(value?.ToString(), out var id) && id > 0 ? id : null;
|
||||
}
|
||||
15
PlotLine/ViewModels/ApplicationNavigationViewModel.cs
Normal file
15
PlotLine/ViewModels/ApplicationNavigationViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using PlotLine.Models;
|
||||
|
||||
namespace PlotLine.ViewModels;
|
||||
|
||||
public sealed class ApplicationNavigationViewModel
|
||||
{
|
||||
public bool IsAdmin { get; set; }
|
||||
public bool ShowCompanionPresence { get; set; }
|
||||
public int FeatureRequestAttentionCount { get; set; }
|
||||
public int AdminFeatureRequestAttentionCount { get; set; }
|
||||
public Project? Project { get; set; }
|
||||
public Book? Book { get; set; }
|
||||
public IReadOnlyList<Book> Books { get; set; } = [];
|
||||
public string ActiveSection { get; set; } = string.Empty;
|
||||
}
|
||||
110
PlotLine/Views/Shared/_ApplicationNavigation.cshtml
Normal file
110
PlotLine/Views/Shared/_ApplicationNavigation.cshtml
Normal file
@ -0,0 +1,110 @@
|
||||
@model ApplicationNavigationViewModel
|
||||
@{
|
||||
var project = Model.Project;
|
||||
var book = Model.Book;
|
||||
var controller = ViewContext.RouteData.Values["controller"]?.ToString();
|
||||
}
|
||||
<nav class="navbar navbar-expand-lg border-bottom plotline-nav app-navigation" aria-label="Application navigation" data-app-navigation>
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand fw-semibold" asp-route="@PublicRouteNames.Home">PlotDirector</a>
|
||||
<div class="app-navigation-status">
|
||||
@if (Model.ShowCompanionPresence)
|
||||
{
|
||||
<span class="word-companion-presence-pill" data-word-companion-presence data-word-companion-status="Offline" title="Word Companion status" role="status" aria-live="polite">
|
||||
<span class="word-companion-presence-dot" data-word-companion-status-dot></span>
|
||||
<span data-word-companion-status-label>Offline</span>
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#applicationMenu" aria-controls="applicationMenu" aria-expanded="false" aria-label="Toggle application menu">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="applicationMenu">
|
||||
<ul class="navbar-nav app-navigation-menus">
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(controller == "Projects" ? "active" : null)" type="button" id="appProjectMenu" data-bs-toggle="dropdown" aria-expanded="false" title="@(project?.ProjectName ?? "Project")">
|
||||
<span class="app-context-label">@(project?.ProjectName ?? "Project")</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="appProjectMenu">
|
||||
@if (project is not null)
|
||||
{
|
||||
<li><h2 class="dropdown-header">@project.ProjectName</h2></li>
|
||||
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Details" asp-route-id="@project.ProjectID">Project overview</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Edit" asp-route-id="@project.ProjectID">Edit project</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Books" asp-action="Create" asp-route-projectId="@project.ProjectID">Add book</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Activity" asp-route-id="@project.ProjectID">Activity</a></li>
|
||||
@if (project.IsOwner)
|
||||
{
|
||||
<li><a class="dropdown-item" asp-controller="ProjectCollaborators" asp-action="Index" asp-route-projectId="@project.ProjectID">Collaborators</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Exports" asp-action="ProjectBackup" asp-route-projectId="@project.ProjectID">Download Project Backup</a></li>
|
||||
}
|
||||
<li><a class="dropdown-item" asp-controller="ProjectRestorePoints" asp-action="Index" asp-route-projectId="@project.ProjectID">Restore Points</a></li>
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
}
|
||||
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Index">@(project is null ? "Projects" : "Switch project…")</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Writer" asp-action="Index">Writer Workspace</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Imports" asp-action="Index">Import</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@if (project is not null)
|
||||
{
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(controller is "Books" or "Chapters" or "Scenes" ? "active" : null)" type="button" id="appBookMenu" data-bs-toggle="dropdown" aria-expanded="false" title="@(book?.BookDisplayTitle ?? "Book")">
|
||||
<span class="app-context-label app-book-label" data-app-book-label>@(book?.BookDisplayTitle ?? "Book")</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu app-book-menu" aria-labelledby="appBookMenu">
|
||||
<li><h2 class="dropdown-header" data-app-book-heading>@(book?.BookDisplayTitle ?? "Books in this project")</h2></li>
|
||||
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Details", "Books", new { id = (int?)null })" asp-controller="Books" asp-action="Details" asp-route-id="@book?.BookID">Book overview</a></li>
|
||||
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Edit", "Books", new { id = (int?)null })" asp-controller="Books" asp-action="Edit" asp-route-id="@book?.BookID">Edit book</a></li>
|
||||
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Create", "Chapters", new { id = (int?)null })" data-app-book-param="bookId" asp-controller="Chapters" asp-action="Create" asp-route-bookId="@book?.BookID">Add chapter</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Details" asp-route-id="@project.ProjectID">All books / project overview</a></li>
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
@foreach (var choice in Model.Books)
|
||||
{
|
||||
<li><a class="dropdown-item @(choice.BookID == book?.BookID ? "active" : null)" aria-current="@(choice.BookID == book?.BookID ? "page" : null)" data-app-book-choice="@choice.BookID" data-app-book-title="@choice.BookDisplayTitle" asp-controller="Books" asp-action="Details" asp-route-id="@choice.BookID">Book @choice.BookNumber: @choice.BookDisplayTitle</a></li>
|
||||
}
|
||||
@if (Model.Books.Count == 0)
|
||||
{
|
||||
<li><span class="dropdown-item-text text-muted">No books yet</span></li>
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
<partial name="_ApplicationSectionMenus" model="Model" />
|
||||
}
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(controller is "Help" or "FeatureRequests" ? "active" : null)" type="button" id="appHelpMenu" data-bs-toggle="dropdown" aria-expanded="false">Help</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="appHelpMenu">
|
||||
<li><a class="dropdown-item" asp-route="@PublicRouteNames.Help">Help Centre</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="FeatureRequests" asp-action="Index">Feature Requests @if (Model.FeatureRequestAttentionCount > 0) { <span class="badge text-bg-warning ms-1">@Model.FeatureRequestAttentionCount</span> }</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="nav-item dropdown app-account-menu">
|
||||
<button class="nav-link dropdown-toggle" type="button" id="accountMenuButton" data-bs-toggle="dropdown" aria-expanded="false" title="@User.Identity?.Name">
|
||||
<span class="app-account-label">@User.Identity?.Name</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="accountMenuButton">
|
||||
<li><h2 class="dropdown-header">@User.Identity?.Name</h2></li>
|
||||
<li><a class="dropdown-item" asp-controller="ManageAccount" asp-action="Index">Manage Account</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Onboarding" asp-action="Index">Setup preferences</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="ManageAccount" asp-action="Subscription">Billing / Subscription</a></li>
|
||||
@if (Model.IsAdmin)
|
||||
{
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
<li><a class="dropdown-item" asp-controller="Admin" asp-action="Index">Admin @if (Model.AdminFeatureRequestAttentionCount > 0) { <span class="badge text-bg-danger ms-1">@Model.AdminFeatureRequestAttentionCount</span> }</a></li>
|
||||
}
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
<li><div class="px-3 py-2">
|
||||
<div class="small text-muted mb-2">Theme</div>
|
||||
<div class="theme-switcher btn-group btn-group-sm w-100" role="group" aria-label="Theme selection">
|
||||
<button type="button" class="btn btn-outline-secondary" data-theme-choice="light" aria-pressed="true">Light</button>
|
||||
<button type="button" class="btn btn-outline-secondary" data-theme-choice="dark" aria-pressed="false">Dark</button>
|
||||
</div>
|
||||
</div></li>
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
<li><form asp-controller="Account" asp-action="Logout" method="post" class="m-0"><button class="dropdown-item" type="submit">Logout</button></form></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
47
PlotLine/Views/Shared/_ApplicationSectionMenus.cshtml
Normal file
47
PlotLine/Views/Shared/_ApplicationSectionMenus.cshtml
Normal file
@ -0,0 +1,47 @@
|
||||
@model ApplicationNavigationViewModel
|
||||
@{
|
||||
var projectId = Model.Project!.ProjectID;
|
||||
string ActiveClass(string section) => string.Equals(Model.ActiveSection, section, StringComparison.OrdinalIgnoreCase) ? "active" : string.Empty;
|
||||
}
|
||||
@{ var storyActive = Model.ActiveSection == "Overview" || Model.ActiveSection == "Timeline" || Model.ActiveSection == "Calendar" || Model.ActiveSection == "At This Point" || Model.ActiveSection == "Threads" || Model.ActiveSection == "Scenarios" || Model.ActiveSection == "Continuity Explorer"; }
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(storyActive ? "active" : string.Empty)" type="button" id="appStoryMenu" data-bs-toggle="dropdown" aria-expanded="false">Story</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="appStoryMenu">
|
||||
<li><a class="dropdown-item @(ActiveClass("Overview"))" aria-current="@(Model.ActiveSection == "Overview" ? "page" : null)" asp-controller="Projects" asp-action="Details" asp-route-id="@projectId">Overview</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Timeline"))" aria-current="@(Model.ActiveSection == "Timeline" ? "page" : null)" asp-controller="Timeline" asp-action="Index" asp-route-projectId="@projectId">Timeline</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Calendar"))" aria-current="@(Model.ActiveSection == "Calendar" ? "page" : null)" asp-controller="StoryCalendar" asp-action="Index" asp-route-projectId="@projectId">Calendar</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("At This Point"))" aria-current="@(Model.ActiveSection == "At This Point" ? "page" : null)" asp-controller="StoryPoint" asp-action="Index" asp-route-projectId="@projectId">At This Point</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Threads"))" aria-current="@(Model.ActiveSection == "Threads" ? "page" : null)" asp-controller="PlotThreads" asp-action="Index" asp-route-projectId="@projectId">Threads</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Scenarios"))" aria-current="@(Model.ActiveSection == "Scenarios" ? "page" : null)" asp-controller="Scenarios" asp-action="Index" asp-route-projectId="@projectId">Scenarios</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Continuity Explorer"))" aria-current="@(Model.ActiveSection == "Continuity Explorer" ? "page" : null)" asp-controller="ContinuityExplorer" asp-action="Index" asp-route-projectId="@projectId">Continuity Explorer</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@{ var charactersActive = Model.ActiveSection == "Characters" || Model.ActiveSection == "Names" || Model.ActiveSection == "Relationships"; }
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(charactersActive ? "active" : string.Empty)" type="button" id="appCharactersMenu" data-bs-toggle="dropdown" aria-expanded="false">Characters</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="appCharactersMenu">
|
||||
<li><a class="dropdown-item @(ActiveClass("Characters"))" aria-current="@(Model.ActiveSection == "Characters" ? "page" : null)" asp-controller="Characters" asp-action="Index" asp-route-projectId="@projectId">Characters</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Names"))" aria-current="@(Model.ActiveSection == "Names" ? "page" : null)" asp-controller="Names" asp-action="Index" asp-route-projectId="@projectId">Names</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Relationships"))" aria-current="@(Model.ActiveSection == "Relationships" ? "page" : null)" asp-controller="RelationshipMap" asp-action="Index" asp-route-projectId="@projectId">Relationships</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@{ var worldActive = Model.ActiveSection == "Assets" || Model.ActiveSection == "Locations" || Model.ActiveSection == "Floor Plans"; }
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(worldActive ? "active" : string.Empty)" type="button" id="appWorldMenu" data-bs-toggle="dropdown" aria-expanded="false">World</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="appWorldMenu">
|
||||
<li><a class="dropdown-item @(ActiveClass("Assets"))" aria-current="@(Model.ActiveSection == "Assets" ? "page" : null)" asp-controller="StoryAssets" asp-action="Index" asp-route-projectId="@projectId">Assets</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Locations"))" aria-current="@(Model.ActiveSection == "Locations" ? "page" : null)" asp-controller="Locations" asp-action="Index" asp-route-projectId="@projectId">Locations</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Floor Plans"))" aria-current="@(Model.ActiveSection == "Floor Plans" ? "page" : null)" asp-controller="FloorPlans" asp-action="Index" asp-route-projectId="@projectId">Floor Plans</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@{ var toolsActive = Model.ActiveSection == "Story Bible" || Model.ActiveSection == "Metrics" || Model.ActiveSection == "Health" || Model.ActiveSection == "Warnings" || Model.ActiveSection == "Archive"; }
|
||||
<li class="nav-item dropdown">
|
||||
<button class="nav-link dropdown-toggle @(toolsActive ? "active" : string.Empty)" type="button" id="appToolsMenu" data-bs-toggle="dropdown" aria-expanded="false">Tools</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="appToolsMenu">
|
||||
<li><a class="dropdown-item @(ActiveClass("Story Bible"))" aria-current="@(Model.ActiveSection == "Story Bible" ? "page" : null)" asp-controller="StoryBible" asp-action="Index" asp-route-projectId="@projectId">Story Bible</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Metrics"))" aria-current="@(Model.ActiveSection == "Metrics" ? "page" : null)" asp-controller="ProjectMetrics" asp-action="Index" asp-route-projectId="@projectId">Metrics</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Health"))" aria-current="@(Model.ActiveSection == "Health" ? "page" : null)" asp-controller="Analytics" asp-action="Index" asp-route-projectId="@projectId">Health</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Warnings"))" aria-current="@(Model.ActiveSection == "Warnings" ? "page" : null)" asp-controller="Warnings" asp-action="Index" asp-route-projectId="@projectId">Warnings</a></li>
|
||||
<li><a class="dropdown-item @(ActiveClass("Archive"))" aria-current="@(Model.ActiveSection == "Archive" ? "page" : null)" asp-controller="Archives" asp-action="Index" asp-route-projectId="@projectId">Archive</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@ -3,6 +3,7 @@
|
||||
@using System.Security.Claims
|
||||
@inject IConfiguration Configuration
|
||||
@inject IFeatureRequestService FeatureRequestService
|
||||
@inject ApplicationNavigation Navigation
|
||||
@inject IOnboardingService OnboardingService
|
||||
@inject IStoryIntelligenceGlobalProgressService StoryIntelligenceGlobalProgress
|
||||
@{
|
||||
@ -20,6 +21,13 @@
|
||||
var storyIntelligenceProgress = User.Identity?.IsAuthenticated == true && !isMarketingPage
|
||||
? await StoryIntelligenceGlobalProgress.GetForCurrentUserAsync()
|
||||
: new StoryIntelligenceGlobalProgressViewModel();
|
||||
var appNavigation = User.Identity?.IsAuthenticated == true
|
||||
? await Navigation.BuildAsync(ViewData.Model, ViewData["ProjectSection"] as string, Context.Request)
|
||||
: new ApplicationNavigationViewModel();
|
||||
appNavigation.IsAdmin = isAdmin;
|
||||
appNavigation.ShowCompanionPresence = showWordCompanionHeader;
|
||||
appNavigation.FeatureRequestAttentionCount = featureRequestAttentionCount;
|
||||
appNavigation.AdminFeatureRequestAttentionCount = adminFeatureRequestAttentionCount;
|
||||
var seoMetadata = ViewData["Seo"] as SeoMetadata;
|
||||
var defaultTitle = PublicSeo.DisplayTitle(ViewData["Title"] as string);
|
||||
var seoTitle = ViewData["SeoTitle"] is string seoTitleValue ? seoTitleValue : defaultTitle;
|
||||
@ -114,120 +122,35 @@
|
||||
<meta name="msapplication-config" content="/browserconfig.xml" />
|
||||
<meta name="msapplication-TileColor" content="#1F2A44" />
|
||||
<meta name="theme-color" content="#1F2A44" />
|
||||
<link rel="stylesheet" href="~/css/application-navigation.css" asp-append-version="true" />
|
||||
</head>
|
||||
<body>
|
||||
<body class="@(User.Identity?.IsAuthenticated == true && !isMarketingPage ? "app-layout" : null)">
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm border-bottom plotline-nav mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand fw-semibold" asp-route="@PublicRouteNames.Home">PlotDirector</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
@if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Projects" asp-action="Index">Projects</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Writer" asp-action="Index">Writer Workspace</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Imports" asp-action="Index">Import</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-route="@PublicRouteNames.Help">Help</a>
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-route="@PublicRouteNames.Home">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-route="@PublicRouteNames.Features">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-route="@PublicRouteNames.Pricing">Pricing</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-route="@PublicRouteNames.Help">Help</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
<div class="d-flex align-items-center gap-2 flex-wrap">
|
||||
@if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<div class="d-flex align-items-center gap-2 flex-wrap me-sm-1">
|
||||
@if (showWordCompanionHeader)
|
||||
{
|
||||
<span class="word-companion-presence-pill"
|
||||
data-word-companion-presence
|
||||
data-word-companion-status="Offline"
|
||||
title="Word Companion status">
|
||||
<span class="word-companion-presence-dot" data-word-companion-status-dot></span>
|
||||
<span data-word-companion-status-label>Offline</span>
|
||||
</span>
|
||||
<button class="btn btn-outline-secondary btn-sm word-companion-follow-toggle" type="button" data-word-companion-follow-toggle aria-pressed="false">
|
||||
Follow Word Companion
|
||||
</button>
|
||||
}
|
||||
<a class="btn btn-outline-secondary btn-sm" asp-area="" asp-controller="FeatureRequests" asp-action="Index">
|
||||
Feature Requests
|
||||
@if (featureRequestAttentionCount > 0)
|
||||
{
|
||||
<span class="badge text-bg-warning ms-1">@featureRequestAttentionCount</span>
|
||||
}
|
||||
</a>
|
||||
@if (isAdmin)
|
||||
{
|
||||
<a class="btn btn-outline-secondary btn-sm" asp-area="" asp-controller="Admin" asp-action="Index">
|
||||
Admin
|
||||
@if (adminFeatureRequestAttentionCount > 0)
|
||||
{
|
||||
<span class="badge text-bg-danger ms-1">@adminFeatureRequestAttentionCount</span>
|
||||
}
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
<div class="nav-item dropdown">
|
||||
<button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button" id="accountMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Hello @User.Identity.Name
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="accountMenuButton">
|
||||
<li><a class="dropdown-item" asp-controller="ManageAccount" asp-action="Index">Manage Account</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="Onboarding" asp-action="Index">Setup preferences</a></li>
|
||||
<li><a class="dropdown-item" asp-controller="ManageAccount" asp-action="Subscription">Billing / Subscription</a></li>
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
<li>
|
||||
<div class="px-3 py-2">
|
||||
<div class="small text-muted mb-2">Theme</div>
|
||||
<div class="theme-switcher btn-group btn-group-sm w-100" role="group" aria-label="Theme selection">
|
||||
<button type="button" class="btn btn-outline-secondary" data-theme-choice="light" aria-pressed="true">Light</button>
|
||||
<button type="button" class="btn btn-outline-secondary" data-theme-choice="dark" aria-pressed="false">Dark</button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
<li>
|
||||
<form asp-controller="Account" asp-action="Logout" method="post" class="m-0">
|
||||
<button class="dropdown-item" type="submit">Logout</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<partial name="_ApplicationNavigation" model="appNavigation" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm border-bottom plotline-nav mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand fw-semibold" asp-route="@PublicRouteNames.Home">PlotDirector</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#publicMenu" aria-controls="publicMenu" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between" id="publicMenu">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item"><a class="nav-link text-dark" asp-route="@PublicRouteNames.Home">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link text-dark" asp-route="@PublicRouteNames.Features">Features</a></li>
|
||||
<li class="nav-item"><a class="nav-link text-dark" asp-route="@PublicRouteNames.Pricing">Pricing</a></li>
|
||||
<li class="nav-item"><a class="nav-link text-dark" asp-route="@PublicRouteNames.Help">Help</a></li>
|
||||
</ul>
|
||||
<div class="d-flex align-items-center gap-2 flex-wrap">
|
||||
<a class="btn btn-outline-secondary btn-sm" asp-controller="Account" asp-action="Login">Login</a>
|
||||
<a class="btn btn-outline-primary btn-sm" asp-controller="Account" asp-action="Register">Register</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</nav>
|
||||
}
|
||||
@if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
var primaryBook = storyIntelligenceProgress.Books.FirstOrDefault(book => book.HasActiveRuns);
|
||||
@ -400,6 +323,7 @@
|
||||
</environment>
|
||||
@if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<script src="~/js/application-navigation.js" asp-append-version="true"></script>
|
||||
<script src="~/js/word-companion-presence.js" asp-append-version="true"></script>
|
||||
<script src="~/js/story-intelligence-global-progress.js" asp-append-version="true"></script>
|
||||
}
|
||||
|
||||
@ -1,32 +1,5 @@
|
||||
@model Project
|
||||
@inject ApplicationNavigation Navigation
|
||||
@{
|
||||
var activeSection = ViewData["ProjectSection"] as string ?? "Overview";
|
||||
var projectId = Model.ProjectID;
|
||||
|
||||
string ActiveClass(string section) =>
|
||||
string.Equals(activeSection, section, StringComparison.OrdinalIgnoreCase) ? "active" : string.Empty;
|
||||
Navigation.Project = Model;
|
||||
}
|
||||
|
||||
<section class="pw-project-nav" aria-label="Project navigation">
|
||||
<span class="pw-project-nav__label">Project navigation</span>
|
||||
<nav class="pw-project-nav__links" aria-label="Project sections">
|
||||
<a class="pw-project-nav__link @(ActiveClass("Overview"))" asp-controller="Projects" asp-action="Details" asp-route-id="@projectId">Overview</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Timeline"))" asp-controller="Timeline" asp-action="Index" asp-route-projectId="@projectId">Timeline</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Calendar"))" asp-controller="StoryCalendar" asp-action="Index" asp-route-projectId="@projectId">Calendar</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("At This Point"))" asp-controller="StoryPoint" asp-action="Index" asp-route-projectId="@projectId">At This Point</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Characters"))" asp-controller="Characters" asp-action="Index" asp-route-projectId="@projectId">Characters</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Names"))" asp-controller="Names" asp-action="Index" asp-route-projectId="@projectId">Names</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Relationships"))" asp-controller="RelationshipMap" asp-action="Index" asp-route-projectId="@projectId">Relationships</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Assets"))" asp-controller="StoryAssets" asp-action="Index" asp-route-projectId="@projectId">Assets</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Locations"))" asp-controller="Locations" asp-action="Index" asp-route-projectId="@projectId">Locations</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Floor Plans"))" asp-controller="FloorPlans" asp-action="Index" asp-route-projectId="@projectId">Floor Plans</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Threads"))" asp-controller="PlotThreads" asp-action="Index" asp-route-projectId="@projectId">Threads</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Metrics"))" asp-controller="ProjectMetrics" asp-action="Index" asp-route-projectId="@projectId">Metrics</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Scenarios"))" asp-controller="Scenarios" asp-action="Index" asp-route-projectId="@projectId">Scenarios</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Story Bible"))" asp-controller="StoryBible" asp-action="Index" asp-route-projectId="@projectId">Story Bible</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Continuity Explorer"))" asp-controller="ContinuityExplorer" asp-action="Index" asp-route-projectId="@projectId">Continuity Explorer</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Health"))" asp-controller="Analytics" asp-action="Index" asp-route-projectId="@projectId">Health</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Warnings"))" asp-controller="Warnings" asp-action="Index" asp-route-projectId="@projectId">Warnings</a>
|
||||
<a class="pw-project-nav__link @(ActiveClass("Archive"))" asp-controller="Archives" asp-action="Index" asp-route-projectId="@projectId">Archive</a>
|
||||
</nav>
|
||||
</section>
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
var weekdays = new[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
|
||||
}
|
||||
|
||||
<div class="page-heading story-calendar-heading">
|
||||
<div class="page-heading story-calendar-heading" data-navigation-book-id="@Model.SelectedBookID">
|
||||
<div>
|
||||
<p class="eyebrow">Story time</p>
|
||||
<h1>Calendar <help-icon key="storyCalendar.overview" /></h1>
|
||||
|
||||
@ -8,7 +8,7 @@ else
|
||||
{
|
||||
var scene = Model.Scene;
|
||||
var exactTime = scene.TimeModeName is "Exact DateTime" or "Exact Date and Time";
|
||||
<article class="story-point" data-scene-id="@scene.SceneID">
|
||||
<article class="story-point" data-scene-id="@scene.SceneID" data-navigation-book-id="@Model.Book.BookID">
|
||||
<header class="story-point-header">
|
||||
<p class="eyebrow">@Model.Book.BookDisplayTitle · Chapter @Model.Chapter.ChapterNumber.ToString("0.##") · Scene @scene.SceneNumber.ToString("0.##")</p>
|
||||
<h2>@scene.SceneTitle</h2>
|
||||
|
||||
49
PlotLine/wwwroot/css/application-navigation.css
Normal file
49
PlotLine/wwwroot/css/application-navigation.css
Normal file
@ -0,0 +1,49 @@
|
||||
/* Compact authenticated shell; the public site and page content keep their styling. */
|
||||
.app-navigation { padding-block: .25rem; margin-bottom: .5rem; }
|
||||
.app-navigation > .container-fluid { gap: .25rem; }
|
||||
.app-navigation .navbar-brand { font-size: 1.1rem; margin-right: .5rem; padding-block: .25rem; }
|
||||
.app-navigation .nav-link { display: flex; align-items: center; gap: .2rem; border: 0; border-radius: .25rem; background: transparent; color: var(--plotline-text); font-size: .875rem; white-space: nowrap; padding: .45rem .5rem; }
|
||||
.app-navigation .nav-link:hover, .app-navigation .nav-link:focus-visible, .app-navigation .nav-link.active, .app-navigation .nav-link.show { color: var(--plotline-accent-dark); background: var(--plotline-soft); }
|
||||
.app-navigation .nav-link.active { box-shadow: inset 0 -2px var(--plotline-accent); }
|
||||
.app-navigation .nav-link:focus-visible { outline: 2px solid var(--plotline-accent); outline-offset: 1px; }
|
||||
.app-navigation .dropdown-toggle::after { flex-shrink: 0; }
|
||||
.app-context-label { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; }
|
||||
.app-book-label { max-width: 8rem; }
|
||||
.app-account-label { max-width: 7rem; overflow: hidden; text-overflow: ellipsis; }
|
||||
.app-navigation .dropdown-menu { max-width: min(28rem, calc(100vw - 1.5rem)); max-height: min(75vh, 38rem); overflow-y: auto; }
|
||||
.app-navigation .dropdown-item, .app-navigation .dropdown-header { white-space: normal; overflow-wrap: anywhere; }
|
||||
.app-navigation .dropdown-header { font-size: .8rem; margin: 0; }
|
||||
.app-navigation .dropdown-item.active { background: var(--plotline-soft); color: var(--plotline-accent-dark); font-weight: 700; }
|
||||
.app-navigation-status { margin-left: auto; }
|
||||
.app-navigation-status .word-companion-presence-pill { white-space: nowrap; font-size: .75rem; padding: .25rem .45rem; }
|
||||
.app-layout .breadcrumb-trail { gap: .3rem; margin: 0 0 .35rem; line-height: 1.35; }
|
||||
.app-layout .breadcrumb-trail a, .app-layout .breadcrumb-trail span { border: 0; border-radius: 0; padding: 0; background: transparent; font-size: .75rem; font-weight: 500; }
|
||||
.app-layout .breadcrumb-trail > * + *::before { content: "/"; margin-right: .3rem; color: var(--plotline-muted); }
|
||||
@media (min-width: 992px) {
|
||||
.app-navigation > .container-fluid { flex-wrap: nowrap; }
|
||||
.app-navigation .navbar-collapse { display: contents !important; }
|
||||
.app-navigation-menus { order: 1; flex-wrap: nowrap; }
|
||||
.app-navigation-status { order: 2; }
|
||||
.app-account-menu { order: 3; }
|
||||
}
|
||||
@media (min-width: 992px) and (max-width: 1199px) {
|
||||
.app-navigation .nav-link { padding-inline: .35rem; font-size: .8rem; }
|
||||
.app-context-label { max-width: 8rem; }
|
||||
.app-book-label { max-width: 6rem; }
|
||||
.app-account-label { max-width: 5rem; }
|
||||
}
|
||||
@media (max-width: 991.98px) {
|
||||
.app-navigation .navbar-collapse { flex-basis: 100%; }
|
||||
.app-navigation .navbar-toggler { padding: .2rem .4rem; font-size: 1rem; }
|
||||
.app-navigation .nav-link { width: 100%; text-align: left; }
|
||||
.app-navigation .dropdown-menu { max-width: 100%; }
|
||||
.app-context-label, .app-account-label { max-width: calc(100vw - 4rem); }
|
||||
.app-account-menu .dropdown-menu { position: static; }
|
||||
}
|
||||
[data-theme="dark"] .app-navigation .nav-link:hover,
|
||||
[data-theme="dark"] .app-navigation .nav-link:focus-visible,
|
||||
[data-theme="dark"] .app-navigation .nav-link.active,
|
||||
[data-theme="dark"] .app-navigation .nav-link.show,
|
||||
[data-theme="dark"] .app-navigation .dropdown-item.active { background: rgba(241, 195, 143, .12); color: var(--app-link); }
|
||||
[data-theme="dark"] .app-layout .breadcrumb-trail a,
|
||||
[data-theme="dark"] .app-layout .breadcrumb-trail span { background: transparent !important; }
|
||||
@ -724,29 +724,8 @@ a:hover {
|
||||
max-width: 52rem;
|
||||
}
|
||||
|
||||
.pw-project-nav {
|
||||
display: grid;
|
||||
gap: 0.55rem;
|
||||
margin: 0 0 1.1rem;
|
||||
border: 1px solid var(--plotline-border-soft);
|
||||
border-radius: var(--plotline-radius);
|
||||
padding: 0.7rem 0.75rem;
|
||||
background:
|
||||
linear-gradient(135deg, rgba(255, 253, 248, 0.9), rgba(242, 226, 207, 0.55)),
|
||||
var(--plotline-surface);
|
||||
box-shadow: var(--plotline-shadow-subtle);
|
||||
}
|
||||
|
||||
.pw-project-nav__label {
|
||||
color: var(--plotline-accent);
|
||||
font-size: 0.68rem;
|
||||
font-weight: 850;
|
||||
letter-spacing: 0.1em;
|
||||
line-height: 1;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.pw-project-nav__links,
|
||||
.pw-character-nav {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@ -754,7 +733,6 @@ a:hover {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.pw-project-nav__link,
|
||||
.pw-character-nav__link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@ -773,8 +751,6 @@ a:hover {
|
||||
transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
|
||||
}
|
||||
|
||||
.pw-project-nav__link:hover,
|
||||
.pw-project-nav__link:focus,
|
||||
.pw-character-nav__link:hover,
|
||||
.pw-character-nav__link:focus {
|
||||
color: var(--plotline-accent-dark);
|
||||
@ -783,7 +759,6 @@ a:hover {
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62), 0 5px 12px rgba(62, 45, 28, 0.06);
|
||||
}
|
||||
|
||||
.pw-project-nav__link.active,
|
||||
.pw-character-nav__link.active {
|
||||
color: #fff8ec;
|
||||
border-color: var(--plotline-accent);
|
||||
@ -1188,9 +1163,6 @@ a:hover {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pw-project-nav {
|
||||
padding: 0.65rem;
|
||||
}
|
||||
|
||||
.project-tabs {
|
||||
width: 100%;
|
||||
@ -2710,24 +2682,12 @@ a:focus-visible {
|
||||
border-color: #ffd5a6;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .pw-project-nav {
|
||||
color: var(--app-text);
|
||||
border-color: rgba(241, 195, 143, 0.18);
|
||||
background:
|
||||
linear-gradient(135deg, rgba(42, 35, 30, 0.96), rgba(58, 42, 32, 0.58)),
|
||||
var(--app-surface);
|
||||
box-shadow: var(--plotline-shadow-subtle);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .pw-project-nav__label {
|
||||
color: #dfc6aa;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .pw-character-nav {
|
||||
border-bottom-color: rgba(241, 195, 143, 0.16);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .pw-project-nav__link,
|
||||
[data-theme="dark"] .pw-character-nav__link {
|
||||
color: #f1dcc4;
|
||||
border-color: rgba(241, 195, 143, 0.26);
|
||||
@ -2735,8 +2695,6 @@ a:focus-visible {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .pw-project-nav__link:hover,
|
||||
[data-theme="dark"] .pw-project-nav__link:focus,
|
||||
[data-theme="dark"] .pw-character-nav__link:hover,
|
||||
[data-theme="dark"] .pw-character-nav__link:focus {
|
||||
color: #21160f;
|
||||
@ -2745,7 +2703,6 @@ a:focus-visible {
|
||||
box-shadow: 0 6px 14px rgba(0, 0, 0, 0.24);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .pw-project-nav__link.active,
|
||||
[data-theme="dark"] .pw-character-nav__link.active {
|
||||
color: #21160f;
|
||||
border-color: #ffd5a6;
|
||||
|
||||
4
PlotLine/wwwroot/css/plotline-theme.min.css
vendored
4
PlotLine/wwwroot/css/plotline-theme.min.css
vendored
File diff suppressed because one or more lines are too long
@ -976,21 +976,6 @@ td.text-end {
|
||||
background: #f3f4f2;
|
||||
}
|
||||
|
||||
.word-companion-follow-toggle[aria-pressed="true"] {
|
||||
border-color: rgba(47, 111, 99, 0.36);
|
||||
color: var(--plotline-accent-dark);
|
||||
background: var(--plotline-soft);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.word-companion-follow-toggle[aria-pressed="true"]::after {
|
||||
content: " On";
|
||||
}
|
||||
|
||||
.word-companion-follow-toggle[aria-pressed="false"]::after {
|
||||
content: " Off";
|
||||
}
|
||||
|
||||
.order-buttons {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
|
||||
2
PlotLine/wwwroot/css/site.min.css
vendored
2
PlotLine/wwwroot/css/site.min.css
vendored
File diff suppressed because one or more lines are too long
38
PlotLine/wwwroot/js/application-navigation.js
Normal file
38
PlotLine/wwwroot/js/application-navigation.js
Normal file
@ -0,0 +1,38 @@
|
||||
(() => {
|
||||
const navigation = document.querySelector('[data-app-navigation]');
|
||||
if (!navigation) return;
|
||||
const label = navigation.querySelector('[data-app-book-label]');
|
||||
const heading = navigation.querySelector('[data-app-book-heading]');
|
||||
const choices = [...navigation.querySelectorAll('[data-app-book-choice]')];
|
||||
let currentBook;
|
||||
const updateBook = () => {
|
||||
// Calendar and At This Point replace their content without re-rendering the layout.
|
||||
const context = document.querySelector('[data-navigation-book-id]');
|
||||
const pointBook = document.querySelector('[data-point-book]');
|
||||
if ((!context && !pointBook) || !label) return;
|
||||
const id = pointBook?.value ?? context?.dataset.navigationBookId ?? '';
|
||||
if (id === currentBook) return;
|
||||
currentBook = id;
|
||||
const selected = choices.find(x => x.dataset.appBookChoice === id);
|
||||
label.textContent = selected?.dataset.appBookTitle || 'Book';
|
||||
label.closest('button').title = label.textContent;
|
||||
heading.textContent = selected?.dataset.appBookTitle || 'Books in this project';
|
||||
choices.forEach(choice => {
|
||||
const active = choice === selected;
|
||||
choice.classList.toggle('active', active);
|
||||
if (active) choice.setAttribute('aria-current', 'page');
|
||||
else choice.removeAttribute('aria-current');
|
||||
});
|
||||
navigation.querySelectorAll('[data-app-book-action]').forEach(item => {
|
||||
item.hidden = !selected;
|
||||
const link = item.querySelector('[data-app-book-url]');
|
||||
if (!selected || !link) return;
|
||||
const url = new URL(link.dataset.appBookUrl, location.origin);
|
||||
url.searchParams.set(link.dataset.appBookParam || 'id', id);
|
||||
link.href = url.pathname + url.search;
|
||||
});
|
||||
};
|
||||
updateBook();
|
||||
const main = document.querySelector('.plotline-help-main');
|
||||
if (main) new MutationObserver(updateBook).observe(main, { childList: true, subtree: true });
|
||||
})();
|
||||
@ -109,143 +109,6 @@
|
||||
};
|
||||
})();
|
||||
|
||||
(() => {
|
||||
const toggle = document.querySelector("[data-word-companion-follow-toggle]");
|
||||
if (!toggle || !window.signalR) {
|
||||
return;
|
||||
}
|
||||
|
||||
const storageKey = "plotdirector.followWordCompanion";
|
||||
const unsafePathPrefixes = [
|
||||
"/pricing",
|
||||
"/about",
|
||||
"/contact",
|
||||
"/privacy",
|
||||
"/terms",
|
||||
"/admin",
|
||||
"/billing",
|
||||
"/account",
|
||||
"/login",
|
||||
"/register",
|
||||
"/feature-requests/admin",
|
||||
"/featurerequests/admin",
|
||||
"/manageaccount"
|
||||
];
|
||||
let lastSceneId = null;
|
||||
let lastCharactersProjectId = null;
|
||||
|
||||
const readEnabled = () => {
|
||||
try {
|
||||
return localStorage.getItem(storageKey) === "true";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const writeEnabled = (value) => {
|
||||
try {
|
||||
localStorage.setItem(storageKey, value ? "true" : "false");
|
||||
} catch {
|
||||
// Follow mode is optional, so storage failures should not interrupt the app.
|
||||
}
|
||||
};
|
||||
|
||||
const applyToggle = (enabled) => {
|
||||
toggle.setAttribute("aria-pressed", String(enabled));
|
||||
toggle.classList.toggle("active", enabled);
|
||||
toggle.title = enabled
|
||||
? "PlotDirector will follow the current Word Companion scene."
|
||||
: "Enable this to let PlotDirector follow the current Word Companion scene.";
|
||||
};
|
||||
|
||||
const isSafeCurrentPage = () => {
|
||||
const path = window.location.pathname.toLowerCase();
|
||||
if (path === "/" || path === "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (document.querySelector("[data-writing-mode]")
|
||||
|| path === "/writing/context"
|
||||
|| path.startsWith("/writing/context/")
|
||||
|| path === "/writing/intent"
|
||||
|| path.startsWith("/writing/intent/")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !unsafePathPrefixes.some((prefix) => path === prefix || path.startsWith(`${prefix}/`));
|
||||
};
|
||||
|
||||
const safeRelativeUrl = (url, expectedPrefix) => {
|
||||
if (typeof url !== "string" || !url.startsWith(expectedPrefix)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = new URL(url, window.location.origin);
|
||||
return parsed.origin === window.location.origin ? `${parsed.pathname}${parsed.search}${parsed.hash}` : "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
const navigateIfAllowed = (url) => {
|
||||
if (!readEnabled() || !isSafeCurrentPage() || !url) {
|
||||
return;
|
||||
}
|
||||
|
||||
const current = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
||||
if (current === url) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.assign(url);
|
||||
};
|
||||
|
||||
applyToggle(readEnabled());
|
||||
toggle.addEventListener("click", () => {
|
||||
const enabled = !readEnabled();
|
||||
writeEnabled(enabled);
|
||||
applyToggle(enabled);
|
||||
});
|
||||
|
||||
const connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("/hubs/word-companion-follow")
|
||||
.withAutomaticReconnect()
|
||||
.build();
|
||||
|
||||
connection.on("wordCompanionSceneChanged", (payload) => {
|
||||
const position = window.PlotDirectorStoryPosition?.publishChanged(payload, "WordCompanion")
|
||||
|| { sceneId: Number.parseInt(payload?.sceneId || payload?.SceneId || "", 10) };
|
||||
const sceneId = position.sceneId;
|
||||
if (!Number.isInteger(sceneId) || sceneId <= 0 || sceneId === lastSceneId) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastSceneId = sceneId;
|
||||
const sceneUrl = safeRelativeUrl(payload?.sceneUrl || payload?.SceneUrl || "", "/Scenes/Edit/");
|
||||
navigateIfAllowed(sceneUrl);
|
||||
});
|
||||
|
||||
connection.on("storyPositionChanged", (payload) => {
|
||||
window.PlotDirectorStoryPosition?.publishChanged(payload, payload?.source || payload?.Source || "WordCompanion");
|
||||
});
|
||||
|
||||
connection.on("wordCompanionCharactersCreated", (payload) => {
|
||||
const projectId = Number.parseInt(payload?.projectId || payload?.ProjectId || "", 10);
|
||||
if (!Number.isInteger(projectId) || projectId <= 0 || projectId === lastCharactersProjectId) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastCharactersProjectId = projectId;
|
||||
const charactersUrl = safeRelativeUrl(payload?.charactersUrl || payload?.CharactersUrl || "", "/Characters");
|
||||
navigateIfAllowed(charactersUrl);
|
||||
});
|
||||
|
||||
connection.start().catch((error) => {
|
||||
console.debug("Word Companion follow connection unavailable.", error);
|
||||
});
|
||||
})();
|
||||
|
||||
(() => {
|
||||
const modalElement = document.getElementById("plotlineConfirmModal");
|
||||
const modal = modalElement && window.bootstrap ? new bootstrap.Modal(modalElement) : null;
|
||||
|
||||
2
PlotLine/wwwroot/js/site.min.js
vendored
2
PlotLine/wwwroot/js/site.min.js
vendored
File diff suppressed because one or more lines are too long
@ -210,6 +210,12 @@
|
||||
.withAutomaticReconnect()
|
||||
.build();
|
||||
|
||||
// The workspace keeps receiving canonical positions independently of the
|
||||
// retired global browser-navigation toggle.
|
||||
connection.on("storyPositionChanged", (payload) => {
|
||||
window.PlotDirectorStoryPosition?.publishChanged(payload, payload?.source || payload?.Source || "WordCompanion");
|
||||
});
|
||||
|
||||
connection.on("WritingWorkspacePresenceChanged", (status) => {
|
||||
latestStatus = status;
|
||||
document.dispatchEvent(new CustomEvent("plotdirector:writing-workspace-status", { bubbles: true, detail: status }));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user