-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Preview mode: Server-side generated preview URLs #20021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
004d6a2
Serverside generated preview URLs
kjac 28e9200
Add URL provider notation to UrlInfo
kjac 64ae0ab
Merge branch 'v17/dev' into v17/feature/preview-urls
kjac 37c0990
Change preview URL generation to happen at preview time based on prov…
kjac b21c2bb
Update XML docs
kjac 7823097
Always add culture (if available) to preview URL
kjac 6eb1071
Do not log user input (security vulnerability)
kjac cf2452d
Merge branch 'v17/dev' into v17/feature/preview-urls
kjac b6417cc
Fix typo
kjac 5dfbef5
Merge branch 'v17/dev' into v17/feature/preview-urls
kjac b92aa09
Re-generate TypeScript client
leekelleher d45f62b
Deprecated `UmbDocumentPreviewRepository.enter()` (for v19)
leekelleher 2992026
Adds `previewOption` extension-type
leekelleher e073433
Adds "default" `previewOption` kind
leekelleher f45cdcc
Relocated "Save and Preview" workspace action
leekelleher b2be9d1
Added stub for "urlProvider" `previewOption` kind
leekelleher 68f851a
Renamed "workspace-action-default-kind.element.ts"
leekelleher 9524216
Refactored "Save and Preview" button
leekelleher 9356b59
Reverted `previewOption` extension-type
leekelleher 32b7c89
Modified `saveAndPreview` Document Workspace Context
leekelleher 8be39e7
Refactored "Save and Preview" button
leekelleher ae75bcc
Used `umbPeekError` to surface any errors to the user
leekelleher 36700b5
Renamed `urlProvider` kind to `previewOption`
leekelleher 633fa50
Relocated `urlProviderAlias` inside the `meta` property
leekelleher 221a44c
also throw an error
leekelleher d00df79
Added missing `await`
leekelleher 21a6cba
Merge remote-tracking branch 'origin/v17/dev' into v17/feature/previe…
iOvergaard d2105ca
Merge branch 'v17/dev' into v17/feature/preview-urls
lauraneto 7dc5ade
Merge branch 'v17/dev' into v17/feature/preview-urls
kjac fe8ac03
Fix build errors after forward merge
kjac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/Umbraco.Cms.Api.Management/Controllers/Document/DocumentPreviewUrlController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| using Asp.Versioning; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Umbraco.Cms.Api.Common.Builders; | ||
| using Umbraco.Cms.Api.Management.Factories; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Document; | ||
| using Umbraco.Cms.Core.Models; | ||
| using Umbraco.Cms.Core.Services; | ||
|
|
||
| namespace Umbraco.Cms.Api.Management.Controllers.Document; | ||
|
|
||
| [ApiVersion("1.0")] | ||
| public class DocumentPreviewUrlController : DocumentControllerBase | ||
| { | ||
| private readonly IContentService _contentService; | ||
| private readonly IDocumentUrlFactory _documentUrlFactory; | ||
|
|
||
| public DocumentPreviewUrlController( | ||
| IContentService contentService, | ||
| IDocumentUrlFactory documentUrlFactory) | ||
| { | ||
| _contentService = contentService; | ||
| _documentUrlFactory = documentUrlFactory; | ||
| } | ||
|
|
||
| [MapToApiVersion("1.0")] | ||
| [HttpGet("{id:guid}/preview-url")] | ||
| [ProducesResponseType(typeof(DocumentUrlInfo), StatusCodes.Status200OK)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] | ||
| [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
| public async Task<IActionResult> GetPreviewUrl(Guid id, string providerAlias, string? culture, string? segment) | ||
| { | ||
| IContent? content = _contentService.GetById(id); | ||
| if (content is null) | ||
| { | ||
| return NotFound(new ProblemDetailsBuilder() | ||
| .WithTitle("Document not found") | ||
| .WithDetail("The requested document did not exist.") | ||
| .Build()); | ||
| } | ||
|
|
||
| DocumentUrlInfo? previewUrlInfo = await _documentUrlFactory.GetPreviewUrlAsync(content, providerAlias, culture, segment); | ||
| if (previewUrlInfo is null) | ||
| { | ||
| return BadRequest(new ProblemDetailsBuilder() | ||
| .WithTitle("No preview URL for document") | ||
| .WithDetail("Failed to produce a preview URL for the requested document.") | ||
| .Build()); | ||
| } | ||
|
|
||
| return Ok(previewUrlInfo); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| namespace Umbraco.Cms.Core; | ||
|
|
||
| public static partial class Constants | ||
| { | ||
| public static class UrlProviders | ||
| { | ||
| public const string Content = "umbDocumentUrlProvider"; | ||
|
|
||
| public const string Media = "umbMediaUrlProvider"; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.