diff --git a/Docs/ManuscriptReader/Phase1.md b/Docs/ManuscriptReader/Phase1.md new file mode 100644 index 00000000..83a85eea --- /dev/null +++ b/Docs/ManuscriptReader/Phase1.md @@ -0,0 +1,62 @@ +# Manuscript Reader — Phase 1 + +The read-only Reader is available from **Read manuscript** in a book's Chapters list, each chapter's details, and the application Book menu. The installed PWA uses the same authenticated workspace. It requires no local Word installation. + +## Implementation and data contract + +- GET `/manuscript/reader?bookId={id}&chapterId={id}`; chapterId is optional and defaults to the first active chapter. +- `ManuscriptReaderService` separates retrieval/projection from the Razor paragraph partial and navigation controls. It calls the existing `IParagraphManuscriptRepository.Get(user, book)` / `dbo.ParagraphManuscript` get operation. That procedure checks active project access before any book metadata is fetched. Unknown/foreign books and cross-book chapter IDs return 404. +- Only committed `BookParagraphManuscripts.Payload` is read. No preview, pending capture, live Word position, reconciliation operation, bootstrap or write method is invoked. A rejected transfer leaves this existing accepted snapshot visible. Position verification is intentionally not required for reading: it concerns live Word coordinates, not validity of saved prose. +- Active chapters use existing `Chapter_ListByBook` ordering. Paragraphs use accepted heading windows and occurrence ordinal, retaining blank paragraphs and scene separators as well as prose. Canonical-zero section boundaries keep excluded sections outside chapter windows. Older or inconsistent boundary metadata falls back to explicit ChapterId assignments and the mapped heading; no boundaries are guessed. GUIDs remain in the projection for future reuse without appearing in the interface. +- Only the selected chapter is rendered/sent to the browser. This phase reuses the existing whole-book JSON read on the server; large books still incur aggregate transfer/deserialization for each request. There is no browser preloading of the book, speculative caching, second manuscript store, new database object or schema migration. +- Razor encodes prose as ordinary HTML text. Paragraphs retain captured whitespace with `white-space: pre-wrap`. Formatting absent from capture (emphasis, images, page layout and other Word objects) is not reconstructed. The captured opening chapter heading is retained verbatim without duplicating the title in the reading column. +- GET-only controller, existing authentication, no-store responses and `X-Robots-Tag: noindex, nofollow, noarchive`. Database/JSON/timeout errors produce a generic 503 page with retry, without payloads or exception messages. No offline manuscript storage is provided. + +## Timestamp meanings + +**Last successful chapter synchronisation** comes directly from the selected chapter's persisted `ChapterCheckpoints[].LastSuccessfulSyncUtc`. The existing chapter validation contract records this after successful evidence acceptance, including unchanged-text validation. It is not a claim that the prose changed at that moment. If absent, the Reader explicitly says it is not recorded. + +**Accepted manuscript snapshot captured** comes from persisted `ParagraphManuscript.UpdatedUtc`, set by bootstrap/full snapshot or chapter reconciliation. It is a book-snapshot capture time, not an invented chapter-specific sync time or the database row's UpdatedUtc (which also changes for preferences). Chapter-only unchanged validation may update its checkpoint without changing this capture time. All displayed times explicitly use UTC, to the second. A failed/pending transfer cannot supply either displayed value. + +## Verification + +Run serially: + +```sh +dotnet build PlotLine.slnx +dotnet run --no-build --project PlotLine.Tests/PlotLine.Tests.csproj +dotnet run --no-build --project PlotLine.Tests/PlotLine.Tests.csproj -- --chapter-sync +``` + +Focused Reader tests are also available with `--manuscript-reader`. + +For browser checks, start the existing isolated fixture host (synthetic manuscript, no database connection): + +```sh +PD_BROWSER_FIXTURE_URL=http://127.0.0.1:5249 dotnet run --no-build --project PlotLine.Tests/PlotLine.Tests.csproj -- --toolbar-browser-host +PD_BROWSER_FIXTURE_URL=http://127.0.0.1:5249 node PlotLine.Tests/Browser/manuscript-reader.cjs +``` + +The browser suite exercises the real controller and compiled Razor, three viewport widths (390/800/1440), all four application themes, browser and simulated installed-PWA modes, safe HTML-like text, DOM text selection, navigation/selector, empty state, UTC timestamps, focus/Escape, account/book isolation, private headers, GET-only routing and generic error/retry. PWA simulation does not constitute a Windows installed-app acceptance test. Tests use normal DOM Range selection; ElevenReader itself is not integrated or tested. + +### Results — 13 November 2026 + +- Solution build: passed, zero warnings/errors. Full executable regression harness: passed, including Reader and existing paragraph synchronisation workflows. +- Dedicated chapter synchronisation regression: passed. +- Chromium suite: passed all 24 viewport/theme/browser-or-PWA combinations, plus isolation and error/retry checks. Desktop and phone screenshots were visually inspected during development. +- Read-only live Development check: verified the effective database, retrieved first/middle/last chapters (537 paragraphs) from an existing accepted manuscript, refused an unrelated account, and confirmed the accepted revision and snapshot hash were unchanged. An earlier check traversed all 48 chapters. No author prose was exported or database state modified. +- Actual Word editing/saving and a real installed Windows PWA were unavailable on Atlas. The end-to-end scenario below remains unverified. + +## Windows Word-to-Reader acceptance still required + +1. On Windows, open the existing bound manuscript in Word using the current Companion; no new installer is required for Reader use. +2. Add a small identifiable phrase within an existing chapter, save, and wait for a successful Companion acknowledgement. Record the acknowledged chapter and UTC time. +3. On a separate browser/device, open the same book and choose **Read manuscript**, then the changed chapter. Refresh if already open. Confirm the exact phrase and paragraph position. +4. Compare the chapter synchronisation timestamp with the successful acceptance (including seconds/UTC); the separately labelled snapshot capture time has the meaning described above. +5. Drag-select multiple paragraphs and copy/paste them into a plain-text document. Optionally try the author's normal reading extension. Confirm paragraph order and literal angle-bracket text where present. +6. Use previous/next and the chapter selector, then return. Repeat on mobile and the installed desktop PWA in the desired theme. +7. Confirm Word text and Companion accepted revision remain unchanged by Reader navigation. Do not use the Reader to trigger sync; it has no mutation action. + +## Deployment + +Normal development application deployment is needed to expose the new route and assets. No SQL migration, configuration change or Companion installer is needed. This implementation does not deploy or change Production. diff --git a/PlotLine.Tests/Browser/manuscript-reader.cjs b/PlotLine.Tests/Browser/manuscript-reader.cjs new file mode 100644 index 00000000..078ce9c5 --- /dev/null +++ b/PlotLine.Tests/Browser/manuscript-reader.cjs @@ -0,0 +1,61 @@ +const assert = require('node:assert/strict'); +const { chromium } = require('playwright'); +const base = process.env.PD_BROWSER_FIXTURE_URL || 'http://127.0.0.1:5238'; +(async () => { + const browser = await chromium.launch(); + try { + for (const pwa of [false, true]) for (const width of [390, 800, 1440]) { + const context = await browser.newContext({viewport:{width,height:1000}}); + if(pwa) await context.addInitScript(() => Object.defineProperty(navigator, 'standalone', {value:true})); + const page = await context.newPage(); + for(const theme of ['modern-light','modern-dark','warm-light','warm-dark']) { + const response = await page.goto(`${base}/manuscript/reader?bookId=12&chapterId=21`); + assert.equal(response.status(),200); + assert.match(response.headers()['cache-control'],/no-store/); + assert.match(response.headers()['x-robots-tag'],/noindex/); + await page.evaluate(theme => PlotDirectorApplyApplicationTheme(theme), theme); + const paragraphs = page.locator('.reader-paragraph'); + assert.equal(await paragraphs.count(),3); + assert.match(await paragraphs.nth(1).textContent(), /First paragraph: & plain text.\r", Outline = 10 } }, + new() { ChapterId = 22, Story = true, Occurrence = new() { Id = Guid.NewGuid(), Ordinal = 3, Text = "Another chapter only.\r", Outline = 10 } }, + new() { ChapterId = null, Story = false, Occurrence = new() { Ordinal = 4, Text = "Excluded section." } } + ] + }; + } + internal static ManuscriptReaderService FixtureService(Func? snapshot = null) + { + var repository = NativeWorkflowTests.Proxy((name, args) => { + if (name != "Get") throw new Exception("Reader attempted manuscript mutation: " + name); + if ((int)args![0]! != 4 || (int)args[1]! != 12) throw new UnauthorizedAccessException(); + return Task.FromResult(snapshot is null ? Snapshot() : snapshot()); + }); + var books = NativeWorkflowTests.Proxy((name, _) => name == "GetAsync" + ? Task.FromResult(new() { BookID = 12, BookTitle = "A Distant Shore", ProjectID = 7 }) : throw new Exception(name)); + var chapters = NativeWorkflowTests.Proxy((name, _) => name == "ListByBookAsync" + ? Task.FromResult>(Chapters) : throw new Exception(name)); + return new(repository, books, chapters); + } + public static async Task Run() + { + void Check(bool value, string message) { if (!value) throw new Exception(message); } + var state = Snapshot(); var service = FixtureService(() => state); + var first = (await service.Read(4, 12, null))!; + Check(first.Chapters.Count == 3 && first.Chapter!.ChapterID == 21, "Book context and canonical chapter ordering"); + Check(first.PreviousId is null && first.NextId == 22, "First chapter navigation"); + Check(first.Paragraphs.Select(p => p.Text).SequenceEqual(state.Paragraphs.OrderBy(p => p.Occurrence.Ordinal).Take(3).Select(p => p.Occurrence.Text)), "Exact accepted paragraph order, heading and boundaries"); + Check(first.Paragraphs.All(p => p.Id != Guid.Empty), "Paragraph identities retained internally"); + Check(first.LastSuccessfulSyncUtc == state.ChapterCheckpoints[0].LastSuccessfulSyncUtc && first.SnapshotCapturedUtc == state.UpdatedUtc, "Distinct exact timestamp sources"); + var last = (await service.Read(4, 12, 23))!; + Check(last.PreviousId == 22 && last.NextId is null && last.Paragraphs.Count == 0, "Last chapter navigation and empty state"); + Check(await service.Read(4, 12, 999) is null, "Cross-book or unknown chapter rejected"); + try { await service.Read(5, 12, 21); throw new Exception("Foreign account retrieved manuscript"); } catch (UnauthorizedAccessException) { } + try { await service.Read(4, 13, 21); throw new Exception("Foreign book retrieved manuscript"); } catch (UnauthorizedAccessException) { } + var windows = Snapshot(); + windows.Paragraphs = windows.Paragraphs.OrderBy(p => p.Occurrence.Ordinal).Take(4).ToList(); + windows.Chapters.Add(new() { CanonicalId = 22, HeadingId = windows.Paragraphs[3].Occurrence.Id }); + windows.Paragraphs.Insert(2, new() { Occurrence = new() { Id = Guid.NewGuid(), Text = " ", Ordinal = 1 } }); + var complete = ManuscriptReaderService.Project(first.Book, Chapters, Chapters[0], windows); + Check(complete.Paragraphs.Count == 4 && complete.Paragraphs.Any(p => p.Text == " "), "Heading windows preserve unassigned blank paragraphs and scene separators"); + var pending = ParagraphManuscriptEngine.Clone(state); pending.Paragraphs[2].Occurrence.Text = "Pending change"; + Check((await service.Read(4, 12, 21))!.Paragraphs[1].Text != "Pending change", "Uncommitted or rejected submissions cannot enter Reader"); + state = pending; + Check((await service.Read(4, 12, 21))!.Paragraphs[1].Text == "Pending change", "Next read sees newly committed snapshot without cache"); + var empty = await FixtureService(() => null).Read(4, 12, 21); + Check(empty!.Paragraphs.Count == 0 && empty.SnapshotCapturedUtc is null, "Missing accepted snapshot remains empty without bootstrap"); + var user = NativeWorkflowTests.Proxy((_, _) => 5); + var controller = new ManuscriptReaderController(service, user, NullLogger.Instance) { ControllerContext = new() { HttpContext = new DefaultHttpContext() } }; + Check(await controller.Index(12, 21) is NotFoundResult, "Controller does not leak unauthorised book existence"); + Check(typeof(ManuscriptReaderController).IsDefined(typeof(AuthorizeAttribute), true), "Reader requires authentication"); + var cache = (ResponseCacheAttribute)System.Attribute.GetCustomAttribute(typeof(ManuscriptReaderController), typeof(ResponseCacheAttribute))!; + Check(cache.NoStore && cache.Location == ResponseCacheLocation.None, "Private manuscript responses cannot be cached"); + Check(controller.Response.Headers["X-Robots-Tag"] == "noindex, nofollow, noarchive", "Manuscript indexing disabled"); + Console.WriteLine("PASS Manuscript Reader: scoped read-only retrieval, ordering, navigation, empty snapshot, accepted updates, pending isolation and accurate timestamps"); + } +} diff --git a/PlotLine.Tests/Program.cs b/PlotLine.Tests/Program.cs index a8ceb381..a992680c 100644 --- a/PlotLine.Tests/Program.cs +++ b/PlotLine.Tests/Program.cs @@ -18,6 +18,7 @@ using PlotLine.ViewModels; if((args.Contains("--chapter-acceptance-dev")||args.Contains("--chapter-reuse-dev")||args.Contains("--chapter-incremental-dev"))){await ChapterAcceptanceDevelopmentTests.Run(args);return;} if(args.Contains("--chapter-sync-dev")){await ChapterSyncDevelopmentTests.Run(args);return;} if(args.Contains("--chapter-sync")){ChapterSynchronisationTests.Run();return;} +if(args.Contains("--manuscript-reader")){await ManuscriptReaderTests.Run();return;} #pragma warning disable CS8321 if (args.Contains("--word-marker-security")) @@ -154,6 +155,7 @@ var tests = new (string Name, Action Test)[] ("Release triage and browser-only onboarding preserve author decisions", ReleaseSprintTests.Run), ("Approved native import source and confirmation remain safe", () => NativeImportTests.Run().GetAwaiter().GetResult()), ("Native installation renewal and revocation remain account/security scoped", () => NativeInstallationTests.Run().GetAwaiter().GetResult()), + ("Manuscript Reader", () => ManuscriptReaderTests.Run().GetAwaiter().GetResult()), ("Paragraph manuscript identity, evidence and exact-session synchronisation", () => { ParagraphManuscriptTests.Run();ParagraphWorkflowTests.Run().GetAwaiter().GetResult(); }), ("Native wizard capture is scoped, durable and independent of Word", () => NativeManuscriptCaptureTests.Run().GetAwaiter().GetResult()), ("Native tray presence and PWA review remain scoped, expiring and non-destructive", () => NativeTrayIntegrationTests.Run().GetAwaiter().GetResult()), diff --git a/PlotLine.Tests/ToolbarBrowserHost.cs b/PlotLine.Tests/ToolbarBrowserHost.cs index fd6879e8..aa5a71d0 100644 --- a/PlotLine.Tests/ToolbarBrowserHost.cs +++ b/PlotLine.Tests/ToolbarBrowserHost.cs @@ -117,6 +117,9 @@ internal static class ToolbarBrowserHost builder.Services.AddSingleton(FixtureProxy((name, args) => throw new NotSupportedException(name))); builder.Services.AddSingleton(); + builder.Services.AddScoped(services => ManuscriptReaderTests.FixtureService(() => + services.GetRequiredService().HttpContext!.Request.Query["reader-error"] == "true" + ? throw new TimeoutException("Synthetic unavailable manuscript") : ManuscriptReaderTests.Snapshot())); builder.Services.AddHttpContextAccessor(); builder.Services.AddSingleton(); builder.Services.AddScoped(services => new ApplicationNavigation( diff --git a/PlotLine/Controllers/ManuscriptReaderController.cs b/PlotLine/Controllers/ManuscriptReaderController.cs new file mode 100644 index 00000000..c8c02b4d --- /dev/null +++ b/PlotLine/Controllers/ManuscriptReaderController.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Data.SqlClient; +using PlotLine.Services; +using PlotLine.Services.Manuscript; + +namespace PlotLine.Controllers; + +[Authorize] +[Route("manuscript/reader")] +[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)] +public sealed class ManuscriptReaderController(ManuscriptReaderService reader, ICurrentUserService currentUser, + ILogger logger) : Controller +{ + [HttpGet] + public async Task Index(int bookId, int? chapterId = null) + { + Response.Headers["X-Robots-Tag"] = "noindex, nofollow, noarchive"; + if (currentUser.UserId is not int user) return Challenge(); + if (bookId <= 0 || chapterId is <= 0) return NotFound(); + try + { + var model = await reader.Read(user, bookId, chapterId); + return model is null ? NotFound() : View(model); + } + catch (UnauthorizedAccessException) { return NotFound(); } + catch (SqlException e) when (e.Number == 51000) { return NotFound(); } + catch (Exception e) when (e is SqlException or TimeoutException or System.Text.Json.JsonException) + { + // Log neither SQL error text nor payloads: manuscripts are private content. + logger.LogWarning("Manuscript Reader unavailable ({FailureKind}).", e.GetType().Name); + Response.StatusCode = StatusCodes.Status503ServiceUnavailable; + return View("Unavailable", new { BookId = bookId, ChapterId = chapterId }); + } + } +} diff --git a/PlotLine/Program.cs b/PlotLine/Program.cs index e9940ee8..c6f6ea55 100644 --- a/PlotLine/Program.cs +++ b/PlotLine/Program.cs @@ -113,6 +113,7 @@ public class Program builder.Services.AddHostedService(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/PlotLine/Services/ApplicationNavigation.cs b/PlotLine/Services/ApplicationNavigation.cs index ff459330..35574c9c 100644 --- a/PlotLine/Services/ApplicationNavigation.cs +++ b/PlotLine/Services/ApplicationNavigation.cs @@ -15,7 +15,7 @@ public sealed class ApplicationNavigation(IProjectRepository projects, IBookRepo var controller = request.RouteValues["controller"]?.ToString() ?? string.Empty; var result = new ApplicationNavigationViewModel { ActiveSection = section ?? controller switch { - "Projects" or "Books" or "Chapters" or "Scenes" => "Overview", + "Projects" or "Books" or "Chapters" or "Scenes" or "ManuscriptReader" => "Overview", "StoryCalendar" => "Calendar", "StoryPoint" => "At This Point", "RelationshipMap" => "Relationships", "StoryAssets" => "Assets", "FloorPlans" => "Floor Plans", "PlotThreads" => "Threads", "PlotLineWorkspace" => "Plot Lines", diff --git a/PlotLine/Services/Manuscript/ManuscriptReaderService.cs b/PlotLine/Services/Manuscript/ManuscriptReaderService.cs new file mode 100644 index 00000000..700f6e07 --- /dev/null +++ b/PlotLine/Services/Manuscript/ManuscriptReaderService.cs @@ -0,0 +1,73 @@ +using PlotLine.Data; +using PlotLine.Models; + +namespace PlotLine.Services.Manuscript; + +public sealed record ReaderParagraph(Guid Id, string Text, bool IsHeading); +public sealed class ManuscriptReaderModel +{ + public required Book Book { get; init; } + public required IReadOnlyList Chapters { get; init; } + public Chapter? Chapter { get; init; } + public int? PreviousId { get; init; } + public int? NextId { get; init; } + public IReadOnlyList Paragraphs { get; init; } = []; + public DateTime? LastSuccessfulSyncUtc { get; init; } + public DateTime? SnapshotCapturedUtc { get; init; } +} + +// Read only: deliberately bypasses the manuscript workspace, which may bootstrap tracking. +public sealed class ManuscriptReaderService( + IParagraphManuscriptRepository manuscripts, IBookRepository books, IChapterRepository chapters) +{ + public async Task Read(int user, int bookId, int? chapterId) + { + // This existing stored procedure checks active ProjectUserAccess before returning any data, + // even when no paragraph snapshot exists. Never fetch book metadata before this check. + var state = await manuscripts.Get(user, bookId); + var book = await books.GetAsync(bookId); + if (book is null || book.IsArchived) return null; + var ordered = (await chapters.ListByBookAsync(bookId)).Where(c => !c.IsArchived).ToArray(); + var selected = chapterId.HasValue ? ordered.FirstOrDefault(c => c.ChapterID == chapterId) : ordered.FirstOrDefault(); + if (chapterId.HasValue && selected is null) return null; + return Project(book, ordered, selected, state); + } + + public static ManuscriptReaderModel Project(Book book, IReadOnlyList ordered, Chapter? selected, ParagraphManuscript? state) + { + var index = selected is null ? -1 : ordered.ToList().FindIndex(c => c.ChapterID == selected.ChapterID); + var heading = state?.Chapters.FirstOrDefault(c => c.CanonicalId == selected?.ChapterID)?.HeadingId; + // Accepted assignments, not live Word positions, govern reading. Position verification may + // expire or need review without invalidating the last committed prose. + IEnumerable source = state?.Paragraphs.Where(p => + selected is not null && (p.ChapterId == selected.ChapterID || p.Occurrence.Id == heading)) ?? []; + if (state is not null && selected is not null) + { + try + { + // Exact accepted heading windows also retain unassigned blank paragraphs and + // scene separators. Excluded sections have their own canonical-zero boundary. + var part = ChapterCheckpointEngine.Parts(state).FirstOrDefault(p => p.Chapter.CanonicalId == selected.ChapterID); + if (part is not null && !part.Rows.Any(p => p.ChapterId > 0 && p.ChapterId != selected.ChapterID)) + source = part.Rows; + } + catch (InvalidOperationException) + { + // Older accepted snapshots can lack reversible heading windows. Use only their + // explicit chapter assignments; never guess boundaries from prose or Word offsets. + } + } + var rows = source.OrderBy(p => p.Occurrence.Ordinal) + .Select(p => new ReaderParagraph(p.Occurrence.Id, p.Occurrence.Text, p.Occurrence.Id == heading || p.Occurrence.Outline is >= 1 and <= 6)) + .ToArray(); + var checkpoint = state?.ChapterCheckpoints.FirstOrDefault(c => c.ChapterId == selected?.ChapterID); + return new() + { + Book = book, Chapters = ordered, Chapter = selected, Paragraphs = rows, + PreviousId = index > 0 ? ordered[index - 1].ChapterID : null, + NextId = index >= 0 && index + 1 < ordered.Count ? ordered[index + 1].ChapterID : null, + LastSuccessfulSyncUtc = checkpoint?.LastSuccessfulSyncUtc > DateTime.MinValue ? checkpoint.LastSuccessfulSyncUtc : null, + SnapshotCapturedUtc = state?.UpdatedUtc > DateTime.MinValue ? state.UpdatedUtc : null + }; + } +} diff --git a/PlotLine/Views/Books/Details.cshtml b/PlotLine/Views/Books/Details.cshtml index 75db79cf..43e9ce2e 100644 --- a/PlotLine/Views/Books/Details.cshtml +++ b/PlotLine/Views/Books/Details.cshtml @@ -178,6 +178,7 @@

Chapters

+ Read manuscript @if (!Model.Chapters.Any()) {

No chapters yet.

@@ -212,6 +213,7 @@ @(chapter.IsLinkedToManuscript ? "🔗 Linked" : "📝 Planned") @chapter.Summary + Read manuscript Edit
diff --git a/PlotLine/Views/Chapters/Details.cshtml b/PlotLine/Views/Chapters/Details.cshtml index 2db92414..c7e857b8 100644 --- a/PlotLine/Views/Chapters/Details.cshtml +++ b/PlotLine/Views/Chapters/Details.cshtml @@ -30,6 +30,7 @@ / @Model.Book.BookTitle

Chapter @Model.Chapter.ChapterNumber: @Model.Chapter.ChapterTitle

+ Read manuscript @(Model.Chapter.IsLinkedToManuscript ? "🔗 Linked" : "📝 Planned") @if (!string.IsNullOrWhiteSpace(Model.Chapter.ChapterPurposeName)) { diff --git a/PlotLine/Views/ManuscriptReader/Index.cshtml b/PlotLine/Views/ManuscriptReader/Index.cshtml new file mode 100644 index 00000000..8443e9d0 --- /dev/null +++ b/PlotLine/Views/ManuscriptReader/Index.cshtml @@ -0,0 +1,64 @@ +@model PlotLine.Services.Manuscript.ManuscriptReaderModel +@{ + ViewData["Title"] = $"Manuscript Reader · {Model.Book.BookTitle}"; + ViewData["DesktopLayout"] = "details"; +} + +
+ +
+

@Model.Book.BookTitle

Manuscript Reader

Read only
+
+ + +
+ @if (Model.LastSuccessfulSyncUtc is DateTime sync) + {

Last successful chapter synchronisation:

} + else {

No successful chapter synchronisation timestamp is recorded.

} + @if (Model.SnapshotCapturedUtc is DateTime captured) + {

Accepted manuscript snapshot captured:

} +

Showing the latest accepted server text. Refresh to read newly synchronised changes.

+
+ @if (Model.Paragraphs.Count == 0) + { +

@(Model.Chapter?.ChapterTitle ?? "No chapters yet")

+

No accepted manuscript text is available for this chapter. Save and successfully synchronise it using Word Companion, then refresh this page.

+ Refresh manuscript +
+ } + else + { +
+

Chapter @Model.Chapter?.ChapterNumber

+ @if (!Model.Paragraphs[0].IsHeading) + {

@Model.Chapter?.ChapterTitle

} +
+ +
+ } +

Captured paragraph text and headings are preserved. Word formatting such as bold, italics, images and page layout is not available in this capture.

+ Return to Chapters + Refresh manuscript +
+
+ diff --git a/PlotLine/Views/ManuscriptReader/Unavailable.cshtml b/PlotLine/Views/ManuscriptReader/Unavailable.cshtml new file mode 100644 index 00000000..fd701ea3 --- /dev/null +++ b/PlotLine/Views/ManuscriptReader/Unavailable.cshtml @@ -0,0 +1,9 @@ +@{ + ViewData["Title"] = "Manuscript Reader unavailable"; +} + diff --git a/PlotLine/Views/ManuscriptReader/_Paragraphs.cshtml b/PlotLine/Views/ManuscriptReader/_Paragraphs.cshtml new file mode 100644 index 00000000..88a1b638 --- /dev/null +++ b/PlotLine/Views/ManuscriptReader/_Paragraphs.cshtml @@ -0,0 +1,11 @@ +@model IReadOnlyList +@for (var index = 0; index < Model.Count; index++) +{ + var paragraph = Model[index]; + if (paragraph.IsHeading && index == 0) + {

@paragraph.Text

} + else if (paragraph.IsHeading) + {

@paragraph.Text

} + else + {

@paragraph.Text

} +} diff --git a/PlotLine/Views/Shared/_ApplicationNavigation.cshtml b/PlotLine/Views/Shared/_ApplicationNavigation.cshtml index 561fb419..0910978d 100644 --- a/PlotLine/Views/Shared/_ApplicationNavigation.cshtml +++ b/PlotLine/Views/Shared/_ApplicationNavigation.cshtml @@ -51,12 +51,13 @@ @if (project is not null) {