praeclarum / FuGetGallery

An alternative web UI for browsing nuget packages

Home Page:https://www.fuget.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move to extract Icon property to display in PackageData

timheuer opened this issue · comments

With the deprecation of iconUrl packages have moved to icon which is a package-local path to an icon image. Move to using this in PackageData and extract that as base64 data URI to display

Yeah I've been debating how to handle this (license too). Never considered the base64 trick. I like it!

I did a quick hack to prove 'it works' but now need to figure out how to extract/read the image stream which really could be anywhere in the package -- so thinking PackageData would have another List for Images (anything with JPG/JPEG/PNG?) and then i guess need to iterate and match against IconUrl. Streaming the bytes is I guess the tricky part because right now Fuget only does that with nuspec as far as I can see?

The current streaming support is through PackageData.Entry which loads the compressed data from nuget into a MemoryStream. The memory stream is used to get seekability, but not everything requires that so there's some room for optimization.

The entries are queried when the package data is loaded. I think I already also force nuspec loading at that point (to check the license) so it should be easy to match up the XML icon name with the entry list at that point.

Somewhere around here:

if (nuspecEntry != null) {
ReadNuspec (nuspecEntry);
}
TargetFrameworks.Sort ((a,b) => string.Compare (a.Moniker, b.Moniker, StringComparison.Ordinal));

FYI while the iconUrl field in .nuspec files have been deprecated, the iconUrl field in the package metadata API is still valid: https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#catalog-entry

Even for packages with embedded icons, nuget.org will have a valid iconUrl there. I would recommend loading icons from that URL.