Skip to content

Commit

Permalink
display
Browse files Browse the repository at this point in the history
  • Loading branch information
Lynn Dai committed Aug 4, 2021
1 parent 681c64b commit 1deecfd
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/NuGetGallery/Controllers/PackagesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ private async Task<JsonResult> GetVerifyPackageView(User currentUser,
packageMetadata.LicenseMetadata?.Type == LicenseType.File &&
Path.GetExtension(license).Equals(ServicesConstants.MarkdownFileExtension, StringComparison.InvariantCulture))
{
model.LicenseFileContentsHtml = _markdownService.GetHtmlFromMarkdown(packageContentData.LicenseFileContents, incrementHeadersBy: 2)?.Content;
model.LicenseFileContentsHtml = _markdownService.GetHtmlFromMarkdown(packageContentData.LicenseFileContents, incrementHeadersBy: 2);
}

model.LicenseExpressionSegments = packageContentData.LicenseExpressionSegments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private DisplayLicenseViewModel SetupInternal(
package.EmbeddedLicenseType == EmbeddedLicenseFileType.Markdown &&
licenseFileContents != null)
{
viewModel.LicenseFileContentsHtml = _markdownService.GetHtmlFromMarkdown(licenseFileContents)?.Content;
viewModel.LicenseFileContentsHtml = _markdownService.GetHtmlFromMarkdown(licenseFileContents);
}

return viewModel;
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/RequestModels/VerifyPackageRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public VerifyPackageRequest(PackageMetadata packageMetadata, IEnumerable<User> p
public string LicenseExpression { get; set; }
public IReadOnlyCollection<CompositeLicenseExpressionSegmentViewModel> LicenseExpressionSegments { get; set; }
public string LicenseFileContents { get; set; }
public string LicenseFileContentsHtml { get; set; }
public RenderedMarkdownResult LicenseFileContentsHtml { get; set; }
public string MinClientVersionDisplay { get; set; }
public string ProjectUrl { get; set; }
public string RepositoryUrl { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/ViewModels/DisplayLicenseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class DisplayLicenseViewModel : PackageViewModel
public IReadOnlyCollection<string> LicenseNames { get; set; }
public IReadOnlyCollection<CompositeLicenseExpressionSegment> LicenseExpressionSegments { get; set; }
public string LicenseFileContents { get; set; }
public string LicenseFileContentsHtml { get; set; }
public RenderedMarkdownResult LicenseFileContentsHtml { get; set; }
}
}
11 changes: 8 additions & 3 deletions src/NuGetGallery/Views/Packages/License.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@
<div class="common-licenses">
@if (Model.LicenseFileContentsHtml != null)
{
@Html.Raw(Model.LicenseFileContentsHtml)
}
else
if (Model.LicenseFileContentsHtml.ImageSourceDisallowed)
{
@ViewHelpers.AlertWarning(@<text>Some images are not displayed as they are not from <a href='https://aka.ms/nuget-org-readme#allowed-domains-for-images-and-badges'>trusted domains</a>.</text>)

}
@Html.Raw(Model.LicenseFileContentsHtml.Content)
}
else
{
<pre class="license-file-contents custom-license-container">@Model.LicenseFileContents</pre>
}
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetGallery/Views/Packages/_VerifyMetadata.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@
<div class="verify-package-field common-licenses">
<label class="verify-package-field-heading">License file</label>
<!-- ko if: $data.LicenseFileContentsHtml -->
<span class="license-file-html-container" data-bind="html: $data.LicenseFileContentsHtml"></span>
<!-- ko if: $data.LicenseFileContentsHtml.ImageSourceDisallowed-->
@ViewHelpers.AlertWarning(@<text>Some images are not displayed as they are not from <a href='https://aka.ms/nuget-org-readme#allowed-domains-for-images-and-badges'>trusted domains</a>.</text>)
<!-- /ko -->
<span class="license-file-html-container" data-bind="html: $data.LicenseFileContentsHtml.Content"></span>
<!-- /ko -->
<!-- ko ifnot: $data.LicenseFileContentsHtml -->
<pre class="license-file-contents custom-license-container" data-bind="text: $data.LicenseFileContents"></pre>
Expand Down

0 comments on commit 1deecfd

Please sign in to comment.